From e01f25b49a8458aa0d94250b0a8b942c7c4542c3 Mon Sep 17 00:00:00 2001 From: Indra Date: Thu, 18 Apr 2024 20:40:55 +0200 Subject: [PATCH] Add heap size patch --- src/modules/Patches.cpp | 14 ++++++++++++++ src/modules/Patches.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/modules/Patches.cpp b/src/modules/Patches.cpp index 908a0f8..776430c 100644 --- a/src/modules/Patches.cpp +++ b/src/modules/Patches.cpp @@ -94,6 +94,11 @@ Patches::Patches() MH_CreateHook((void*)GET_ADDRESS(0x4642F0, 0x467E60, 0x000000), MakePeHandle, nullptr); #endif + if (m_heapSize.GetValue() > 0) + { + PatchHeapSize(); + } + // Insert DeathState hooks MH_CreateHook((void*)GET_ADDRESS(0x55DEC0, 0x5581D0, 0x75AA50), DeathState_Entry, (void**)&s_DeathState_Entry); MH_CreateHook((void*)GET_ADDRESS(0x56EC70, 0x5699C0, 0x75AF90), DeathState_Process, (void**)&s_DeathState_Process); @@ -117,6 +122,15 @@ void Patches::RemoveIntro() const noexcept Hooking::Patch(match.get_first(2), mainState); } +void Patches::PatchHeapSize() const noexcept +{ + auto match = hook::pattern("68 00 00 00 10 6A 00 C7 06").count(1); + auto size = m_heapSize.GetValue(); + + Hooking::Patch(match.get_first(1), size); + Hooking::Patch(match.get_first(19), size); +} + void Patches::OnInput(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { // Remove the quit message diff --git a/src/modules/Patches.h b/src/modules/Patches.h index 7b547ce..a4c561a 100644 --- a/src/modules/Patches.h +++ b/src/modules/Patches.h @@ -10,7 +10,10 @@ class Patches : public Module Option m_noCinematicBars{ "NoCinematicBars", true }; Option m_noMotionBlur{ "NoMotionBlur", false }; + Option m_heapSize{ "HeapSize", 0 }; + void RemoveIntro() const noexcept; + void PatchHeapSize() const noexcept; public: Patches();