mirror of
https://github.com/wiiu-env/MochaPayload.git
synced 2024-11-13 03:35:07 +01:00
When loading a homebrew app force the title to have full permission, give it acccess to the codegen and increase codesize limit to 64MiB.
This commit is contained in:
parent
78a6c4288a
commit
4dd0e9a9f3
@ -1,5 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define CHECK_SIZE(Type, Size) \
|
||||
static_assert(sizeof(Type) == Size, \
|
||||
#Type " must be " #Size " bytes")
|
||||
|
||||
#define CHECK_OFFSET(Type, Offset, Field) \
|
||||
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;
|
||||
@ -109,12 +120,13 @@ typedef struct __attribute__((packed)) {
|
||||
uint32_t add_on_unique_id[32];
|
||||
} ACPMetaXml;
|
||||
|
||||
struct Permission {
|
||||
typedef struct __attribute__((packed)) {
|
||||
uint32_t group;
|
||||
uint64_t mask;
|
||||
};
|
||||
} Permission;
|
||||
|
||||
typedef struct __attribute__((packed)) {
|
||||
|
||||
uint32_t version;
|
||||
char unkn1[8];
|
||||
uint64_t titleId;
|
||||
@ -130,7 +142,7 @@ typedef struct __attribute__((packed)) {
|
||||
uint32_t overlay_arena;
|
||||
uint32_t num_workarea_heap_blocks;
|
||||
uint32_t num_codearea_heap_blocks;
|
||||
struct Permission permissions[19];
|
||||
Permission permissions[19];
|
||||
uint32_t default_stack0_size;
|
||||
uint32_t default_stack1_size;
|
||||
uint32_t default_stack2_size;
|
||||
@ -144,6 +156,33 @@ typedef struct __attribute__((packed)) {
|
||||
uint32_t titleVersion;
|
||||
char unknwn2[0x1270 - 0x124C];
|
||||
} MCPPPrepareTitleInfo;
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x00, version);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x0C, titleId);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x14, groupId);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x18, cmdFlags);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1C, argstr);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x101C, argv);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x111C, max_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1120, avail_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1124, codegen_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1128, codegen_core);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x112C, max_codesize);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1130, overlay_arena);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1134, num_workarea_heap_blocks);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1138, num_codearea_heap_blocks);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x113C, permissions);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1220, default_stack0_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1224, default_stack1_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1228, default_stack2_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x122C, default_redzone0_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1230, default_redzone1_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1234, default_redzone2_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1238, exception_stack0_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x123C, exception_stack1_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1240, exception_stack2_size);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1244, sdkVersion);
|
||||
CHECK_OFFSET(MCPPPrepareTitleInfo, 0x1248, titleVersion);
|
||||
CHECK_SIZE(MCPPPrepareTitleInfo, 0x1270);
|
||||
|
||||
typedef struct {
|
||||
uint32_t version;
|
||||
|
@ -167,7 +167,39 @@ int _MCP_ReadCOSXml_patch(uint32_t u1, uint32_t u2, MCPPPrepareTitleInfo *xmlDat
|
||||
|
||||
int res = real_MCP_ReadCOSXml_patch(u1, u2, xmlData);
|
||||
|
||||
// if we replace the RPX we want to increase the max_codesize and give us full permission!
|
||||
if (replace_valid) {
|
||||
if (xmlData->titleId == 0x000500101004E000 ||
|
||||
xmlData->titleId == 0x000500101004E100 ||
|
||||
xmlData->titleId == 0x000500101004E200) {
|
||||
xmlData->codegen_size = 0x02000000;
|
||||
xmlData->codegen_core = 0x80000001;
|
||||
xmlData->max_size = 0x40000000;
|
||||
|
||||
// Set maximum codesize to 64 MiB
|
||||
xmlData->max_codesize = 0x04000000;
|
||||
xmlData->avail_size = 0;
|
||||
xmlData->overlay_arena = 0;
|
||||
|
||||
// Give us full permissions everywhere
|
||||
for (uint32_t i = 0; i < 19; i++) {
|
||||
xmlData->permissions[i].mask = 0xFFFFFFFFFFFFFFFF;
|
||||
}
|
||||
|
||||
xmlData->default_stack0_size = 0;
|
||||
xmlData->default_stack1_size = 0;
|
||||
xmlData->default_stack2_size = 0;
|
||||
xmlData->default_redzone0_size = 0;
|
||||
xmlData->default_redzone1_size = 0;
|
||||
xmlData->default_redzone2_size = 0;
|
||||
xmlData->exception_stack0_size = 0x00001000;
|
||||
xmlData->exception_stack1_size = 0x00001000;
|
||||
xmlData->exception_stack2_size = 0x00001000;
|
||||
}
|
||||
}
|
||||
|
||||
// When the PPC Kernel reboots we replace the men.rpx to set up our PPC side again
|
||||
// for this the Wii U Menu temporarily gets replaced by our root.rpx and needs code gen access
|
||||
if (!skipPPCSetup) {
|
||||
if (xmlData->titleId == 0x0005001010040000 ||
|
||||
xmlData->titleId == 0x0005001010040100 ||
|
||||
@ -176,24 +208,6 @@ int _MCP_ReadCOSXml_patch(uint32_t u1, uint32_t u2, MCPPPrepareTitleInfo *xmlDat
|
||||
xmlData->codegen_size = 0x02000000;
|
||||
xmlData->codegen_core = 0x80000001;
|
||||
xmlData->max_codesize = 0x02800000;
|
||||
/*
|
||||
xmlData->max_size = 0x40000000;
|
||||
xmlData->max_codesize = 0x00800000;
|
||||
xmlData->avail_size = 0;
|
||||
xmlData->overlay_arena = 0;
|
||||
for (uint32_t i = 0; i < 19; i++) {
|
||||
xmlData->permissions[i].mask = 0xFFFFFFFFFFFFFFFF;
|
||||
}
|
||||
xmlData->default_stack0_size = 0;
|
||||
xmlData->default_stack1_size = 0;
|
||||
xmlData->default_stack2_size = 0;
|
||||
xmlData->default_redzone0_size = 0;
|
||||
xmlData->default_redzone1_size = 0;
|
||||
xmlData->default_redzone2_size = 0;
|
||||
xmlData->exception_stack0_size = 0x00001000;
|
||||
xmlData->exception_stack1_size = 0x00001000;
|
||||
xmlData->exception_stack2_size = 0x00001000;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user