2020-06-01 16:35:34 +02:00
|
|
|
#include "../../source/common/module_defines.h"
|
|
|
|
#include <wums.h>
|
|
|
|
#include "hooks.h"
|
|
|
|
#include "utils/logger.h"
|
|
|
|
|
|
|
|
static const char **hook_names = (const char *[]) {
|
|
|
|
"WUMS_HOOK_INIT",
|
|
|
|
"WUMS_HOOK_APPLICATION_STARTS",
|
|
|
|
"WUMS_HOOK_APPLICATION_ENDS",
|
|
|
|
"WUMS_HOOK_INIT_WUT",
|
|
|
|
"WUMS_HOOK_FINI_WUT"};
|
|
|
|
|
|
|
|
void CallHook(const std::vector<ModuleData> &modules, wums_hook_type_t type) {
|
|
|
|
DEBUG_FUNCTION_LINE("Calling hook of type %s [%d]", hook_names[type], type);
|
|
|
|
for (auto &curModule: modules) {
|
|
|
|
for (auto &curHook : curModule.getHookDataList()) {
|
2020-06-03 19:36:16 +02:00
|
|
|
if ((type == WUMS_HOOK_INIT ||
|
|
|
|
type == WUMS_HOOK_APPLICATION_STARTS ||
|
|
|
|
type == WUMS_HOOK_APPLICATION_ENDS ||
|
|
|
|
type == WUMS_HOOK_INIT_WUT ||
|
|
|
|
type == WUMS_HOOK_FINI_WUT) && curHook.getType() == type) {
|
2020-06-01 16:35:34 +02:00
|
|
|
uint32_t func_ptr = (uint32_t) curHook.getTarget();
|
2020-06-01 16:41:46 +02:00
|
|
|
if (func_ptr == 0) {
|
2020-06-01 16:35:34 +02:00
|
|
|
DEBUG_FUNCTION_LINE("Hook ptr was NULL\n");
|
|
|
|
} else {
|
|
|
|
DEBUG_FUNCTION_LINE("Calling for module [%s]\n", curModule.getExportName().c_str());
|
|
|
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|