Jump to content
metin2dev

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
  • Like 1

Share this post


Link to post
Share on other sites
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

  • Like 1

Share this post


Link to post
Share on other sites

@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.

Sry for Bad Eng <_<

Share this post


Link to post
Share on other sites
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

  • Like 1

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
On 13/01/2018 at 4:34 PM, .Rise said:

It shows virus..

Explain to me, how can a source code alert virus?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×