2020-04-26 13:41:39 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <coreinit/ios.h>
|
|
|
|
#include <coreinit/time.h>
|
|
|
|
|
|
|
|
#include <coreinit/systeminfo.h>
|
|
|
|
#include <coreinit/foreground.h>
|
|
|
|
|
|
|
|
#include <nsysnet/socket.h>
|
|
|
|
|
|
|
|
#include <proc_ui/procui.h>
|
|
|
|
#include <coreinit/thread.h>
|
|
|
|
|
|
|
|
#include <whb/proc.h>
|
|
|
|
#include <whb/log.h>
|
|
|
|
#include <whb/log_udp.h>
|
|
|
|
#include <sysapp/launch.h>
|
|
|
|
#include <coreinit/exit.h>
|
|
|
|
#include <coreinit/cache.h>
|
|
|
|
#include <coreinit/dynload.h>
|
|
|
|
#include <vpad/input.h>
|
|
|
|
#include "utils/logger.h"
|
|
|
|
#include "utils/utils.h"
|
|
|
|
#include "ElfUtils.h"
|
|
|
|
#include "ios_exploit.h"
|
|
|
|
|
|
|
|
#include "gx2sploit.h"
|
2020-07-22 15:12:25 +02:00
|
|
|
|
2020-04-26 13:41:39 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
bool CheckRunning() {
|
|
|
|
|
2020-07-22 15:12:25 +02:00
|
|
|
switch (ProcUIProcessMessages(true)) {
|
|
|
|
case PROCUI_STATUS_EXITING: {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
case PROCUI_STATUS_RELEASE_FOREGROUND: {
|
|
|
|
ProcUIDrawDoneRelease();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROCUI_STATUS_IN_FOREGROUND: {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PROCUI_STATUS_IN_BACKGROUND:
|
|
|
|
default:
|
|
|
|
break;
|
2020-04-26 13:41:39 +02:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" uint64_t _SYSGetSystemApplicationTitleId(int);
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
WHBLogUdpInit();
|
|
|
|
|
|
|
|
WHBLogPrintf("Hello!");
|
|
|
|
|
|
|
|
VPADReadError err;
|
|
|
|
VPADStatus vpad_data;
|
|
|
|
VPADRead(VPAD_CHAN_0, &vpad_data, 1, &err);
|
|
|
|
|
|
|
|
uint32_t btn = vpad_data.hold | vpad_data.trigger;
|
|
|
|
bool loadWithoutHacks = false;
|
|
|
|
bool kernelDone = false;
|
2020-07-22 15:12:25 +02:00
|
|
|
if ((btn & VPAD_BUTTON_ZR) == VPAD_BUTTON_ZR) {
|
2020-04-26 13:41:39 +02:00
|
|
|
loadWithoutHacks = true;
|
|
|
|
}
|
2020-07-22 15:12:25 +02:00
|
|
|
if ((btn & VPAD_BUTTON_ZL) == VPAD_BUTTON_ZL) {
|
2020-04-26 13:41:39 +02:00
|
|
|
// In case that fopen check is not working...
|
|
|
|
WHBLogPrintf("Force kernel exploit");
|
|
|
|
kernelDone = true;
|
|
|
|
DoKernelExploit();
|
|
|
|
}
|
|
|
|
|
2020-07-22 15:12:25 +02:00
|
|
|
if (!kernelDone) {
|
|
|
|
if (fopen("fs:/vol/external01/wiiu/payload.elf", "r") != NULL) {
|
2020-04-26 13:41:39 +02:00
|
|
|
WHBLogPrintf("We need the kernel exploit to load the payload");
|
|
|
|
DoKernelExploit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-22 15:12:25 +02:00
|
|
|
if (!loadWithoutHacks) {
|
2020-04-26 13:41:39 +02:00
|
|
|
uint32_t entryPoint = load_loader_elf_from_sd(0, "wiiu/payload.elf");
|
2020-07-22 15:12:25 +02:00
|
|
|
if (entryPoint != 0) {
|
2020-04-26 13:41:39 +02:00
|
|
|
WHBLogPrintf("New entrypoint: %08X", entryPoint);
|
2020-07-22 15:12:25 +02:00
|
|
|
int res = ((int (*)(int, char **)) entryPoint)(argc, argv);
|
|
|
|
if (res > 0) {
|
2020-04-26 13:41:39 +02:00
|
|
|
WHBLogPrintf("Returning...");
|
|
|
|
WHBLogUdpDeinit();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
loadWithoutHacks = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ProcUIInit(OSSavesDone_ReadyToRelease);
|
|
|
|
DEBUG_FUNCTION_LINE("ProcUIInit done");
|
|
|
|
|
2020-07-22 15:12:25 +02:00
|
|
|
if (loadWithoutHacks) {
|
2020-04-26 13:41:39 +02:00
|
|
|
DEBUG_FUNCTION_LINE("Load system menu");
|
|
|
|
// Restore the default title id to the normal wii u menu.
|
|
|
|
unsigned long long sysmenuIdUll = _SYSGetSystemApplicationTitleId(0);
|
2020-07-22 15:12:25 +02:00
|
|
|
memcpy((void *) 0xF417FFF0, &sysmenuIdUll, 8);
|
|
|
|
DCStoreRange((void *) 0xF417FFF0, 0x8);
|
2020-04-26 13:41:39 +02:00
|
|
|
|
2020-07-22 15:12:25 +02:00
|
|
|
DEBUG_FUNCTION_LINE("THIS IS A TEST %016llX\n", sysmenuIdUll);
|
2020-04-26 13:41:39 +02:00
|
|
|
|
|
|
|
ExecuteIOSExploit();
|
|
|
|
SYSLaunchMenu();
|
|
|
|
}
|
|
|
|
|
2020-07-22 15:12:25 +02:00
|
|
|
while (CheckRunning()) {
|
2020-04-26 13:41:39 +02:00
|
|
|
// wait.
|
|
|
|
OSSleepTicks(OSMillisecondsToTicks(100));
|
|
|
|
}
|
|
|
|
ProcUIShutdown();
|
|
|
|
|
|
|
|
DEBUG_FUNCTION_LINE("Bye!");
|
|
|
|
WHBLogUdpDeinit();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|