Commit | Line | Data |
---|---|---|
eb313e17 H |
1 | <?php\r |
2 | //Patcher generator 0.3\r | |
3 | //Harvie 2oo7\r | |
4 | /*\r | |
5 | This will parse output from my HexCmp tool and\r | |
6 | create the code, than can be directly pasted to\r | |
7 | my BinPatcher source.\r | |
8 | Making 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 | |
17 | while(!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 | |
36 | Difference @ D: 222313 H: 0x36469\r | |
37 | \x90\x90\x90\x90\x90\r | |
38 | Lenght: 5 Bytes\r | |
39 | \r | |
40 | Difference @ D: 317430 H: 0x4d7f6\r | |
41 | \x13\x37\xc0\xde\r | |
42 | Lenght: 4 Bytes\r | |
43 | \r | |
44 | //Will be turned to something like this:\r | |
45 | fseek(bin, 0x36469L, SEEK_SET); //Seek to 0x36469\r | |
46 | fwrite("\x90\x90\x90\x90\x90", 5, 1, bin); //Patch 5 bytes\r | |
47 | fseek(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 |