Hook into __PPCExit instead of _Exit

This commit is contained in:
Maschell 2022-09-09 14:27:11 +02:00
parent f13ba45652
commit 186160f8f2
3 changed files with 7 additions and 8 deletions

View File

@ -24,13 +24,6 @@ void CallHook(wums_hook_type_t type) {
} }
} }
DECL_FUNCTION(void, _Exit, uint32_t status) {
CallHook(WUMS_HOOK_APPLICATION_ENDS);
CallHook(WUMS_HOOK_FINI_WUT_SOCKETS);
CallHook(WUMS_HOOK_FINI_WUT_DEVOPTAB);
real__Exit(status);
}
DECL_FUNCTION(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *message, uint32_t flags) { DECL_FUNCTION(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *message, uint32_t flags) {
uint32_t res = real_OSReceiveMessage(queue, message, flags); uint32_t res = real_OSReceiveMessage(queue, message, flags);
if (queue == OSGetSystemMessageQueue()) { if (queue == OSGetSystemMessageQueue()) {
@ -48,7 +41,6 @@ DECL_FUNCTION(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *mess
function_replacement_data_t applicationendshook_function_replacements[] = { function_replacement_data_t applicationendshook_function_replacements[] = {
REPLACE_FUNCTION(OSReceiveMessage, LIBRARY_COREINIT, OSReceiveMessage), REPLACE_FUNCTION(OSReceiveMessage, LIBRARY_COREINIT, OSReceiveMessage),
REPLACE_FUNCTION(_Exit, LIBRARY_COREINIT, _Exit),
}; };
uint32_t applicationendshook_function_replacements_size = sizeof(applicationendshook_function_replacements) / sizeof(function_replacement_data_t); uint32_t applicationendshook_function_replacements_size = sizeof(applicationendshook_function_replacements) / sizeof(function_replacement_data_t);

View File

@ -2,11 +2,14 @@
#include <cstdint> #include <cstdint>
#include <function_patcher/function_patching.h> #include <function_patcher/function_patching.h>
#include <wums/hooks.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
void CallHook(wums_hook_type_t type);
extern function_replacement_data_t applicationendshook_function_replacements[]; extern function_replacement_data_t applicationendshook_function_replacements[];

View File

@ -1,10 +1,14 @@
#include "sd_function_replacements.h" #include "sd_function_replacements.h"
#include "applicationendshook/applicationends_function_replacements.h"
#include "globals.h" #include "globals.h"
#include "logger.h" #include "logger.h"
#include <coreinit/filesystem_fsa.h> #include <coreinit/filesystem_fsa.h>
#include <string_view> #include <string_view>
DECL_FUNCTION(void, __PPCExit, uint32_t u1) { DECL_FUNCTION(void, __PPCExit, uint32_t u1) {
CallHook(WUMS_HOOK_APPLICATION_ENDS);
CallHook(WUMS_HOOK_FINI_WUT_SOCKETS);
CallHook(WUMS_HOOK_FINI_WUT_DEVOPTAB);
if (gSDMountRefCount > 0) { if (gSDMountRefCount > 0) {
FSAInit(); FSAInit();
auto client = FSAAddClient(nullptr); auto client = FSAAddClient(nullptr);