Add support for the WUMS_HOOK_RELOCATIONS_DONE hook

This commit is contained in:
Maschell 2020-06-10 16:20:20 +02:00
parent 00a8f16314
commit c3e7fe0f51
2 changed files with 7 additions and 2 deletions

View File

@ -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);

View File

@ -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<ModuleData> &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;