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