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);