-
-
Save ivan-ristovic/4439611489cd6120199be68ef2093fbc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Output "--- m4d.dll patch by Linu (because badtime sucks lel) ---" | |
function Wait-Key | |
{ | |
Write-Host -NoNewLine 'Press any key to continue...'; | |
$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown'); | |
} | |
Write-Output "Starting..." | |
# Are we in the correct directory? | |
$m4d_exists = [System.IO.File]::Exists("m4d.dll"); | |
if ( ! $m4d_exists ) | |
{ | |
Write-Error "m4d.dll not found. Are you sure that you are in Swat4 Content/System directory?" | |
Wait-Key | |
exit 1 | |
} | |
# Copy m4d.dll to a backup file | |
[System.IO.File]::Copy("m4d.dll", "m4d.dll.bak"); | |
Write-Output "Saved m4d.dll to m4d.dll.bak" | |
# Read the bytes from the original m4d.dll | |
$bytes = [System.IO.File]::ReadAllBytes("m4d.dll"); | |
# Edit "madserver.net" to "localhost" | |
$bytes[0x3c340] = 0x6c; # 'l' | |
$bytes[0x3c341] = 0x6f; # 'o' | |
$bytes[0x3c342] = 0x63; # 'c' | |
$bytes[0x3c343] = 0x61; # 'a' | |
$bytes[0x3c344] = 0x6c; # 'l' | |
$bytes[0x3c345] = 0x68; # 'h' | |
$bytes[0x3c346] = 0x6f; # 'o' | |
$bytes[0x3c347] = 0x73; # 's' | |
$bytes[0x3c348] = 0x74; # 't' | |
$bytes[0x3c349] = 0x00; # NUL padding to overwrite madserver.net string | |
$bytes[0x3c34a] = 0x00; | |
$bytes[0x3c34b] = 0x00; | |
$bytes[0x3c34c] = 0x00; | |
$bytes[0x3c34d] = 0x00; | |
$bytes[0x3c34e] = 0x00; | |
$bytes[0x3c34f] = 0x00; | |
# Rewrite to m4d.dll | |
[System.IO.File]::WriteAllBytes("m4d.dll", $bytes); | |
Write-Output "Patched successfully!" | |
Wait-Key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment