From 31836812ef8536154b23c1ab77981db8e0adcd6a Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 4 Dec 2020 19:24:50 +0100 Subject: [PATCH] Pass a callback to the entrypoint instead of handling the return values --- source/main.cpp | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 8ba46ec..5ac2035 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -89,33 +89,14 @@ int main(int argc, char **argv) { uint32_t entryPoint = load_loader_elf_from_sd(0, "wiiu/payload.elf"); if (entryPoint != 0) { DEBUG_FUNCTION_LINE("New entrypoint at %08X", entryPoint); - int res = ((int (*)(int, char **)) entryPoint)(argc, argv); - WHBLogUdpInit(); - if (res >= 0) { - DEBUG_FUNCTION_LINE("Returning result of payload"); - if(res & 1){ - DEBUG_FUNCTION_LINE("Force default title id"); - forceDefaultTitleIDToWiiUMenu(); - } - if(res & 4){ - DEBUG_FUNCTION_LINE("do produi"); - ProcUIInit(OSSavesDone_ReadyToRelease); - } - if(res & 2){ - DEBUG_FUNCTION_LINE("Launch menu"); - SYSLaunchMenu(); - }else if(res & 8){ - DEBUG_FUNCTION_LINE("Launch mii maker"); - SYSLaunchMiiStudio(0); - } - if(res & 4){ - DEBUG_FUNCTION_LINE("ProcUIInit done"); - while (CheckRunning()) { - // wait. - OSSleepTicks(OSMillisecondsToTicks(100)); - } - ProcUIShutdown(); - } + + char* arr[3]; + arr[0] = argv[0]; + arr[1] = (char*) "void forceDefaultTitleIDToWiiUMenu(void)"; + arr[2] = (char*)&forceDefaultTitleIDToWiiUMenu; + + int res = ((int (*)(int, char **)) entryPoint)(3, arr); + if (res >= 0) { DEBUG_FUNCTION_LINE("Exiting."); WHBLogUdpDeinit(); return res;