Skip to content

Commit

Permalink
Reset the cached function handle if RPL has been unloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Maschell committed Jan 2, 2023
1 parent e51e6a9 commit ac0c341
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions source/FunctionAddressProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,12 @@ function_replacement_library_type_t FunctionAddressProvider::getTypeForHandle(OS
return LIBRARY_OTHER;
}

bool FunctionAddressProvider::resetHandle(OSDynLoad_Module handle) {
for (auto &rplHandle : rpl_handles) {
if (rplHandle.handle == handle) {
rplHandle.handle = nullptr;
return true;
}
}
return false;
}
2 changes: 2 additions & 0 deletions source/FunctionAddressProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class FunctionAddressProvider {

function_replacement_library_type_t getTypeForHandle(OSDynLoad_Module toReset);

bool resetHandle(OSDynLoad_Module handle);

std::list<rpl_handling> rpl_handles = {
{LIBRARY_AVM, "avm.rpl", nullptr},
{LIBRARY_CAMERA, "camera.rpl", nullptr},
Expand Down
1 change: 1 addition & 0 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ void notify_callback(OSDynLoad_Module module,
}
}
}
gFunctionAddressProvider->resetHandle(module);
CheckIfPatchedFunctionsAreStillInMemory();
}
}
Expand Down

0 comments on commit ac0c341

Please sign in to comment.