Cleaned up directory a bit...
[mirrors/Programs.git] / misc / BinCracking / patcher_gen.phps
... / ...
CommitLineData
1<?php\r
2//Patcher generator 0.3\r
3//Harvie 2oo7\r
4/*\r
5This will parse output from my HexCmp tool and\r
6create the code, than can be directly pasted to\r
7my BinPatcher source.\r
8Making of patcher was never easier.\r
9*/\r
10\r
11///SETINGS///////////////////////////////////////////////////////\r
12$proc = "hexcmp orig.exe crac.exe"; //HexCmp command\r
13$fp = "bin"; //FILE pointer to handle with\r
14\r
15///CODE//////////////////////////////////////////////////////////\r
16$pp = popen($proc, "r");\r
17while(!feof($pp)) {\r
18 $line = trim(fgets($pp));\r
19 \r
20 if(ereg("Difference", $line)) {\r
21 $offset = explode("H: ", $line);\r
22 $offset = $offset[1];\r
23 echo("fseek($fp, $offset"."L, SEEK_SET); //Seek to $offset\n");\r
24 }\r
25 \r
26 if(ereg("\\\\x.", $line)) {\r
27 $bytes = substr_count($line, "\\x");\r
28 echo(" fwrite(\"$line\", $bytes, 1, $fp); //Patch $bytes bytes\n");\r
29 }\r
30\r
31}\r
32\r
33///EXAMPLE///////////////////////////////////////////////////////\r
34/*\r
35 //Example output from HexCmp:\r
36Difference @ D: 222313 H: 0x36469\r
37\x90\x90\x90\x90\x90\r
38Lenght: 5 Bytes\r
39\r
40Difference @ D: 317430 H: 0x4d7f6\r
41\x13\x37\xc0\xde\r
42Lenght: 4 Bytes\r
43\r
44 //Will be turned to something like this:\r
45fseek(bin, 0x36469L, SEEK_SET); //Seek to 0x36469\r
46 fwrite("\x90\x90\x90\x90\x90", 5, 1, bin); //Patch 5 bytes\r
47fseek(bin, 0x4d7f6L, SEEK_SET); //Seek to 0x4d7f6\r
48 fwrite("\x13\x37\xc0\xde", 4, 1, bin); //Patch 4 bytes\r
49\r
50//Just compile ;))\r
51*/\r
52?>\r
This page took 0.540337 seconds and 4 git commands to generate.