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