Jump to content

Open Source CRC Patcher


Recommended Posts

Require administrator priviliges:

Right click on the project -> Add -> New Item -> Application Manifest File

Search this:
 

<requestedExecutionLevel level="asInvoker" uiAccess="false" />

 

Replace with this:
 

<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

 

Edited by Minton
  • Love 2

System Administrator @ Hungarian Government
System Administrator @ Vibestro
Freelancer Developer @ Various projects

Link to comment
Share on other sites

  • 3 months later...
On 6/19/2015, 12:50:54, ☢ cнαяραяσdαя ☢ said:

Hello again,

I realised that the patcher doesn't download bigger files, like 35MB +, but the download, checks them as complete...

Is the Lister that is doing wrong the crc code? Or is the patcher that have a size limit to download?

Thanks...

Hi, try to change crc hash to md5, it helped me.

 

Spoiler

 

In Common.cs

Add this in begging of the file:


using System.Security.Cryptography;

and after:


        public static string GetHash(string Name)
        {
            if (Name == string.Empty)
                return string.Empty;

            CRC crc = new CRC();

            string Hash = string.Empty;

            using (FileStream fileStream = File.Open(Name, FileMode.Open))
            {
                foreach (byte b in crc.ComputeHash(fileStream))
                {
                    Hash += b.ToString("x2").ToLower();
                }
            }

            return Hash;
        }

add:


        public static string CalculateMD5Hash(string Name)
        {
            if (Name == string.Empty)
                return null;

            MD5 md5 = System.Security.Cryptography.MD5.Create();

            string Hash = string.Empty;

            try
            {
                using (FileStream fileStream = File.Open(Name, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    foreach (byte b in md5.ComputeHash(fileStream))
                    {
                        Hash += b.ToString("x2").ToLower();
                    }
                }
            }
            catch
            {
                MessageBox.Show("Can't open: " + Name);
            }

            return Hash;
        }

In FileChecker.cs find:


if (!File.Exists(file.Name) || Common.GetHash(file.Name) != file.Hash)

and replace with:


if (!File.Exists(file.Name) || Common.CalculateMD5Hash(file.Name) != file.Hash)

After these changes you'll have MD5 Patcher :)

PS: Atm I'm experiencing some problems with progress bar, will add solution if I'll find it.

 

 

 

 

Also I'd like to share php script which generate patchlist.txt (probably will be useful for someone):

Spoiler

 


<?php
/*
Usage: Upload this file to the web-server, in folder with patchlist.txt and open it in browser.
Note: I recommend to protect this file from public usage with password (put file in folder, change output file and directory path and and use .htaccess)
*/
function list_directory($dir) {
	$file_list = array();
	$stack[] = $dir;

	while ($stack) {
		$current_dir = array_pop($stack);
		if ($dh = opendir($current_dir)) {
			while (($file = readdir($dh)) !== false) {
				if ($file !== '.' AND $file !== '..') {
					$current_file = "{$current_dir}/{$file}";
					$report = array();
					if (is_file($current_file)) {
						$file_list[] = "{$current_dir}/{$file}";
					} elseif (is_dir($current_file)) {
						$stack[] = $current_file;
						$file_list[] = "{$current_dir}/{$file}/";
					}
				}
			}
		}
	}

	return $file_list;
}

$files = list_directory('.'); // Path to directory with files
sort($files, SORT_NATURAL | SORT_FLAG_CASE);
$line = "";
foreach($files as $file)
{
	$hash = hash_file( 'crc32b', $file );
	$size = filesize($file);

	if($hash == "00000000" || preg_match("/patchlist/", $file))
		continue;

	$file_n = preg_replace("/^../","",$file);
	echo $file_n . " " . $hash . " " . $size . "<br>";
	$line .= $file_n . " " . $hash . " " . $size . "\r\n";
}

$handle = fopen("patchlist.txt", "w+"); // Path to output file
fwrite($handle, $line);
fclose($handle);
?>

 

 

 

 

 

Best Regards

  • Love 1
Link to comment
Share on other sites

  • 2 weeks later...
13 hours ago, berseker said:

@wezt i try to change the code for md5, the problem is the patchlist that don't have the md5 hash saved and the patcher continue to download every time you start the patch.

Hi, you need to use patchlist.txt with md5 hash. In order to get md5 you can use php script (was added in previous post) but you need:

//change this line
$hash = hash_file( 'crc32b', $file );
//to
$hash = hash_file( 'md5', $file );

Or you can add "CalculateMD5Hash(string Name)" function in Sanchez.Lister

  • Love 1
Link to comment
Share on other sites

On 26.11.2015, 12:54:14, wezt said:

Hi, you need to use patchlist.txt with md5 hash. In order to get md5 you can use php script (was added in previous post) but you need:


//change this line
$hash = hash_file( 'crc32b', $file );
//to
$hash = hash_file( 'md5', $file );

Or you can add "CalculateMD5Hash(string Name)" function in Sanchez.Lister

Hi bro. I have problem with this patcher.

 Some people have error:

Can't connect to server, please check your network settings and try again.

And patcher can`t download file.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...
  • 4 months later...
  • 4 months later...
  • 4 weeks later...
  • Management
On 12/12/2016 at 8:08 PM, RaVenRG said:

Hi if i change something in locale_pl or somewhere do it download it too?

It just would change if you put on the auto patcher, every time you change something on locale and pack, the CRC32 must change, soo if you put on the auto patcher it'll download automatically...

raw

raw

Link to comment
Share on other sites

  • 1 year later...
  • 2 months later...
  • 4 months later...
  • 1 month later...
  • 2 weeks later...
La 18.10.2018 la 12:10, Traceur3RUN a spus:

can someone fix this bug?

when you have like

something/something/something

then this doesnt work, because dont create folder with lz

 

only work with

pack/

but dont work if you have

lib/lib/

What do you mean by that?

You want to put only the path to the file, or the whole file?

But you can do that.

Eg. /public_html/patch/client/any folder you want (without writing that full path as url_path to your source code, in Globals.cs, but adding the folder/folders  in patchlist)

 

Best of luck

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 year later...
  • Contributor
4 hours ago, BeauDeCiuda said:

virus

This is the hidden content, please

 

Sanchez's upload does not even contain an exe lol.

Your got virus probably because of a pirated visual studio, or already infected machine.

 

If you compile it in a legal vs, it will only produce 2 false positive by noname antivirus. It is because it connects to the internet and downloads files.

Btw this patcher does not have any "extern" or "lib" so it is 100% open source, you can see every files, only .cs, resx, sln, vcproj,

these are text files so you can see what's inside them.

Edited by TMP4
  • Metin2 Dev 3
Link to comment
Share on other sites

  • Contributor

Hungarian:

Spoiler

 

Hogyan üzemeld be:

 

1. Változtasd meg a ServerURL-t a Globals.cs fájlban a sajátodra

2. Fordítsd le a projectet VisualStudio-ban

3. Csináld meg a listát a fájlokról a lister tool-al (Példa hogy néz ki a lista)

4. Töltsd fel a kliensedet és a lista fájlt a webszerveredre (Példa hogy néz ki a mappa stuktúrája)

 

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 10
  • Dislove 1
  • Not Good 1
  • Good 1
  • Love 2
Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.