2020-06-12 20:51:21 +02:00
|
|
|
#include "hooks_patcher_static.h"
|
2019-03-01 19:26:15 +01:00
|
|
|
#include <malloc.h>
|
2020-04-29 18:02:36 +02:00
|
|
|
#include <wups.h>
|
|
|
|
#include <vpad/input.h>
|
|
|
|
#include <coreinit/messagequeue.h>
|
|
|
|
#include <coreinit/core.h>
|
2019-02-08 16:42:39 +01:00
|
|
|
|
2020-12-26 14:17:50 +01:00
|
|
|
#include "../utils/logger.h"
|
|
|
|
#include "../globals.h"
|
|
|
|
#include "../hooks.h"
|
2019-02-08 16:42:39 +01:00
|
|
|
|
2020-06-12 20:51:21 +02:00
|
|
|
DECL_FUNCTION(void, GX2WaitForVsync, void) {
|
2020-04-29 18:02:36 +02:00
|
|
|
CallHook(gPluginInformation, WUPS_LOADER_HOOK_VSYNC);
|
2019-02-08 16:42:39 +01:00
|
|
|
real_GX2WaitForVsync();
|
|
|
|
}
|
|
|
|
|
2019-11-16 15:12:30 +01:00
|
|
|
static uint32_t lastData0 = 0;
|
2020-06-12 20:51:21 +02:00
|
|
|
DECL_FUNCTION(uint32_t, OSReceiveMessage, OSMessageQueue *queue, OSMessage *message, uint32_t flags) {
|
2020-05-03 12:30:15 +02:00
|
|
|
int32_t res = real_OSReceiveMessage(queue, message, flags);
|
|
|
|
if (queue == OSGetSystemMessageQueue()) {
|
2020-12-26 14:17:50 +01:00
|
|
|
if (message != nullptr && res) {
|
2020-05-03 12:30:15 +02:00
|
|
|
if (lastData0 != message->args[0]) {
|
|
|
|
if (message->args[0] == 0xFACEF000) {
|
2020-04-29 18:02:36 +02:00
|
|
|
CallHook(gPluginInformation, WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND);
|
2020-05-03 12:30:15 +02:00
|
|
|
} else if (message->args[0] == 0xD1E0D1E0) {
|
2020-12-28 14:38:08 +01:00
|
|
|
// Implemented via WUMS Hook
|
2019-11-16 15:12:30 +01:00
|
|
|
}
|
|
|
|
}
|
2020-04-29 18:02:36 +02:00
|
|
|
lastData0 = message->args[0];
|
2019-11-16 15:12:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2020-06-12 20:51:21 +02:00
|
|
|
DECL_FUNCTION(void, OSReleaseForeground) {
|
2020-05-03 12:30:15 +02:00
|
|
|
if (OSGetCoreId() == 1) {
|
2020-04-29 18:02:36 +02:00
|
|
|
CallHook(gPluginInformation, WUPS_LOADER_HOOK_RELEASE_FOREGROUND);
|
2019-11-16 15:12:30 +01:00
|
|
|
}
|
|
|
|
real_OSReleaseForeground();
|
|
|
|
}
|
|
|
|
|
2020-06-12 20:51:21 +02:00
|
|
|
function_replacement_data_t method_hooks_hooks_static[] __attribute__((section(".data"))) = {
|
2020-08-09 18:14:58 +02:00
|
|
|
REPLACE_FUNCTION(GX2WaitForVsync, LIBRARY_GX2, GX2WaitForVsync),
|
2020-06-12 20:51:21 +02:00
|
|
|
REPLACE_FUNCTION(OSReceiveMessage, LIBRARY_COREINIT, OSReceiveMessage),
|
|
|
|
REPLACE_FUNCTION(OSReleaseForeground, LIBRARY_COREINIT, OSReleaseForeground)
|
2019-02-08 16:42:39 +01:00
|
|
|
};
|
|
|
|
|
2020-06-12 20:51:21 +02:00
|
|
|
uint32_t method_hooks_size_hooks_static __attribute__((section(".data"))) = sizeof(method_hooks_hooks_static) / sizeof(function_replacement_data_t);
|