2022-07-25 15:20:17 +02:00
|
|
|
#include "common/ipc_defs.h"
|
|
|
|
#include "ios_exploit.h"
|
2020-04-28 15:07:52 +02:00
|
|
|
#include <coreinit/cache.h>
|
2022-07-25 15:20:17 +02:00
|
|
|
#include <coreinit/debug.h>
|
2020-06-21 00:04:10 +02:00
|
|
|
#include <coreinit/ios.h>
|
2023-11-25 17:55:10 +01:00
|
|
|
#include <coreinit/thread.h>
|
2022-02-04 14:23:22 +01:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2022-07-25 15:22:17 +02:00
|
|
|
#include <mocha/commands.h>
|
2021-04-04 23:51:23 +02:00
|
|
|
#include <sysapp/title.h>
|
|
|
|
#include <whb/log.h>
|
|
|
|
#include <whb/log_udp.h>
|
2020-04-28 15:07:52 +02:00
|
|
|
|
2023-11-25 17:55:10 +01:00
|
|
|
static void StartMCPThreadIfMochaAlreadyRunning() {
|
|
|
|
// start /dev/iosuhax and wupserver if mocha is already running
|
|
|
|
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
|
|
|
if (mcpFd >= 0) {
|
|
|
|
int in = IPC_CUSTOM_START_MCP_THREAD;
|
|
|
|
int out = 0;
|
|
|
|
if (IOS_Ioctl(mcpFd, 100, &in, sizeof(in), &out, sizeof(out)) == IOS_ERROR_OK) {
|
|
|
|
// give /dev/iosuhax a chance to start.
|
|
|
|
OSSleepTicks(OSMillisecondsToTicks(100));
|
|
|
|
}
|
|
|
|
IOS_Close(mcpFd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-28 15:07:52 +02:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
WHBLogUdpInit();
|
|
|
|
WHBLogPrintf("Hello from mocha");
|
2021-09-23 18:52:20 +02:00
|
|
|
|
2021-12-28 15:30:53 +01:00
|
|
|
if (argc >= 1) {
|
|
|
|
if (strncmp(argv[0], "fs:/", 4) == 0) {
|
|
|
|
strncpy((char *) 0xF417FEF0, argv[0], 0xFF);
|
2023-03-11 17:06:07 +01:00
|
|
|
DCStoreRange((void *) 0xF417FEF0, 0x100);
|
2021-12-28 15:30:53 +01:00
|
|
|
}
|
|
|
|
}
|
2022-07-25 15:20:17 +02:00
|
|
|
uint64_t sysmenuIdUll = _SYSGetSystemApplicationTitleId(SYSTEM_APP_ID_WII_U_MENU);
|
2020-06-20 23:43:44 +02:00
|
|
|
memcpy((void *) 0xF417FFF0, &sysmenuIdUll, 8);
|
|
|
|
DCStoreRange((void *) 0xF417FFF0, 0x8);
|
2020-04-28 15:07:52 +02:00
|
|
|
|
2023-11-25 17:55:10 +01:00
|
|
|
StartMCPThreadIfMochaAlreadyRunning();
|
|
|
|
|
2020-04-28 15:07:52 +02:00
|
|
|
ExecuteIOSExploit();
|
2020-06-21 00:04:10 +02:00
|
|
|
|
|
|
|
// When the kernel exploit is set up successfully, we signal the ios to move on.
|
|
|
|
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);
|
|
|
|
if (mcpFd >= 0) {
|
2022-02-04 14:23:22 +01:00
|
|
|
int in = IPC_CUSTOM_MEN_RPX_HOOK_COMPLETED;
|
2020-06-21 00:04:10 +02:00
|
|
|
int out = 0;
|
2021-04-04 22:33:22 +02:00
|
|
|
IOS_Ioctl(mcpFd, 100, &in, sizeof(in), &out, sizeof(out));
|
2020-06-21 00:04:10 +02:00
|
|
|
|
2022-02-04 14:23:22 +01:00
|
|
|
in = IPC_CUSTOM_START_MCP_THREAD;
|
2021-04-04 22:33:22 +02:00
|
|
|
out = 0;
|
2020-06-21 00:04:10 +02:00
|
|
|
IOS_Ioctl(mcpFd, 100, &in, sizeof(in), &out, sizeof(out));
|
|
|
|
IOS_Close(mcpFd);
|
|
|
|
}
|
|
|
|
|
2020-04-28 15:07:52 +02:00
|
|
|
WHBLogPrintf("Bye from mocha");
|
|
|
|
return 0;
|
|
|
|
}
|