Skip to content

Commit

Permalink
Fix launching various applications such as the Amiibo Setting when no…
Browse files Browse the repository at this point in the history
…t running the homebrew launcher before.
  • Loading branch information
Maschell committed Jan 5, 2022
1 parent a3d477f commit 8da9113
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand Down

0 comments on commit 8da9113

Please sign in to comment.