$v) { $q[$k] = ($dStruct->_qNorm[$k]); } foreach($p['wp'] as $k => $v) { $w[$k] = ($dStruct->_qNorm[$k]); } $filePath = $p['filePath']; $filePath = str_replace("\\", "\\\\", $filePath); $fp = fopen($filePath, "rb+"); // delete old checksum at offset 0x0C - byte 12 fseek($fp, 12); // (I) unsigned integer (machine dependent size and byte order) fwrite($fp, pack('I', 0)); // produces 4 bytes // edit quests which are checked, to Just finished FE FF foreach ($q as $k => $v) { fseek($fp, $v); fwrite($fp, pack('C', 0xFE)); fseek($fp, $v+1); fwrite($fp, pack('C', 0xFF)); } if ($p['wp_all'] == "1") { fseek($fp, 643); fwrite($fp, pack('C', 0xFF)); fseek($fp, 644); fwrite($fp, pack('C', 0xFF)); fseek($fp, 645); fwrite($fp, pack('C', 0xFF)); fseek($fp, 646); fwrite($fp, pack('C', 0xFF)); fseek($fp, 647); fwrite($fp, pack('C', 0x7F)); fseek($fp, 667); fwrite($fp, pack('C', 0xFF)); fseek($fp, 668); fwrite($fp, pack('C', 0xFF)); fseek($fp, 669); fwrite($fp, pack('C', 0xFF)); fseek($fp, 670); fwrite($fp, pack('C', 0xFF)); fseek($fp, 671); fwrite($fp, pack('C', 0x7F)); fseek($fp, 691); fwrite($fp, pack('C', 0xFF)); fseek($fp, 692); fwrite($fp, pack('C', 0xFF)); fseek($fp, 693); fwrite($fp, pack('C', 0xFF)); fseek($fp, 694); fwrite($fp, pack('C', 0xFF)); fseek($fp, 695); fwrite($fp, pack('C', 0x7F)); } else if ($p['wp_all'] == "0") { fseek($fp, 643); fwrite($fp, pack('C', 0x00)); fseek($fp, 644); fwrite($fp, pack('C', 0x00)); fseek($fp, 645); fwrite($fp, pack('C', 0x00)); fseek($fp, 646); fwrite($fp, pack('C', 0x00)); fseek($fp, 647); fwrite($fp, pack('C', 0x00)); fseek($fp, 667); fwrite($fp, pack('C', 0x00)); fseek($fp, 668); fwrite($fp, pack('C', 0x00)); fseek($fp, 669); fwrite($fp, pack('C', 0x00)); fseek($fp, 670); fwrite($fp, pack('C', 0x00)); fseek($fp, 671); fwrite($fp, pack('C', 0x00)); fseek($fp, 691); fwrite($fp, pack('C', 0x00)); fseek($fp, 692); fwrite($fp, pack('C', 0x00)); fseek($fp, 693); fwrite($fp, pack('C', 0x00)); fseek($fp, 694); fwrite($fp, pack('C', 0x00)); fseek($fp, 695); fwrite($fp, pack('C', 0x00)); } $checksum = (shell_exec("bin\d2scs.exe \"$filePath\"")); // write NEW checksum at offset 0x0C - byte 12 fseek($fp, 12); // (I) unsigned integer (machine dependent size and byte order) fwrite($fp, pack('H*', $checksum)); // produces 4 bytes fclose($fp); header('Location: /');