Added "ON_FUNCTIONS_PATCHED" hook

This commit is contained in:
Maschell 2018-03-07 18:53:43 +01:00
parent bee832131a
commit fd5acd8932
5 changed files with 89007 additions and 11 deletions

View File

@ -82,7 +82,7 @@ extern "C" int Menu_Main(int argc, char **argv) {
DEBUG_FUNCTION_LINE("Wii U Plugin System Loader %s\n",APP_VERSION);
setup_os_exceptions();
//setup_os_exceptions();
Init();
@ -144,6 +144,7 @@ void ApplyPatchesAndCallHookStartingApp() {
for(int plugin_index=0; plugin_index<gbl_replacement_data.number_used_plugins; plugin_index++) {
CallHookEx(WUPS_LOADER_HOOK_STARTING_APPLICATION,plugin_index);
new_PatchInvidualMethodHooks(&gbl_replacement_data.plugin_data[plugin_index]);
CallHookEx(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,plugin_index);
}
}

View File

@ -59,7 +59,7 @@ void CallHookEx(wups_loader_hook_type_t hook_type, s32 plugin_index_needed) {
((void (*)(void))((unsigned int*)func_ptr) )();
} else if(hook_type == WUPS_LOADER_HOOK_DEINIT_PLUGIN) {
((void (*)(void))((unsigned int*)func_ptr) )();
} else if(hook_type == WUPS_LOADER_HOOK_STARTING_APPLICATION) {
} else if(hook_type == WUPS_LOADER_HOOK_STARTING_APPLICATION) {
wups_loader_app_started_args_t args;
memset(&args,0,sizeof(args));
if(gSDInitDone & WUPS_SD_MOUNTED) {
@ -69,6 +69,8 @@ void CallHookEx(wups_loader_hook_type_t hook_type, s32 plugin_index_needed) {
args.usb_mounted = true;
}
((void (*)(wups_loader_app_started_args_t))((unsigned int*)func_ptr) )(args);
} else if(hook_type == WUPS_LOADER_HOOK_FUNCTIONS_PATCHED) {
((void (*)(void))((unsigned int*)func_ptr))();
} else if(hook_type == WUPS_LOADER_HOOK_ENDING_APPLICATION) {
((void (*)(void))((unsigned int*)func_ptr))();
} else if(hook_type == WUPS_LOADER_HOOK_VSYNC) {

View File

@ -40,17 +40,20 @@ ON_APPLICATION_START(args){
DEBUG_FUNCTION_LINE("Initializing the controller data\n");
ControllerPatcher::Init(CONTROLLER_PATCHER_PATH);
ControllerPatcher::disableControllerMapping();
log_print("Starting HID to VPAD network server\n");
DEBUG_FUNCTION_LINE("Starting HID to VPAD network server\n");
ControllerPatcher::startNetworkServer();
}
ON_APPLICATION_ENDING(){
//CursorDrawer::destroyInstance();
ControllerPatcher::destroyConfigHelper();
ControllerPatcher::stopNetworkServer();
ControllerPatcher::resetCallbackData();
ON_APP_STATUS_CHANGED(status){
if(status == WUPS_APP_STATUS_CLOSED){
//CursorDrawer::destroyInstance();
DEBUG_FUNCTION_LINE("ON_APPLICATION_ENDING\n");
ControllerPatcher::destroyConfigHelper();
DEBUG_FUNCTION_LINE("Calling stopNetworkServer\n");
ControllerPatcher::stopNetworkServer();
DEBUG_FUNCTION_LINE("Calling resetCallbackData\n");
ControllerPatcher::resetCallbackData();
}
}
DECL_FUNCTION(s32, VPADRead, s32 chan, VPADData *buffer, u32 buffer_size, s32 *error) {

File diff suppressed because it is too large Load Diff

View File

@ -39,9 +39,11 @@ typedef enum wups_loader_hook_type_t {
WUPS_LOADER_HOOK_INIT_PLUGIN, /* Called when exiting the plugin loader */
WUPS_LOADER_HOOK_DEINIT_PLUGIN, /* Called when re-entering the plugin loader */
WUPS_LOADER_HOOK_STARTING_APPLICATION, /* Called when an application gets started */
WUPS_LOADER_HOOK_FUNCTIONS_PATCHED, /* Called when the functions where patched */
WUPS_LOADER_HOOK_ENDING_APPLICATION, /* Called when an application ends */
WUPS_LOADER_HOOK_VSYNC, /* Called when an application calls GX2WaitForVsync (most times each frame) */
WUPS_LOADER_HOOK_APP_STATUS_CHANGED, /* Called when the app status changes (foreground, background, closing) */
} wups_loader_hook_type_t;
typedef struct wups_loader_hook_t {
@ -107,7 +109,12 @@ typedef struct wups_loader_app_started_args_t {
#define ON_APPLICATION_START(myargs) \
void on_app_starting(wups_loader_app_started_args_t);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_STARTING_APPLICATION,on_app_starting); \
void on_app_starting(wups_loader_app_started_args_t myargs)
void on_app_starting(wups_loader_app_started_args_t myargs)
#define ON_FUNCTIONS_PATCHED() \
void on_functions_patched();\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,on_functions_patched); \
void on_functions_patched()
#define ON_APPLICATION_ENDING() \
void on_app_ending(void);\