From a8d1960dc3b19036367c8e415ccd0a55f2fda05f Mon Sep 17 00:00:00 2001 From: Maschell Date: Wed, 4 Apr 2018 14:33:22 +0200 Subject: [PATCH] [Loader] Check the current titleid before calling hooks. --- loader/src/common/retain_vars.cpp | 1 + loader/src/common/retain_vars.h | 1 + loader/src/main.cpp | 1 + loader/src/patcher/hooks_patcher.cpp | 14 ++++++++------ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/loader/src/common/retain_vars.cpp b/loader/src/common/retain_vars.cpp index 17487c2..658922e 100644 --- a/loader/src/common/retain_vars.cpp +++ b/loader/src/common/retain_vars.cpp @@ -2,6 +2,7 @@ #include "myutils/overlay_helper.h" replacement_data_t gbl_replacement_data __attribute__((section(".data"))); u8 gAppStatus __attribute__((section(".data"))) = 0; +u64 gGameTitleID __attribute__((section(".data"))) = 0; volatile u8 gSDInitDone __attribute__((section(".data"))) = 0; void * ntfs_mounts __attribute__((section(".data"))) = NULL; diff --git a/loader/src/common/retain_vars.h b/loader/src/common/retain_vars.h index 180a8a3..47d1f90 100644 --- a/loader/src/common/retain_vars.h +++ b/loader/src/common/retain_vars.h @@ -4,6 +4,7 @@ extern replacement_data_t gbl_replacement_data; extern u8 gAppStatus; +extern u64 gGameTitleID; extern volatile u8 gSDInitDone; diff --git a/loader/src/main.cpp b/loader/src/main.cpp index 88e76ed..41906c5 100644 --- a/loader/src/main.cpp +++ b/loader/src/main.cpp @@ -86,6 +86,7 @@ extern "C" int Menu_Main(int argc, char **argv) { //setup_os_exceptions(); Init(); + gGameTitleID = OSGetTitleID(); s32 result = 0; diff --git a/loader/src/patcher/hooks_patcher.cpp b/loader/src/patcher/hooks_patcher.cpp index e0bc2f9..4fcdff0 100644 --- a/loader/src/patcher/hooks_patcher.cpp +++ b/loader/src/patcher/hooks_patcher.cpp @@ -7,18 +7,20 @@ #include "utils.h" DECL(void, __PPCExit, void) { - DEBUG_FUNCTION_LINE("__PPCExit\n"); - - CallHook(WUPS_LOADER_HOOK_ENDING_APPLICATION); - - DeInit(); + // Only continue if we are in the "right" application. + if(OSGetTitleID() == gGameTitleID) { + DEBUG_FUNCTION_LINE("__PPCExit\n"); + CallHook(WUPS_LOADER_HOOK_ENDING_APPLICATION); + DeInit(); + } real___PPCExit(); } DECL(u32, ProcUIProcessMessages, u32 u) { u32 res = real_ProcUIProcessMessages(u); - if(res != gAppStatus) { + // Only continue if we are in the "right" application. + if(res != gAppStatus && OSGetTitleID() == gGameTitleID) { DEBUG_FUNCTION_LINE("App status changed from %d to %d \n",gAppStatus,res); gAppStatus = res; CallHook(WUPS_LOADER_HOOK_APP_STATUS_CHANGED);