mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-26 06:34:16 +01:00
Formatting of hooks.cpp, improving logs when a hook is not implemented
This commit is contained in:
parent
4f5de0f889
commit
7c0476fab4
146
source/hooks.cpp
146
source/hooks.cpp
@ -2,18 +2,17 @@
|
|||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
|
||||||
|
|
||||||
|
void CallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type) {
|
||||||
void CallHook(plugin_information_t * pluginInformation, wups_loader_hook_type_t hook_type) {
|
CallHookEx(pluginInformation, hook_type, -1);
|
||||||
CallHookEx(pluginInformation, hook_type,-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasHookCallHook(plugin_information_t * pluginInformation, wups_loader_hook_type_t hook_type) {
|
bool HasHookCallHook(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type) {
|
||||||
for(int32_t plugin_index=0; plugin_index<pluginInformation->number_used_plugins; plugin_index++) {
|
for (int32_t plugin_index = 0; plugin_index < pluginInformation->number_used_plugins; plugin_index++) {
|
||||||
plugin_information_single_t * plugin_data = &pluginInformation->plugin_data[plugin_index];
|
plugin_information_single_t *plugin_data = &pluginInformation->plugin_data[plugin_index];
|
||||||
|
|
||||||
for(uint32_t j=0; j<plugin_data->info.number_used_hooks; j++) {
|
for (uint32_t j = 0; j < plugin_data->info.number_used_hooks; j++) {
|
||||||
replacement_data_hook_t * hook_data = &plugin_data->info.hooks[j];
|
replacement_data_hook_t *hook_data = &plugin_data->info.hooks[j];
|
||||||
if(hook_data->type == hook_type) {
|
if (hook_data->type == hook_type) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,78 +20,79 @@ bool HasHookCallHook(plugin_information_t * pluginInformation, wups_loader_hook_
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char** hook_names = (const char *[]){
|
static const char **hook_names = (const char *[]) {
|
||||||
"WUPS_LOADER_HOOK_INIT_OVERLAY",
|
"WUPS_LOADER_HOOK_INIT_OVERLAY",
|
||||||
"WUPS_LOADER_HOOK_INIT_KERNEL",
|
"WUPS_LOADER_HOOK_INIT_KERNEL",
|
||||||
"WUPS_LOADER_HOOK_INIT_VID_MEM",
|
"WUPS_LOADER_HOOK_INIT_VID_MEM",
|
||||||
"WUPS_LOADER_HOOK_INIT_WUT_MALLOC",
|
"WUPS_LOADER_HOOK_INIT_WUT_MALLOC",
|
||||||
"WUPS_LOADER_HOOK_FINI_WUT_MALLOC",
|
"WUPS_LOADER_HOOK_FINI_WUT_MALLOC",
|
||||||
"WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB",
|
"WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB",
|
||||||
"WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB",
|
"WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB",
|
||||||
"WUPS_LOADER_HOOK_INIT_WUT_NEWLIB",
|
"WUPS_LOADER_HOOK_INIT_WUT_NEWLIB",
|
||||||
"WUPS_LOADER_HOOK_FINI_WUT_NEWLIB",
|
"WUPS_LOADER_HOOK_FINI_WUT_NEWLIB",
|
||||||
"WUPS_LOADER_HOOK_INIT_WUT_STDCPP",
|
"WUPS_LOADER_HOOK_INIT_WUT_STDCPP",
|
||||||
"WUPS_LOADER_HOOK_FINI_WUT_STDCPP",
|
"WUPS_LOADER_HOOK_FINI_WUT_STDCPP",
|
||||||
"WUPS_LOADER_HOOK_INIT_PLUGIN",
|
"WUPS_LOADER_HOOK_INIT_PLUGIN",
|
||||||
"WUPS_LOADER_HOOK_DEINIT_PLUGIN",
|
"WUPS_LOADER_HOOK_DEINIT_PLUGIN",
|
||||||
"WUPS_LOADER_HOOK_APPLICATION_START",
|
"WUPS_LOADER_HOOK_APPLICATION_START",
|
||||||
"WUPS_LOADER_HOOK_FUNCTIONS_PATCHED",
|
"WUPS_LOADER_HOOK_FUNCTIONS_PATCHED",
|
||||||
"WUPS_LOADER_HOOK_RELEASE_FOREGROUND",
|
"WUPS_LOADER_HOOK_RELEASE_FOREGROUND",
|
||||||
"WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND",
|
"WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND",
|
||||||
"WUPS_LOADER_HOOK_APPLICATION_END",
|
"WUPS_LOADER_HOOK_APPLICATION_END",
|
||||||
"WUPS_LOADER_HOOK_CONFIRM_RELEASE_FOREGROUND",
|
"WUPS_LOADER_HOOK_CONFIRM_RELEASE_FOREGROUND",
|
||||||
"WUPS_LOADER_HOOK_SAVES_DONE_READY_TO_RELEASE",
|
"WUPS_LOADER_HOOK_SAVES_DONE_READY_TO_RELEASE",
|
||||||
"WUPS_LOADER_HOOK_VSYNC",
|
"WUPS_LOADER_HOOK_VSYNC",
|
||||||
"WUPS_LOADER_HOOK_GET_CONFIG",
|
"WUPS_LOADER_HOOK_GET_CONFIG",
|
||||||
"WUPS_LOADER_HOOK_VID_DRC_DRAW",
|
"WUPS_LOADER_HOOK_VID_DRC_DRAW",
|
||||||
"WUPS_LOADER_HOOK_VID_TV_DRAW",
|
"WUPS_LOADER_HOOK_VID_TV_DRAW",
|
||||||
"WUPS_LOADER_HOOK_APPLET_START"};
|
"WUPS_LOADER_HOOK_APPLET_START"};
|
||||||
|
|
||||||
void CallHookEx(plugin_information_t * pluginInformation, wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) {
|
void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) {
|
||||||
for(int32_t plugin_index=0; plugin_index<pluginInformation->number_used_plugins; plugin_index++) {
|
for (int32_t plugin_index = 0; plugin_index < pluginInformation->number_used_plugins; plugin_index++) {
|
||||||
plugin_information_single_t * plugin_data = &pluginInformation->plugin_data[plugin_index];
|
plugin_information_single_t *plugin_data = &pluginInformation->plugin_data[plugin_index];
|
||||||
if(plugin_index_needed != -1 && plugin_index_needed != plugin_index) {
|
if (plugin_index_needed != -1 && plugin_index_needed != plugin_index) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//DEBUG_FUNCTION_LINE("Checking hook functions for %s.\n",plugin_data->plugin_name);
|
//DEBUG_FUNCTION_LINE("Checking hook functions for %s.\n",plugin_data->plugin_name);
|
||||||
//DEBUG_FUNCTION_LINE("Found hooks: %d\n",plugin_data->number_used_hooks);
|
//DEBUG_FUNCTION_LINE("Found hooks: %d\n",plugin_data->number_used_hooks);
|
||||||
for(uint32_t j=0; j<plugin_data->info.number_used_hooks; j++) {
|
for (uint32_t j = 0; j < plugin_data->info.number_used_hooks; j++) {
|
||||||
replacement_data_hook_t * hook_data = &plugin_data->info.hooks[j];
|
replacement_data_hook_t *hook_data = &plugin_data->info.hooks[j];
|
||||||
if(hook_data->type == hook_type) {
|
if (hook_data->type == hook_type) {
|
||||||
DEBUG_FUNCTION_LINE("Calling hook of type %s for plugin %s",hook_names[hook_data->type],plugin_data->meta.name);
|
DEBUG_FUNCTION_LINE("Calling hook of type %s for plugin %s", hook_names[hook_data->type], plugin_data->meta.name);
|
||||||
void * func_ptr = hook_data->func_pointer;
|
void *func_ptr = hook_data->func_pointer;
|
||||||
if(func_ptr != NULL) {
|
if (func_ptr != NULL) {
|
||||||
//DEBUG_FUNCTION_LINE("function pointer is %08x\n",func_ptr);
|
//DEBUG_FUNCTION_LINE("function pointer is %08x\n",func_ptr);
|
||||||
if(hook_type == WUPS_LOADER_HOOK_INIT_PLUGIN) {
|
if (hook_type == WUPS_LOADER_HOOK_INIT_PLUGIN) {
|
||||||
((void (*)(void))((uint32_t*)func_ptr) )();
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN) {
|
} else if (hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN) {
|
||||||
((void (*)(void))((uint32_t*)func_ptr) )();
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_APPLICATION_START) {
|
} else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_START) {
|
||||||
wups_loader_app_started_args_t args;
|
wups_loader_app_started_args_t args;
|
||||||
((void (*)(wups_loader_app_started_args_t))((uint32_t*)func_ptr) )(args);
|
((void (*)(wups_loader_app_started_args_t)) ((uint32_t *) func_ptr))(args);
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_FUNCTIONS_PATCHED) {
|
} else if (hook_type == WUPS_LOADER_HOOK_FUNCTIONS_PATCHED) {
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_APPLICATION_END) {
|
} else if (hook_type == WUPS_LOADER_HOOK_APPLICATION_END) {
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
} if(hook_type == WUPS_LOADER_HOOK_INIT_WUT_MALLOC) {
|
}
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_MALLOC) {
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_FINI_WUT_MALLOC) {
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_MALLOC) {
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB) {
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB) {
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB) {
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB) {
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_WUT_NEWLIB) {
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_NEWLIB) {
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_FINI_WUT_NEWLIB) {
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_NEWLIB) {
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_WUT_STDCPP) {
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
} else if (hook_type == WUPS_LOADER_HOOK_INIT_WUT_STDCPP) {
|
||||||
} else if(hook_type == WUPS_LOADER_HOOK_FINI_WUT_STDCPP) {
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
((void (*)(void))((uint32_t*)func_ptr))();
|
} else if (hook_type == WUPS_LOADER_HOOK_FINI_WUT_STDCPP) {
|
||||||
}else{
|
((void (*)(void)) ((uint32_t *) func_ptr))();
|
||||||
DEBUG_FUNCTION_LINE("IMPLEMENT ME");
|
} else {
|
||||||
|
DEBUG_FUNCTION_LINE("Hook is not implemented %s", hook_names[hook_data->type]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG_FUNCTION_LINE("Failed to call hook. It was not defined\n");
|
DEBUG_FUNCTION_LINE("Failed to call hook. It was not defined\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user