Was looking at arm9loaderhax source code, and on the stage2 payload I found the code of which loads the arm9loaderhax.bin file into memory, and then jumps into it. Thing is, load a hardcoded binary if the SD is not present or arm9loaderhax.bin is not found. I have a code for this, but I don't want to risk my console testing it.
Code:
/* delebile's version of a9lh */
/* main.c of stage2 payload */
/* only the part that loads a9lh.bin*/
#include "HardcodedBinary.h"
// ...
void loadHarcodedBinary() // call if SD mount failed or a9lh.bin not found
{
ownArm11();
clearScreen();
screenInit();
// HC_PAYLOAD_ADDRESS
// HC_PAYLOAD
// HC_PAYLOAD_SIZE
// defined on HardcodedBinary.h
memcpy(HC_PAYLOAD_ADDRESS, HC_PAYLOAD, HC_PAYLOAD_SIZE)
((void (*)())HC_PAYLOAD_ADDRESS)();
}
int main()
{
// ...
FATFS fs;
FIL payload;
unsigned int br;
f_mount(&fs, "0:", 0);
if (FS == NULL)
{
loadHardcodedBinary();
}
if(f_open(&payload, "arm9loaderhax.bin", FA_READ | FA_OPEN_EXISTING) == FR_OK)
{
ownArm11();
clearScreen();
screenInit();
f_read(&payload, (void*)PAYLOAD_ADDRESS, PAYLOAD_SIZE, &br);
((void (*)())PAYLOAD_ADDRESS)();
}
else
{
loadHardcodedBinary();
}
// ...
}
Last edited by Pokéidiot,