mirror of
https://github.com/wiiu-env/FunctionPatcherModule.git
synced 2025-01-08 08:00:46 +01:00
Only try to restore a function if it's actually patched
This commit is contained in:
parent
5adf6c3688
commit
ecc109af50
@ -60,6 +60,10 @@ FunctionPatcherStatus FPRemoveFunctionPatch(PatchedFunctionHandle handle) {
|
|||||||
if (cur->getHandle() == handle) {
|
if (cur->getHandle() == handle) {
|
||||||
toRemoved = cur;
|
toRemoved = cur;
|
||||||
found = true;
|
found = true;
|
||||||
|
if (!cur->isPatched) {
|
||||||
|
// Early return if the function is not patched.
|
||||||
|
break;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Check if something else patched the same function afterwards.
|
// Check if something else patched the same function afterwards.
|
||||||
@ -76,19 +80,23 @@ FunctionPatcherStatus FPRemoveFunctionPatch(PatchedFunctionHandle handle) {
|
|||||||
return FUNCTION_PATCHER_RESULT_PATCH_NOT_FOUND;
|
return FUNCTION_PATCHER_RESULT_PATCH_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore function patches that were done after the patch we actually want to restore.
|
if (toRemoved->isPatched) {
|
||||||
for (auto &cur : std::ranges::reverse_view(toBeTempRestored)) {
|
// Restore function patches that were done after the patch we actually want to restore.
|
||||||
RestoreFunction(cur);
|
for (auto &cur : std::ranges::reverse_view(toBeTempRestored)) {
|
||||||
}
|
RestoreFunction(cur);
|
||||||
|
}
|
||||||
|
|
||||||
// Restore the function we actually want to restore
|
// Restore the function we actually want to restore
|
||||||
RestoreFunction(toRemoved);
|
RestoreFunction(toRemoved);
|
||||||
|
}
|
||||||
|
|
||||||
gPatchedFunctions.erase(gPatchedFunctions.begin() + erasePosition);
|
gPatchedFunctions.erase(gPatchedFunctions.begin() + erasePosition);
|
||||||
|
|
||||||
// Apply the other patches again
|
if (toRemoved->isPatched) {
|
||||||
for (auto &cur : toBeTempRestored) {
|
// Apply the other patches again
|
||||||
PatchFunction(cur);
|
for (auto &cur : toBeTempRestored) {
|
||||||
|
PatchFunction(cur);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OSMemoryBarrier();
|
OSMemoryBarrier();
|
||||||
|
Loading…
Reference in New Issue
Block a user