From c3e7fe0f5115887c29431aedcaffe9521dbf2407 Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 10 Jun 2020 16:20:20 +0200 Subject: [PATCH] Add support for the WUMS_HOOK_RELOCATIONS_DONE hook --- relocator/src/entry.cpp | 2 ++ relocator/src/hooks.cpp | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/relocator/src/entry.cpp b/relocator/src/entry.cpp index e434bcc..d3f9a72 100644 --- a/relocator/src/entry.cpp +++ b/relocator/src/entry.cpp @@ -130,6 +130,7 @@ extern "C" void doStart(int argc, char **argv) { } } + CallHook(loadedModules, WUMS_HOOK_RELOCATIONS_DONE); for (int i = 0; i < gModuleData->number_used_modules; i++) { DEBUG_FUNCTION_LINE("About to call %08X\n", gModuleData->module_data[i].entrypoint); @@ -145,6 +146,7 @@ extern "C" void doStart(int argc, char **argv) { } else { DEBUG_FUNCTION_LINE("Resolve relocations and replace alloc functions\n"); ResolveRelocations(loadedModules); + CallHook(loadedModules, WUMS_HOOK_RELOCATIONS_DONE); } // CallHook(loadedModules, WUMS_HOOK_FINI_WUT); diff --git a/relocator/src/hooks.cpp b/relocator/src/hooks.cpp index 82f8262..6883660 100644 --- a/relocator/src/hooks.cpp +++ b/relocator/src/hooks.cpp @@ -8,7 +8,8 @@ static const char **hook_names = (const char *[]) { "WUMS_HOOK_APPLICATION_STARTS", "WUMS_HOOK_APPLICATION_ENDS", "WUMS_HOOK_INIT_WUT", - "WUMS_HOOK_FINI_WUT"}; + "WUMS_HOOK_FINI_WUT", + "WUMS_HOOK_RELOCATIONS_DONE"}; void CallHook(const std::vector &modules, wums_hook_type_t type) { DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] for all modules\n", hook_names[type], type); @@ -33,7 +34,9 @@ void CallHook(const ModuleData &module, wums_hook_type_t type) { type == WUMS_HOOK_FINI_WUT)) { DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s \n", hook_names[type], type, curHook.getType(), module.getExportName().c_str()); ((void (*)(void)) ((uint32_t *) func_ptr))(); - } else if (type == WUMS_HOOK_INIT) { + break; + } else if (type == WUMS_HOOK_INIT || + type == WUMS_HOOK_RELOCATIONS_DONE) { DEBUG_FUNCTION_LINE("Calling hook of type %s [%d] %d for %s\n", hook_names[type], type, curHook.getType(), module.getExportName().c_str(), gModuleData); wums_app_init_args_t args; args.module_information = gModuleData;