Fix launching various applications such as the Amiibo Setting when not running the homebrew launcher before.

This commit is contained in:
Maschell 2022-01-05 16:16:54 +01:00
parent 99e0f20f85
commit 442d1d3a27

View File

@ -119,6 +119,24 @@ void InstallHBL() {
KernelWriteU32(repl_addr, bufferU32);
}
/*
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 */
@ -138,6 +156,11 @@ static void InstallPatches() {
memcpy((void *) &ELF_DATA_SIZE, &bufferU32, sizeof(bufferU32));
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.
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;