From f93b99883039588480d25f1baac74173229bed49 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 5 Oct 2022 18:49:01 +0200 Subject: [PATCH] Hook OSDynLoad_Release to supress a warning whencalled with an aroma module handle --- source/dynload/dynload_function_replacements.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/dynload/dynload_function_replacements.cpp b/source/dynload/dynload_function_replacements.cpp index 73df0b4..f38bb72 100644 --- a/source/dynload/dynload_function_replacements.cpp +++ b/source/dynload/dynload_function_replacements.cpp @@ -6,6 +6,18 @@ #include #include +DECL_FUNCTION(void, OSDynLoad_Release, OSDynLoad_Module module) { + if (((uint32_t) module & MODULE_MAGIC_MASK) == MODULE_MAGIC) { + uint32_t moduleHandle = ((uint32_t) module) & MODULE_ID_MASK; + if (moduleHandle >= gModuleData->number_modules) { + DEBUG_FUNCTION_LINE_WARN("Invalid module handle was encoded in OSDynLoad_Module %d (%08X)", moduleHandle, module); + } else { + return; + } + } + real_OSDynLoad_Release(module); +} + DECL_FUNCTION(OSDynLoad_Error, OSDynLoad_Acquire, char const *name, OSDynLoad_Module *outModule) { DEBUG_FUNCTION_LINE_VERBOSE("Looking for module %s", name); for (uint32_t i = 0; i < gModuleData->number_modules; i++) { @@ -146,6 +158,7 @@ function_replacement_data_t dynload_function_replacements[] = { REPLACE_FUNCTION_VIA_ADDRESS(LiFixupRelocOneRPL, 0x320059f0, 0x010059f0), REPLACE_FUNCTION(OSDynLoad_Acquire, LIBRARY_COREINIT, OSDynLoad_Acquire), REPLACE_FUNCTION(OSDynLoad_FindExport, LIBRARY_COREINIT, OSDynLoad_FindExport), + REPLACE_FUNCTION(OSDynLoad_Release, LIBRARY_COREINIT, OSDynLoad_Release), }; uint32_t dynload_function_replacements_size = sizeof(dynload_function_replacements) / sizeof(function_replacement_data_t); \ No newline at end of file