Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- REM A script I made to patch LOTRC for certain mods.
- @echo off
- color 0a
- setlocal
- ::Define your input for patching
- set "EXE_FILE=Conquest.exe"
- set "OFFSET=0x49F238"
- set "NEW_HEX=C7 05 00 E2 A3 00 00 00 00 10" ::C7 05 00 E2 A3 00 00 00 A0 0A
- ::Create backup of file being patched
- set "TIMESTAMP=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%_%TIME:~0,2%%TIME:~3,2%%TIME:~6,2%"
- set "TIMESTAMP=%TIMESTAMP: =0%" :: Replace space with 0 for time formatting
- set "BACKUP_FILE=%EXE_FILE%.backup.%TIMESTAMP%"
- ::Catch error
- echo Creating backup: %BACKUP_FILE%
- copy /Y "%EXE_FILE%" "%BACKUP_FILE%" > nul
- if errorlevel 1 (
- echo Failed to create backup. Aborting patch.
- exit /b 1
- )
- ::Find offset and replace hex values
- powershell -NoProfile -ExecutionPolicy Bypass -Command ^
- "$Path='%EXE_FILE%';" ^
- "$Offset=%OFFSET%;" ^
- "$Bytes='%NEW_HEX%'.Split(' ') | ForEach-Object { [Convert]::ToByte($_,16) };" ^
- "$fs=[System.IO.File]::Open($Path, 'Open', 'ReadWrite');" ^
- "$fs.Seek($Offset, 'Begin') > $null;" ^
- "$fs.Write($Bytes, 0, $Bytes.Length);" ^
- "$fs.Close();"
- echo.
- echo Patch has been applied successfully! You may now close this window or press any key.
- pause > nul
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement