diff --git a/src/entry.c b/src/entry.c index 075cd1e..260a4b0 100644 --- a/src/entry.c +++ b/src/entry.c @@ -307,6 +307,24 @@ void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value) { ); } +/* +unsigned int _start(int argc, char **argv) { + if (OSGetTitleID() == 0x000500101004A200 || // mii maker eur + OSGetTitleID() == 0x000500101004A100 || // mii maker usa + OSGetTitleID() == 0x000500101004A000) { // mii maker jpn + // load hbl + return EXIT_SUCCESS; + } + // load real application + return EXIT_RELAUNCH_ON_LOAD; +} + */ +const unsigned char homebrew_stub[] = + {0x94, 0x21, 0xff, 0xf8, 0x7c, 0x08, 0x02, 0xa6, 0x90, 0x01, 0x00, 0x0c, 0x48, 0x81, 0xd5, 0xc1, 0x6c, 0x69, 0x00, 0x05, 0x2c, 0x09, 0x00, 0x10, 0x40, 0x82, 0x00, 0x10, 0x6c, 0x89, 0xef, 0xfb, + 0x2c, 0x09, 0xa2, 0x00, 0x41, 0x82, 0x00, 0x3c, 0x48, 0x81, 0xd5, 0xa5, 0x6c, 0x69, 0x00, 0x05, 0x2c, 0x09, 0x00, 0x10, 0x40, 0x82, 0x00, 0x10, 0x6c, 0x89, 0xef, 0xfb, 0x2c, 0x09, 0xa1, 0x00, + 0x41, 0x82, 0x00, 0x20, 0x48, 0x81, 0xd5, 0x89, 0x6c, 0x69, 0x00, 0x05, 0x2c, 0x09, 0x00, 0x10, 0x40, 0x82, 0x00, 0x24, 0x6c, 0x89, 0xef, 0xfb, 0x2c, 0x09, 0xa0, 0x00, 0x40, 0x82, 0x00, 0x18, + 0x38, 0x60, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0c, 0x38, 0x21, 0x00, 0x08, 0x7c, 0x08, 0x03, 0xa6, 0x4e, 0x80, 0x00, 0x20, 0x38, 0x60, 0xff, 0xfd, 0x4b, 0xff, 0xff, 0xec}; + /* ****************************************************************** */ /* INSTALL PATCHES */ /* All OS specific stuff is done here */ @@ -324,6 +342,12 @@ static void InstallPatches(private_data_t *private_data) { private_data->memcpy((void*)&ELF_DATA_ADDR, &bufferU32, sizeof(bufferU32)); bufferU32 = 0; private_data->memcpy((void*)&ELF_DATA_SIZE, &bufferU32, sizeof(bufferU32)); + private_data->memcpy((void*)&HBL_CHANNEL, &bufferU32, sizeof(bufferU32)); + + // If we install the sd_loader but don't have any homebrew loaded some applications won't start. + // We load a stub that just opens the real app and opens the hbl when opening the mii maker. + private_data->memcpy((void *) 0x00802000, homebrew_stub, sizeof(homebrew_stub)); + MAIN_ENTRY_ADDR = 0x00802000; osSpecificFunctions.addr_OSDynLoad_Acquire = (unsigned int)OSDynLoad_Acquire; osSpecificFunctions.addr_OSDynLoad_FindExport = (unsigned int)OSDynLoad_FindExport;