mirror of
https://github.com/wiiu-env/MochaPayload.git
synced 2024-12-22 14:11:51 +01:00
Add initial libmocha support
This commit is contained in:
parent
4f20c634c9
commit
dcd439e423
@ -1,3 +1,5 @@
|
||||
FROM wiiuenv/devkitppc:20220724
|
||||
|
||||
COPY --from=wiiuenv/libmocha:20220722 /artifacts $DEVKITPRO
|
||||
|
||||
WORKDIR project
|
5
Makefile
5
Makefile
@ -36,14 +36,13 @@ CXXFLAGS := $(CFLAGS)
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -g $(ARCH) $(RPXSPECS) --entry=_start -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lwut
|
||||
LIBS := -lwut -lmocha
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level
|
||||
# containing include and lib
|
||||
#-------------------------------------------------------------------------------
|
||||
LIBDIRS := $(PORTLIBS) $(WUT_ROOT)
|
||||
|
||||
LIBDIRS := $(PORTLIBS) $(WUT_ROOT) $(WUT_ROOT)/usr
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
|
@ -12,115 +12,6 @@
|
||||
static_assert(offsetof(Type, Field) == Offset, \
|
||||
#Type "::" #Field " must be at offset " #Offset)
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint64_t title_id;
|
||||
uint64_t boss_id;
|
||||
uint64_t os_version;
|
||||
uint64_t app_size;
|
||||
uint64_t common_save_size;
|
||||
uint64_t account_save_size;
|
||||
uint64_t common_boss_size;
|
||||
uint64_t account_boss_size;
|
||||
uint64_t join_game_mode_mask;
|
||||
uint32_t version;
|
||||
char product_code[32];
|
||||
char content_platform[32];
|
||||
char company_code[8];
|
||||
char mastering_date[32];
|
||||
uint32_t logo_type;
|
||||
uint32_t app_launch_type;
|
||||
uint32_t invisible_flag;
|
||||
uint32_t no_managed_flag;
|
||||
uint32_t no_event_log;
|
||||
uint32_t no_icon_database;
|
||||
uint32_t launching_flag;
|
||||
uint32_t install_flag;
|
||||
uint32_t closing_msg;
|
||||
uint32_t title_version;
|
||||
uint32_t group_id;
|
||||
uint32_t save_no_rollback;
|
||||
uint32_t bg_daemon_enable;
|
||||
uint32_t join_game_id;
|
||||
uint32_t olv_accesskey;
|
||||
uint32_t wood_tin;
|
||||
uint32_t e_manual;
|
||||
uint32_t e_manual_version;
|
||||
uint32_t region;
|
||||
uint32_t pc_cero;
|
||||
uint32_t pc_esrb;
|
||||
uint32_t pc_bbfc;
|
||||
uint32_t pc_usk;
|
||||
uint32_t pc_pegi_gen;
|
||||
uint32_t pc_pegi_fin;
|
||||
uint32_t pc_pegi_prt;
|
||||
uint32_t pc_pegi_bbfc;
|
||||
uint32_t pc_cob;
|
||||
uint32_t pc_grb;
|
||||
uint32_t pc_cgsrr;
|
||||
uint32_t pc_oflc;
|
||||
uint32_t pc_reserved0;
|
||||
uint32_t pc_reserved1;
|
||||
uint32_t pc_reserved2;
|
||||
uint32_t pc_reserved3;
|
||||
uint32_t ext_dev_nunchaku;
|
||||
uint32_t ext_dev_classic;
|
||||
uint32_t ext_dev_urcc;
|
||||
uint32_t ext_dev_board;
|
||||
uint32_t ext_dev_usb_keyboard;
|
||||
uint32_t ext_dev_etc;
|
||||
char ext_dev_etc_name[512];
|
||||
uint32_t eula_version;
|
||||
uint32_t drc_use;
|
||||
uint32_t network_use;
|
||||
uint32_t online_account_use;
|
||||
uint32_t direct_boot;
|
||||
uint32_t reserved_flag0;
|
||||
uint32_t reserved_flag1;
|
||||
uint32_t reserved_flag2;
|
||||
uint32_t reserved_flag3;
|
||||
uint32_t reserved_flag4;
|
||||
uint32_t reserved_flag5;
|
||||
uint32_t reserved_flag6;
|
||||
uint32_t reserved_flag7;
|
||||
char longname_ja[512];
|
||||
char longname_en[512];
|
||||
char longname_fr[512];
|
||||
char longname_de[512];
|
||||
char longname_it[512];
|
||||
char longname_es[512];
|
||||
char longname_zhs[512];
|
||||
char longname_ko[512];
|
||||
char longname_nl[512];
|
||||
char longname_pt[512];
|
||||
char longname_ru[512];
|
||||
char longname_zht[512];
|
||||
char shortname_ja[256];
|
||||
char shortname_en[256];
|
||||
char shortname_fr[256];
|
||||
char shortname_de[256];
|
||||
char shortname_it[256];
|
||||
char shortname_es[256];
|
||||
char shortname_zhs[256];
|
||||
char shortname_ko[256];
|
||||
char shortname_nl[256];
|
||||
char shortname_pt[256];
|
||||
char shortname_ru[256];
|
||||
char shortname_zht[256];
|
||||
char publisher_ja[256];
|
||||
char publisher_en[256];
|
||||
char publisher_fr[256];
|
||||
char publisher_de[256];
|
||||
char publisher_it[256];
|
||||
char publisher_es[256];
|
||||
char publisher_zhs[256];
|
||||
char publisher_ko[256];
|
||||
char publisher_nl[256];
|
||||
char publisher_pt[256];
|
||||
char publisher_ru[256];
|
||||
char publisher_zht[256];
|
||||
uint32_t add_on_unique_id[32];
|
||||
} ACPMetaXml;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint32_t group;
|
||||
uint64_t mask;
|
||||
@ -223,10 +114,4 @@ typedef struct {
|
||||
unsigned char unk3[0x12D8 - 0x68];
|
||||
} MCPLoadFileRequest;
|
||||
|
||||
#define IPC_CUSTOM_START_MCP_THREAD 0xFE
|
||||
#define IPC_CUSTOM_MEN_RPX_HOOK_COMPLETED 0xFD
|
||||
#define IPC_CUSTOM_LOAD_CUSTOM_RPX 0xFC
|
||||
#define IPC_CUSTOM_START_USB_LOGGING 0xFA
|
||||
#define IPC_CUSTOM_COPY_ENVIRONMENT_PATH 0xF9
|
||||
|
||||
#define LOAD_FILE_TARGET_SD_CARD 0
|
||||
#define MOCHA_API_VERSION 1
|
@ -53,7 +53,7 @@ LIBS := -lgcc
|
||||
# list of directories containing libraries, this must be the top level
|
||||
# containing include and lib
|
||||
#-------------------------------------------------------------------------------
|
||||
LIBDIRS :=
|
||||
LIBDIRS := $(DEVKITPRO)/wut/usr
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "ipc_types.h"
|
||||
#include "logger.h"
|
||||
#include "svc.h"
|
||||
#include <mocha/commands.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -31,7 +32,6 @@ int (*const MCP_DoLoadFile)(const char *path, const char *path2, void *outputBuf
|
||||
|
||||
static int MCP_LoadCustomFile(int target, char *path, int filesize, int fileoffset, void *out_buffer, int buffer_len, int pos);
|
||||
|
||||
static bool usbLoggingEnabled = false;
|
||||
static bool replace_valid = false;
|
||||
static bool skipPPCSetup = false;
|
||||
static bool doWantReplaceRPX = false;
|
||||
@ -44,7 +44,7 @@ static char rpxpath[256];
|
||||
#define FAIL_ON(cond, val) \
|
||||
if (cond) { \
|
||||
log(#cond " (%08X)", val); \
|
||||
return -29; \
|
||||
return 29; \
|
||||
}
|
||||
|
||||
int _MCP_LoadFile_patch(ipcmessage *msg) {
|
||||
@ -60,10 +60,10 @@ int _MCP_LoadFile_patch(ipcmessage *msg) {
|
||||
//DEBUG_FUNCTION_LINE("msg->ioctl.buffer_io = %p, msg->ioctl.length_io = 0x%X\n", msg->ioctl.buffer_io, msg->ioctl.length_io);
|
||||
//DEBUG_FUNCTION_LINE("request->type = %d, request->pos = %d, request->name = \"%s\"\n", request->type, request->pos, request->name);
|
||||
|
||||
int replace_target = replace_target_device;
|
||||
int replace_filesize = rep_filesize;
|
||||
int replace_fileoffset = rep_fileoffset;
|
||||
char *replace_path = rpxpath;
|
||||
LoadRPXTargetEnum replace_target = replace_target_device;
|
||||
int replace_filesize = rep_filesize;
|
||||
int replace_fileoffset = rep_fileoffset;
|
||||
char *replace_path = rpxpath;
|
||||
|
||||
if (strlen(request->name) > 1 && request->name[strlen(request->name) - 1] == 'x') {
|
||||
if (strncmp(request->name, "safe.rpx", strlen("safe.rpx")) != 0) {
|
||||
@ -88,14 +88,14 @@ int _MCP_LoadFile_patch(ipcmessage *msg) {
|
||||
// The replacement may restart the application to execute a kernel exploit.
|
||||
// The men.rpx is hooked until the "IPC_CUSTOM_MEN_RPX_HOOK_COMPLETED" command is passed to IOCTL 0x100.
|
||||
// If the loading of the replacement file fails, the Wii U Menu is loaded normally.
|
||||
replace_target = LOAD_FILE_TARGET_SD_CARD;
|
||||
replace_target = LOAD_RPX_TARGET_SD_CARD;
|
||||
replace_filesize = 0; // unknown
|
||||
replace_fileoffset = 0;
|
||||
} else if (strncmp(request->name, "safe.rpx", strlen("safe.rpx")) == 0) {
|
||||
// if we don't explicitly replace files, we do want replace the Health and Safety app with the HBL
|
||||
if (request->pos == 0 && !doWantReplaceRPX) {
|
||||
replace_path = "wiiu/apps/homebrew_launcher/homebrew_launcher.rpx";
|
||||
replace_target = LOAD_FILE_TARGET_SD_CARD;
|
||||
replace_target = LOAD_RPX_TARGET_SD_CARD;
|
||||
//doWantReplaceXML = false;
|
||||
doWantReplaceRPX = true;
|
||||
replace_filesize = 0; // unknown
|
||||
@ -134,7 +134,7 @@ static int MCP_LoadCustomFile(int target, char *path, int filesize, int fileoffs
|
||||
|
||||
char mountpath[] = "/vol/storage_iosu_homebrew";
|
||||
|
||||
if (target == LOAD_FILE_TARGET_SD_CARD) {
|
||||
if (target == LOAD_RPX_TARGET_SD_CARD) {
|
||||
int fsa_h = svcOpen("/dev/fsa", 0);
|
||||
int mount_res = FSA_Mount(fsa_h, "/dev/sdcard01", mountpath, 2, NULL, 0);
|
||||
svcClose(fsa_h);
|
||||
@ -162,7 +162,7 @@ static int MCP_LoadCustomFile(int target, char *path, int filesize, int fileoffs
|
||||
}
|
||||
}
|
||||
|
||||
if (result < 0x400000 && target == LOAD_FILE_TARGET_SD_CARD) {
|
||||
if (result < 0x400000 && target == LOAD_RPX_TARGET_SD_CARD) {
|
||||
int fsa_h = svcOpen("/dev/fsa", 0);
|
||||
int unmount_res = FSA_Unmount(fsa_h, mountpath, 0x80000002);
|
||||
svcClose(fsa_h);
|
||||
@ -270,7 +270,15 @@ int _MCP_ioctl100_patch(ipcmessage *msg) {
|
||||
DEBUG_FUNCTION_LINE("IPC_CUSTOM_LOAD_CUSTOM_RPX\n");
|
||||
|
||||
if (msg->ioctl.length_in >= 0x110) {
|
||||
int target = msg->ioctl.buffer_in[0x04 / 0x04];
|
||||
int target = msg->ioctl.buffer_in[0x04 / 0x04];
|
||||
if (target == LOAD_RPX_TARGET_EXTRA_REVERT_PREPARE) {
|
||||
doWantReplaceRPX = false;
|
||||
replace_valid = false;
|
||||
return 0;
|
||||
}
|
||||
if (target != LOAD_RPX_TARGET_SD_CARD) {
|
||||
return 29;
|
||||
}
|
||||
int filesize = msg->ioctl.buffer_in[0x08 / 0x04];
|
||||
int fileoffset = msg->ioctl.buffer_in[0x0C / 0x04];
|
||||
char *str_ptr = (char *) &msg->ioctl.buffer_in[0x10 / 0x04];
|
||||
@ -285,11 +293,15 @@ int _MCP_ioctl100_patch(ipcmessage *msg) {
|
||||
replace_valid = true;
|
||||
|
||||
DEBUG_FUNCTION_LINE("Will load %s for next title from target: %d (offset %d, filesize %d)\n", rpxpath, target, rep_fileoffset, rep_filesize);
|
||||
return 0;
|
||||
} else {
|
||||
return 29;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case IPC_CUSTOM_START_MCP_THREAD: {
|
||||
_startMainThread();
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
case IPC_CUSTOM_COPY_ENVIRONMENT_PATH: {
|
||||
@ -328,15 +340,26 @@ int _MCP_ioctl100_patch(ipcmessage *msg) {
|
||||
svcClose(handle);
|
||||
}
|
||||
|
||||
// Kill existing syslogs to avoid long catch up
|
||||
uint32_t *bufferPtr = (uint32_t *) (*(uint32_t *) 0x05095ecc);
|
||||
bufferPtr[0] = 0;
|
||||
bufferPtr[1] = 0;
|
||||
|
||||
usbLoggingEnabled = true;
|
||||
bool showCompleteLog = msg->ioctl.buffer_in && msg->ioctl.length_in >= 0x08 && msg->ioctl.buffer_in[1] == 1;
|
||||
if (!showCompleteLog) {
|
||||
// Kill existing syslogs to avoid long catch up
|
||||
uint32_t *bufferPtr = (uint32_t *) (*(uint32_t *) 0x05095ecc);
|
||||
bufferPtr[0] = 0;
|
||||
bufferPtr[1] = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case IPC_CUSTOM_GET_MOCHA_API_VERSION: {
|
||||
if (msg->ioctl.buffer_io && msg->ioctl.length_io >= 8) {
|
||||
msg->ioctl.buffer_io[0] = 0xCAFEBABE;
|
||||
msg->ioctl.buffer_io[1] = MOCHA_API_VERSION;
|
||||
return 0;
|
||||
} else {
|
||||
return 29;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <coreinit/ios.h>
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <mocha/commands.h>
|
||||
#include <sysapp/title.h>
|
||||
#include <whb/log.h>
|
||||
#include <whb/log_udp.h>
|
||||
|
Loading…
Reference in New Issue
Block a user