Last active
March 31, 2025 19:05
-
-
Save fade2gray/c0f19c6aae5888512d2ad42dca53da35 to your computer and use it in GitHub Desktop.
Patch Cheat Engine files for compatability with Lazarus versions > 2.2.6 (e.g 3.8)
This file contains hidden or 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
@echo off | |
setlocal enabledelayedexpansion | |
:: Define the files to modify | |
set "file1=cesupport.pas" | |
set "file2=frmSaveSnapshotsUnit.pas" | |
set "file3=LuaHandler.pas" | |
set "file4=luavirtualstringtree.pas" | |
:: Define search and replace strings | |
set "search1=ExtCtrls, Graphics, FileUtil, Dialogs, math;" | |
set "replace1=ExtCtrls, Graphics, LazFileUtils, Dialogs, math;" | |
set "search2=Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls," | |
set "replace2=Classes, SysUtils, FileUtil, LazFileUtils, Forms, Controls, Graphics, Dialogs, StdCtrls," | |
set "search3=xinput, winsapi, frmExeTrainerGeneratorUnit, CustomBase85, FileUtil, networkConfig," | |
set "replace3=xinput, winsapi, frmExeTrainerGeneratorUnit, CustomBase85, FileUtil, LazFileUtils, networkConfig," | |
set "search4=luaclass_register(TVirtualStringTree, virtualstringtree_addMetaData);" | |
set "replace4=luaclass_register(TLazVirtualStringTree, virtualstringtree_addMetaData);" | |
:: Process each file | |
set /A "index = 1" | |
set /A "count = 4" | |
:while | |
if %index% leq %count% ( | |
set "file=!file%index%!" | |
set "search=!search%index%!" | |
set "replace=!replace%index%!" | |
echo Processing !file! ... | |
:: Create a backup | |
copy /y "!file!" "!file!.bak" | |
:: Run PowerShell search and replace while preserving original line endings | |
powershell -NoProfile -ExecutionPolicy Bypass -Command ^ | |
"$file='!file!'; " ^ | |
"$search='!search!'; $replace='!replace!'; " ^ | |
"$content = (Get-Content $file -Raw); " ^ | |
"$content = $content -replace [regex]::Escape($search), $replace; " ^ | |
"[System.IO.File]::WriteAllText($file, $content, (New-Object System.Text.UTF8Encoding($false)))" | |
set /A "index = index + 1" | |
goto :while | |
) | |
echo Done! | |
pause | |
exit /b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just drop into the Cheat Engine source folder and double click.
Kudos to @VagnerSilver cheat-engine/cheat-engine#2642 (comment)
Note: Batch file created with AI assistance.