From 13701075d8f72a0fa804d0e9221d63ca28813dd6 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 18 Jul 2022 12:36:17 -0700 Subject: [PATCH] patch: implement exit crash fix --- lib/dllmain.cpp | 7 +++++++ src/patchgrid.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/lib/dllmain.cpp b/lib/dllmain.cpp index 6bbcb48..d0a2946 100644 --- a/lib/dllmain.cpp +++ b/lib/dllmain.cpp @@ -76,6 +76,13 @@ __declspec(dllexport) DWORD WINAPI Patch() SearchReplacePattern(dllBase, dbg_map_pattern, dbg_map_replace, 48, TRUE); } + // Exit crash fix + if (config.GetInt(_T("ExitCrashFix"))) { + const char *exit_pattern = "\x50\x52\x51\x8B\x01\xFF\x50\x2C\x85\xC0\x75\x67\x8B\x7C\x24\x14\x8B\x74\x24\x30\x8B\xCB\xC1\xE9\x02\xF3\xA5\x8B\xCB\x83\xE1\x03\xF3\xA4\x8B\x55\x60"; + const char *exit_replace = "\x53\x52\x51\x8B\x01\xFF\x50\x2C\x85\xC0\x75\x67\x8B\x7C\x24\x14\x8B\x74\x24\x30\x8B\x55\x60\x3B\xD3\x7C\x04\x8B\xCB\xEB\x02\x8B\xCA\x90\x90\xF3\xA4"; + SearchReplacePattern(dllBase, exit_pattern, exit_replace, 37, TRUE); + } + // Disable auto-finish in build sections if (config.GetInt(_T("DisableAutoFinishBuilding"))) { // Pattern used in August build (jump is much shorter so it uses a different opcode) diff --git a/src/patchgrid.cpp b/src/patchgrid.cpp index bd6d290..7236311 100644 --- a/src/patchgrid.cpp +++ b/src/patchgrid.cpp @@ -79,6 +79,12 @@ PatchGrid::PatchGrid() "will not automatically finish the build section.", AddBoolItem(sectionGeneral, "Disable Auto-Finish Building Section", false)); + AddPatch("ExitCrashFix", + "LEGO Island contains a buffer overrun bug that frequently crashes the game when trying " + "to exit. This is particularly prevalent on newer versions of Windows and Wine. This " + "patch will fix the crash (though the audio glitches will remain).", + AddBoolItem(sectionGeneral, "Exit Crash Fix", false)); + // Controls section HSECTION sectionControls = AddSection("Controls");