Use latest version of libfunctionpatcher

This commit is contained in:
Maschell
2023-01-06 14:59:45 +01:00
parent 77360e935d
commit d3f874ed2e
4 changed files with 26 additions and 8 deletions

View File

@ -0,0 +1,4 @@
:NAME homebrew_functionpatcher
:TEXT
FPAddFunctionPatch

View File

@ -14,6 +14,9 @@ WUMS_MODULE_EXPORT_NAME("homebrew_memorymapping");
WUMS_MODULE_SKIP_INIT_FINI();
WUMS_MODULE_INIT_BEFORE_RELOCATION_DONE_HOOK();
// We can't use the functions from libfunctionpatcher. Defined in functionpatcher.def
extern "C" FunctionPatcherStatus FPAddFunctionPatch(function_replacement_data_t *function_data, PatchedFunctionHandle *outHandle, bool *outHasBeenPatched);
WUMS_INITIALIZE(args) {
static uint8_t ucSetupRequired = 1;
if (!ucSetupRequired) {
@ -24,14 +27,20 @@ WUMS_INITIALIZE(args) {
MemoryMapping_setupMemoryMapping();
MemoryMapping_CreateHeaps();
/* We can not use FunctionPatcher_InitLibrary here because OSDynLoadAcquire is not patched yet.
if (FunctionPatcher_InitLibrary() != FUNCTION_PATCHER_RESULT_SUCCESS) {
OSFatal("homebrew_memorymapping: FunctionPatcher_InitLibrary failed");
}*/
for (uint32_t i = 0; i < function_replacements_size; i++) {
if (!FunctionPatcherPatchFunction(&function_replacements[i], nullptr)) {
bool wasPatched = false;
// We don't need to save the handles because we never restore them anyway.
if (FPAddFunctionPatch(&function_replacements[i], nullptr, &wasPatched) != FUNCTION_PATCHER_RESULT_SUCCESS || !wasPatched) {
OSFatal("homebrew_memorymapping: Failed to patch function");
}
}
}
WUMS_APPLICATION_STARTS() {
OSReport("Running MemoryMappingModule " VERSION VERSION_EXTRA "\n");
#ifdef DEBUG