From 558b7fa0f013b94b3ab82a7447fe548e15ec9d98 Mon Sep 17 00:00:00 2001 From: Maschell Date: Mon, 4 May 2026 18:58:22 +0200 Subject: [PATCH] Make sure to re-patch function when restoring nested function patches --- source/export.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/export.cpp b/source/export.cpp index f3c148b..c079bec 100644 --- a/source/export.cpp +++ b/source/export.cpp @@ -95,7 +95,8 @@ FunctionPatcherStatus FPRemoveFunctionPatch(PatchedFunctionHandle handle) { return FUNCTION_PATCHER_RESULT_PATCH_NOT_FOUND; } - if (toBeRemoved->isPatched) { + bool functionWasPatched = toBeRemoved->isPatched; + if (functionWasPatched) { // Restore function patches that were done after the patch we actually want to restore. for (auto &cur : std::ranges::reverse_view(toBeTempRestored)) { RestoreFunction(cur); @@ -107,7 +108,7 @@ FunctionPatcherStatus FPRemoveFunctionPatch(PatchedFunctionHandle handle) { gPatchedFunctions.erase(gPatchedFunctions.begin() + erasePosition); - if (toBeRemoved->isPatched) { + if (functionWasPatched) { // Apply the other patches again for (auto &cur : toBeTempRestored) { PatchFunction(cur);