From 2e2c46324c787c2911e92ef93e14c5a33a8c74f8 Mon Sep 17 00:00:00 2001 From: Maschell Date: Sun, 9 Aug 2020 18:14:58 +0200 Subject: [PATCH] Implement WUPS_LOADER_HOOK_VSYNC hook --- source/hooks.cpp | 10 ++++++++-- source/patcher/hooks_patcher_static.cpp | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/source/hooks.cpp b/source/hooks.cpp index 7b21c61..2cb57a1 100644 --- a/source/hooks.cpp +++ b/source/hooks.cpp @@ -48,7 +48,9 @@ static const char **hook_names = (const char *[]) { "WUPS_LOADER_HOOK_APPLET_START"}; void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t hook_type, int32_t plugin_index_needed) { - DEBUG_FUNCTION_LINE("Calling hook of type %s [%d]", hook_names[hook_type], hook_type); + if(hook_type != WUPS_LOADER_HOOK_VSYNC) { + DEBUG_FUNCTION_LINE("Calling hook of type %s [%d]", hook_names[hook_type], hook_type); + } 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]; if (plugin_index_needed != -1 && plugin_index_needed != plugin_index) { @@ -60,7 +62,9 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t for (uint32_t j = 0; j < plugin_data->info.number_used_hooks; j++) { replacement_data_hook_t *hook_data = &plugin_data->info.hooks[j]; if (hook_data->type == hook_type) { - DEBUG_FUNCTION_LINE("Calling hook of type %s for plugin %s [%d]", hook_names[hook_data->type], plugin_data->meta.name, hook_type); + if(hook_data->type != WUPS_LOADER_HOOK_VSYNC){ + DEBUG_FUNCTION_LINE("Calling hook of type %s for plugin %s [%d]", hook_names[hook_data->type], plugin_data->meta.name, hook_type); + } void *func_ptr = hook_data->func_pointer; if (func_ptr != NULL) { //DEBUG_FUNCTION_LINE("function pointer is %08x\n",func_ptr); @@ -95,6 +99,8 @@ void CallHookEx(plugin_information_t *pluginInformation, wups_loader_hook_type_t ((void (*)(void)) ((uint32_t *) func_ptr))(); } else if (hook_type == WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND) { ((void (*)(void)) ((uint32_t *) func_ptr))(); + } else if (hook_type == WUPS_LOADER_HOOK_VSYNC) { + ((void (*)(void)) ((uint32_t *) func_ptr))(); } else { DEBUG_FUNCTION_LINE("######################################"); DEBUG_FUNCTION_LINE("Hook is not implemented %s [%d]", hook_names[hook_type], hook_type); diff --git a/source/patcher/hooks_patcher_static.cpp b/source/patcher/hooks_patcher_static.cpp index 46abd23..1255eed 100644 --- a/source/patcher/hooks_patcher_static.cpp +++ b/source/patcher/hooks_patcher_static.cpp @@ -279,7 +279,7 @@ DECL_FUNCTION(void, OSReleaseForeground) { function_replacement_data_t method_hooks_hooks_static[] __attribute__((section(".data"))) = { //MAKE_MAGIC(GX2SetTVBuffer, LIB_GX2, STATIC_FUNCTION), //MAKE_MAGIC(GX2SetDRCBuffer, LIB_GX2, STATIC_FUNCTION), - //MAKE_MAGIC(GX2WaitForVsync, LIB_GX2, STATIC_FUNCTION), + REPLACE_FUNCTION(GX2WaitForVsync, LIBRARY_GX2, GX2WaitForVsync), //MAKE_MAGIC(GX2CopyColorBufferToScanBuffer, LIB_GX2, STATIC_FUNCTION), //MAKE_MAGIC(GX2SetContextState, LIB_GX2, STATIC_FUNCTION), REPLACE_FUNCTION(VPADRead, LIBRARY_VPAD, VPADRead),