2021-09-23 18:34:56 +02:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2020-04-26 13:41:39 +02:00
|
|
|
#include <coreinit/time.h>
|
|
|
|
|
|
|
|
#include <coreinit/foreground.h>
|
|
|
|
|
2020-11-26 21:40:24 +01:00
|
|
|
#include <nn/act/client_cpp.h>
|
|
|
|
|
2020-04-26 13:41:39 +02:00
|
|
|
#include <proc_ui/procui.h>
|
|
|
|
#include <coreinit/thread.h>
|
2020-10-19 00:46:10 +02:00
|
|
|
#include <coreinit/screen.h>
|
2020-04-26 13:41:39 +02:00
|
|
|
|
|
|
|
#include <whb/log.h>
|
|
|
|
#include <whb/log_udp.h>
|
|
|
|
#include <sysapp/launch.h>
|
2020-08-21 23:03:53 +02:00
|
|
|
#include <sysapp/title.h>
|
2020-04-26 13:41:39 +02:00
|
|
|
#include <coreinit/cache.h>
|
|
|
|
#include <vpad/input.h>
|
2020-10-19 00:46:10 +02:00
|
|
|
#include <string>
|
2020-04-26 13:41:39 +02:00
|
|
|
#include "utils/logger.h"
|
|
|
|
#include "ElfUtils.h"
|
|
|
|
#include "ios_exploit.h"
|
|
|
|
|
|
|
|
#include "gx2sploit.h"
|
2020-07-22 15:12:25 +02:00
|
|
|
|
2020-10-19 00:46:10 +02:00
|
|
|
void SplashScreen(int32_t durationInMs);
|
|
|
|
|
2020-11-30 17:45:51 +01:00
|
|
|
void forceDefaultTitleIDToWiiUMenu();
|
|
|
|
|
2020-04-26 13:41:39 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-11-26 21:40:24 +01:00
|
|
|
extern "C" void _SYSLaunchMenuWithCheckingAccount(nn::act::SlotNo slot);
|
2021-09-23 18:34:56 +02:00
|
|
|
extern "C" void SYSLaunchMiiStudio(void *SysMiiStudioArgs);
|
2020-11-26 21:40:24 +01:00
|
|
|
|
2020-04-26 13:41:39 +02:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
WHBLogUdpInit();
|
|
|
|
|
2020-08-23 10:37:31 +02:00
|
|
|
DEBUG_FUNCTION_LINE("Hello!");
|
2020-04-26 13:41:39 +02:00
|
|
|
|
|
|
|
VPADReadError err;
|
|
|
|
VPADStatus vpad_data;
|
|
|
|
VPADRead(VPAD_CHAN_0, &vpad_data, 1, &err);
|
|
|
|
|
2020-12-11 15:54:50 +01:00
|
|
|
uint32_t btn = 0;
|
2021-09-23 18:34:56 +02:00
|
|
|
if (err == VPAD_READ_SUCCESS) {
|
2020-12-11 15:54:50 +01:00
|
|
|
btn = vpad_data.hold | vpad_data.trigger;
|
|
|
|
}
|
2021-09-23 18:34:56 +02:00
|
|
|
|
2020-04-26 13:41:39 +02:00
|
|
|
bool loadWithoutHacks = false;
|
|
|
|
bool kernelDone = false;
|
2020-08-21 23:04:26 +02:00
|
|
|
bool skipKernel = false;
|
|
|
|
|
|
|
|
if ((btn & VPAD_BUTTON_R) == VPAD_BUTTON_R) {
|
|
|
|
skipKernel = true;
|
|
|
|
loadWithoutHacks = true;
|
|
|
|
}
|
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...
|
2020-08-23 10:37:31 +02:00
|
|
|
DEBUG_FUNCTION_LINE("Force kernel exploit");
|
2020-04-26 13:41:39 +02:00
|
|
|
kernelDone = true;
|
|
|
|
DoKernelExploit();
|
|
|
|
}
|
|
|
|
|
2020-08-21 23:04:26 +02:00
|
|
|
if (!kernelDone && !skipKernel) {
|
2020-07-22 15:12:25 +02:00
|
|
|
if (fopen("fs:/vol/external01/wiiu/payload.elf", "r") != NULL) {
|
2020-08-23 10:37:31 +02:00
|
|
|
DEBUG_FUNCTION_LINE("We need the kernel exploit to load the payload");
|
2020-04-26 13:41:39 +02:00
|
|
|
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-08-23 10:37:31 +02:00
|
|
|
DEBUG_FUNCTION_LINE("New entrypoint at %08X", entryPoint);
|
2020-12-04 19:24:50 +01:00
|
|
|
|
2021-09-23 18:34:56 +02:00
|
|
|
char *arr[3];
|
2020-12-04 19:24:50 +01:00
|
|
|
arr[0] = argv[0];
|
2021-09-23 18:34:56 +02:00
|
|
|
arr[1] = (char *) "void forceDefaultTitleIDToWiiUMenu(void)";
|
|
|
|
arr[2] = (char *) &forceDefaultTitleIDToWiiUMenu;
|
2020-12-04 19:24:50 +01:00
|
|
|
|
|
|
|
int res = ((int (*)(int, char **)) entryPoint)(3, arr);
|
|
|
|
if (res >= 0) {
|
2020-11-30 17:45:51 +01:00
|
|
|
DEBUG_FUNCTION_LINE("Exiting.");
|
2020-04-26 13:41:39 +02:00
|
|
|
WHBLogUdpDeinit();
|
2020-11-30 17:45:51 +01:00
|
|
|
return res;
|
2020-10-19 00:27:59 +02:00
|
|
|
} else {
|
|
|
|
loadWithoutHacks = true;
|
2020-04-26 13:41:39 +02:00
|
|
|
}
|
|
|
|
} else {
|
2020-10-19 00:46:10 +02:00
|
|
|
SplashScreen(1000);
|
2020-04-26 13:41:39 +02:00
|
|
|
loadWithoutHacks = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ProcUIInit(OSSavesDone_ReadyToRelease);
|
|
|
|
DEBUG_FUNCTION_LINE("ProcUIInit done");
|
|
|
|
|
2020-07-22 15:12:25 +02:00
|
|
|
if (loadWithoutHacks) {
|
2020-08-21 23:03:53 +02:00
|
|
|
DEBUG_FUNCTION_LINE("Load Wii U Menu");
|
2020-11-30 17:45:51 +01:00
|
|
|
forceDefaultTitleIDToWiiUMenu();
|
2020-11-26 21:40:24 +01:00
|
|
|
|
|
|
|
nn::act::Initialize();
|
|
|
|
nn::act::SlotNo slot = nn::act::GetSlotNo();
|
|
|
|
nn::act::SlotNo defaultSlot = nn::act::GetDefaultAccount();
|
|
|
|
nn::act::Finalize();
|
|
|
|
|
|
|
|
if (defaultSlot) {
|
|
|
|
//normal menu boot
|
|
|
|
SYSLaunchMenu();
|
|
|
|
} else {
|
|
|
|
//show mii select
|
|
|
|
_SYSLaunchMenuWithCheckingAccount(slot);
|
|
|
|
}
|
2020-04-26 13:41:39 +02:00
|
|
|
}
|
|
|
|
|
2020-07-22 15:12:25 +02:00
|
|
|
while (CheckRunning()) {
|
2020-04-26 13:41:39 +02:00
|
|
|
// wait.
|
|
|
|
OSSleepTicks(OSMillisecondsToTicks(100));
|
|
|
|
}
|
|
|
|
ProcUIShutdown();
|
|
|
|
|
2020-08-21 23:03:53 +02:00
|
|
|
DEBUG_FUNCTION_LINE("Exiting.");
|
2020-04-26 13:41:39 +02:00
|
|
|
WHBLogUdpDeinit();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2020-10-19 00:46:10 +02:00
|
|
|
|
2020-11-30 17:45:51 +01:00
|
|
|
void forceDefaultTitleIDToWiiUMenu() {// Restore the default title id to the normal Wii U Menu.
|
|
|
|
unsigned long long sysmenuIdUll = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_HOME_MENU);
|
|
|
|
memcpy((void *) 0xF417FFF0, &sysmenuIdUll, 8);
|
|
|
|
DCStoreRange((void *) 0xF417FFF0, 0x8);
|
|
|
|
DEBUG_FUNCTION_LINE("Forcing start of title: %016llX", sysmenuIdUll);
|
|
|
|
ExecuteIOSExploit();
|
|
|
|
}
|
|
|
|
|
2020-10-19 00:46:10 +02:00
|
|
|
|
|
|
|
void SplashScreen(int32_t durationInMs) {
|
2021-09-23 18:34:56 +02:00
|
|
|
uint32_t screen_buf0_size;
|
2020-10-19 00:46:10 +02:00
|
|
|
|
|
|
|
// Init screen and screen buffers
|
|
|
|
OSScreenInit();
|
|
|
|
screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
|
|
|
OSScreenSetBufferEx(SCREEN_TV, (void *) 0xF4000000);
|
|
|
|
OSScreenSetBufferEx(SCREEN_DRC, (void *) (0xF4000000 + screen_buf0_size));
|
|
|
|
|
|
|
|
OSScreenEnableEx(SCREEN_TV, 1);
|
|
|
|
OSScreenEnableEx(SCREEN_DRC, 1);
|
|
|
|
|
|
|
|
// Clear screens
|
|
|
|
OSScreenClearBufferEx(SCREEN_TV, 0);
|
|
|
|
OSScreenClearBufferEx(SCREEN_DRC, 0);
|
|
|
|
|
|
|
|
std::string message1 = "Failed to load sd:/wiiu/payload.elf";
|
|
|
|
std::string message2 = "Starting the console without any modifcations.";
|
|
|
|
|
|
|
|
OSScreenPutFontEx(SCREEN_TV, 0, 0, message1.c_str());
|
|
|
|
OSScreenPutFontEx(SCREEN_DRC, 0, 0, message1.c_str());
|
|
|
|
|
|
|
|
OSScreenPutFontEx(SCREEN_TV, 0, 1, message2.c_str());
|
|
|
|
OSScreenPutFontEx(SCREEN_DRC, 0, 1, message2.c_str());
|
|
|
|
|
|
|
|
OSScreenFlipBuffersEx(SCREEN_TV);
|
|
|
|
OSScreenFlipBuffersEx(SCREEN_DRC);
|
|
|
|
|
|
|
|
OSSleepTicks(OSMillisecondsToTicks(durationInMs));
|
|
|
|
}
|