mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-22 12:49:17 +01:00
Add support for new CRT hook, increase the maximum hooks per plugin to 25
This commit is contained in:
parent
7d7a668210
commit
8cd0367514
@ -80,6 +80,8 @@ void ApplyPatchesAndCallHookStartingApp() {
|
||||
PatchInvidualMethodHooks(method_hooks_hooks_static, method_hooks_size_hooks_static, method_calls_hooks_static);
|
||||
PatchInvidualMethodHooks(method_hooks_hooks, method_hooks_size_hooks, method_calls_hooks);
|
||||
for(int32_t plugin_index=0; plugin_index<gbl_replacement_data.number_used_plugins; plugin_index++) {
|
||||
|
||||
CallHookEx(WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB,plugin_index);
|
||||
CallHookEx(WUPS_LOADER_HOOK_APPLICATION_START,plugin_index);
|
||||
new_PatchInvidualMethodHooks(&gbl_replacement_data.plugin_data[plugin_index]);
|
||||
CallHookEx(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,plugin_index);
|
||||
@ -99,6 +101,11 @@ void RestoreEverything() {
|
||||
CallHook(WUPS_LOADER_HOOK_APPLICATION_END);
|
||||
CallHook(WUPS_LOADER_HOOK_DEINIT_PLUGIN);
|
||||
|
||||
CallHook(WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB);
|
||||
CallHook(WUPS_LOADER_HOOK_FINI_WUT_STDCPP);
|
||||
CallHook(WUPS_LOADER_HOOK_FINI_WUT_NEWLIB);
|
||||
CallHook(WUPS_LOADER_HOOK_FINI_WUT_MALLOC);
|
||||
|
||||
// Restore patches as the patched functions could change.
|
||||
RestorePatches();
|
||||
DynamicLinkingHelper::getInstance()->clearAll();
|
||||
@ -118,9 +125,12 @@ void ResolveRelocations() {
|
||||
void afterLoadAndLink() {
|
||||
ResolveRelocations();
|
||||
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_WUT_MALLOC);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_WUT_NEWLIB);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_WUT_STDCPP);
|
||||
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_VID_MEM);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_KERNEL);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_FS);
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_OVERLAY);
|
||||
ConfigUtils::loadConfigFromSD();
|
||||
CallHook(WUPS_LOADER_HOOK_INIT_PLUGIN);
|
||||
|
@ -58,7 +58,7 @@ struct replacement_data_hook_t {
|
||||
wups_loader_hook_type_t type; /* [will be filled] */
|
||||
};
|
||||
|
||||
#define MAXIMUM_HOOKS_PER_PLUGIN 10
|
||||
#define MAXIMUM_HOOKS_PER_PLUGIN 25
|
||||
#define MAXIMUM_FUNCTION_PER_PLUGIN 100
|
||||
|
||||
struct replacement_data_plugin_t {
|
||||
|
@ -314,6 +314,7 @@ DECL(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *message, uint
|
||||
if(flags == 0x15154848) {
|
||||
CallHook(WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND);
|
||||
CallHook(WUPS_LOADER_HOOK_APPLICATION_END);
|
||||
CallHook(WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB);
|
||||
gInBackground = false;
|
||||
DCFlushRange(&gInBackground,4);
|
||||
return false;
|
||||
@ -326,6 +327,7 @@ DECL(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *message, uint
|
||||
CallHook(WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND);
|
||||
} else if(message->data0 == 0xD1E0D1E0) {
|
||||
CallHook(WUPS_LOADER_HOOK_APPLICATION_END);
|
||||
CallHook(WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB);
|
||||
gInBackground = false;
|
||||
DCFlushRange(&gInBackground,4);
|
||||
unmount_sd_fat("sd");
|
||||
|
@ -36,10 +36,17 @@ bool HasHookCallHook(wups_loader_hook_type_t hook_type) {
|
||||
}
|
||||
|
||||
static const char** hook_names = (const char *[]){
|
||||
"WUPS_LOADER_HOOK_INIT_FS",
|
||||
"WUPS_LOADER_HOOK_INIT_OVERLAY",
|
||||
"WUPS_LOADER_HOOK_INIT_KERNEL",
|
||||
"WUPS_LOADER_HOOK_INIT_VID_MEM",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_MALLOC",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_MALLOC",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_NEWLIB",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_NEWLIB",
|
||||
"WUPS_LOADER_HOOK_INIT_WUT_STDCPP",
|
||||
"WUPS_LOADER_HOOK_FINI_WUT_STDCPP",
|
||||
"WUPS_LOADER_HOOK_INIT_PLUGIN",
|
||||
"WUPS_LOADER_HOOK_DEINIT_PLUGIN",
|
||||
"WUPS_LOADER_HOOK_APPLICATION_START",
|
||||
@ -73,22 +80,7 @@ void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed)
|
||||
// Adding arguments!
|
||||
if(func_ptr != NULL) {
|
||||
//DEBUG_FUNCTION_LINE("function pointer is %08x\n",func_ptr);
|
||||
if(hook_type == WUPS_LOADER_HOOK_INIT_FS) {
|
||||
wups_loader_init_fs_args_t args;
|
||||
// open is defined as "extern int open (const char *, int, ...);", we are ignoring the varargs part
|
||||
args.open_repl = (OpenFunction) &open;
|
||||
args.close_repl = &close;
|
||||
args.write_repl = &write;
|
||||
args.read_repl = &read;
|
||||
args.lseek_repl = &lseek;
|
||||
args.stat_repl = &stat;
|
||||
args.fstat_repl = &fstat;
|
||||
args.opendir_repl = &opendir;
|
||||
args.closedir_repl = &closedir;
|
||||
args.readdir_repl = &readdir;
|
||||
args.mkdir_repl = &mkdir;
|
||||
((void (*)(wups_loader_init_fs_args_t))((uint32_t*)func_ptr) )(args);
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_OVERLAY) {
|
||||
if(hook_type == WUPS_LOADER_HOOK_INIT_OVERLAY) {
|
||||
/*wups_loader_init_overlay_args_t args;
|
||||
args.overlayfunction_ptr = &overlay_helper;
|
||||
args.textureconvertfunction_ptr = &TextureUtils::convertImageToTexture;
|
||||
@ -101,12 +93,6 @@ void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed)
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_APPLICATION_START) {
|
||||
wups_loader_app_started_args_t args;
|
||||
memset(&args,0,sizeof(args));
|
||||
///*if(gSDInitDone & WUPS_SD_MOUNTED) {
|
||||
args.sd_mounted = true;
|
||||
//}
|
||||
/*if(gSDInitDone & WUPS_USB_MOUNTED) {
|
||||
args.usb_mounted = true;
|
||||
}*/
|
||||
if(plugin_data->kernel_allowed && plugin_data->kernel_init_done) {
|
||||
args.kernel_access = true;
|
||||
}
|
||||
@ -123,6 +109,22 @@ void CallHookEx(wups_loader_hook_type_t hook_type, int32_t plugin_index_needed)
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_APPLET_START) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_WUT_MALLOC) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_FINI_WUT_MALLOC) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_WUT_NEWLIB) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_FINI_WUT_NEWLIB) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_WUT_STDCPP) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_FINI_WUT_STDCPP) {
|
||||
((void (*)(void))((uint32_t*)func_ptr))();
|
||||
} else if(hook_type == WUPS_LOADER_HOOK_INIT_KERNEL) {
|
||||
// Only call the hook if kernel is allowed.
|
||||
if(plugin_data->kernel_allowed) {
|
||||
|
Loading…
Reference in New Issue
Block a user