Skip to content

Instantly share code, notes, and snippets.

@z2z
Last active July 11, 2019 08:58
Show Gist options
  • Save z2z/9e1e3d48f6ec16cef9ce716a24a74aef to your computer and use it in GitHub Desktop.
Save z2z/9e1e3d48f6ec16cef9ce716a24a74aef to your computer and use it in GitHub Desktop.
WINGINX patch to support php 5.6 and 7.0
<?php
/*
src - https://stackoverflow.com/a/36291595
usage - php winginx_patch.php
After applying this patch you can use "php56", "php70" and "php71"
folders in the root directory of winginx.
*/
function patch($file, $offset, $old_data, $new_data) {
if (!$f = fopen($file, 'r+b')) {
die("Can not open $file");
}
fseek($f, $offset);
$c = fread($f, strlen($old_data));
if ($c == $old_data) {
fseek($f, $offset);
fwrite($f, $new_data, strlen($new_data));
echo "$file patched successfully\n";
} else if ($c != $new_data) {
die("$file can not be patched\n");
}
fclose($f);
}
patch('winginx.exe', 0x0A6254, 2, 6); // 5.2 -> 5.6
patch('winginx.exe', 0x0A6258, 5, 7);
patch('winginx.exe', 0x0A625C, 3, 0); // 5.3 -> 7.0
patch('winginx.exe', 0x0A6260, 5, 7);
patch('winginx.exe', 0x0A6264, 4, 1); // 5.4 -> 7.1
patch('winginx.exe', 0x0AD2DC, 2, 6); // 5.2 -> 5.6
patch('winginx.exe', 0x0AD2EA, 5, 7);
patch('winginx.exe', 0x0AD2EC, 3, 0); // 5.3 -> 7.0
patch('winginx.exe', 0x0AD2FA, 5, 7);
patch('winginx.exe', 0x0AD2FC, 4, 1); // 5.4 -> 7.1
patch('php-config.exe', 0x014FCE, 2, 6); // 5.2 -> 5.6
patch('php-config.exe', 0x014FDC, 5, 7);
patch('php-config.exe', 0x014FDE, 3, 0); // 5.3 -> 7.0
patch('php-config.exe', 0x014FEC, 5, 7);
patch('php-config.exe', 0x014FEE, 4, 1); // 5.4 -> 7.1
echo "Done\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment