Pass a callback to the entrypoint instead of handling the return values

This commit is contained in:
Maschell 2020-12-04 19:24:50 +01:00
parent c4c14496af
commit 31836812ef

View File

@ -89,33 +89,14 @@ int main(int argc, char **argv) {
uint32_t entryPoint = load_loader_elf_from_sd(0, "wiiu/payload.elf"); uint32_t entryPoint = load_loader_elf_from_sd(0, "wiiu/payload.elf");
if (entryPoint != 0) { if (entryPoint != 0) {
DEBUG_FUNCTION_LINE("New entrypoint at %08X", entryPoint); DEBUG_FUNCTION_LINE("New entrypoint at %08X", entryPoint);
int res = ((int (*)(int, char **)) entryPoint)(argc, argv);
WHBLogUdpInit(); char* arr[3];
if (res >= 0) { arr[0] = argv[0];
DEBUG_FUNCTION_LINE("Returning result of payload"); arr[1] = (char*) "void forceDefaultTitleIDToWiiUMenu(void)";
if(res & 1){ arr[2] = (char*)&forceDefaultTitleIDToWiiUMenu;
DEBUG_FUNCTION_LINE("Force default title id");
forceDefaultTitleIDToWiiUMenu(); int res = ((int (*)(int, char **)) entryPoint)(3, arr);
} if (res >= 0) {
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();
}
DEBUG_FUNCTION_LINE("Exiting."); DEBUG_FUNCTION_LINE("Exiting.");
WHBLogUdpDeinit(); WHBLogUdpDeinit();
return res; return res;