Slightly improved the reboot patch, added emuNAND patch improvements from CakesFW, made the emuNAND patch completely version-independent
Should work as-is with future firmwares!
This commit is contained in:
@@ -62,4 +62,12 @@ void getMPU(void *pos, u32 *off, u32 size){
|
||||
const unsigned char pattern[] = {0x03, 0x00, 0x24, 0x00};
|
||||
|
||||
*off = (u32)memsearch(pos, pattern, size, 4);
|
||||
}
|
||||
|
||||
void getEmuCode(void *pos, u32 *off, u32 size){
|
||||
u8 *proc9 = (u8 *)memsearch(pos, "ess9", size, 4);
|
||||
const unsigned char pattern[] = {0x00, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
//Looking for the last spot before Process9
|
||||
*off = (u32)memsearch(pos, pattern, size - (size - (u32)(proc9 - (u8 *)pos)), 4) + 0xD;
|
||||
}
|
||||
@@ -13,4 +13,5 @@
|
||||
void getEmunandSect(u32 *off, u32 *head, u32 emuNAND);
|
||||
void getSDMMC(void *pos, u32 *off, u32 size);
|
||||
void getEmuRW(void *pos, u32 size, u32 *readOff, u32 *writeOff);
|
||||
void getMPU(void *pos, u32 *off, u32 size);
|
||||
void getMPU(void *pos, u32 *off, u32 size);
|
||||
void getEmuCode(void *pos, u32 *off, u32 size);
|
||||
@@ -150,10 +150,7 @@ static u32 loadEmu(void){
|
||||
const char path[] = "/aurei/emunand/emunand.bin";
|
||||
u32 size = fileSize(path);
|
||||
if(!size) return 0;
|
||||
if(!console || !mode) nandRedir[5] = 0xA4;
|
||||
//Find offset for emuNAND code from the offset in nandRedir
|
||||
emuCodeOffset = *(u32 *)(nandRedir + 4) - (u32)section[2].address +
|
||||
section[2].offset + (u32)firmLocation;
|
||||
getEmuCode(firmLocation, &emuCodeOffset, firmSize);
|
||||
fileRead((u8 *)emuCodeOffset, path, size);
|
||||
|
||||
//Find and patch emunand related offsets
|
||||
@@ -171,11 +168,9 @@ static u32 loadEmu(void){
|
||||
//No emuNAND detected
|
||||
if(!*pos_header) return 0;
|
||||
|
||||
//Patch emuNAND code in memory for O3DS and 9.0 N3DS
|
||||
if(!console || !mode){
|
||||
void *pos_instr = memsearch((void *)emuCodeOffset, "\xA6\x01\x08\x30", size, 4);
|
||||
memcpy(pos_instr, emuInstr, sizeof(emuInstr));
|
||||
}
|
||||
//Calculate offset for the hooks
|
||||
*(u32 *)(nandRedir + 4) = emuCodeOffset - (u32)firmLocation -
|
||||
section[2].offset + (u32)section[2].address;
|
||||
|
||||
//Add emunand hooks
|
||||
memcpy((void *)emuRead, nandRedir, sizeof(nandRedir));
|
||||
|
||||
@@ -17,7 +17,8 @@ const u8 mpu[0x2C] = { //MPU shit
|
||||
0x01, 0x01, 0x01, 0x01, 0x03, 0x06, 0x1C, 0x00, 0x00, 0x00, 0x02, 0x08
|
||||
};
|
||||
|
||||
u8 nandRedir[0x08] = {0x00, 0x4C, 0xA0, 0x47, 0xC0, 0xA5, 0x01, 0x08}; //Branch to emunand function
|
||||
//Branch to emunand function. To be filled in
|
||||
u8 nandRedir[0x08] = {0x00, 0x4C, 0xA0, 0x47, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
const u8 sigPat1[2] = {0x00, 0x20};
|
||||
const u8 sigPat2[4] = {0x00, 0x20, 0x70, 0x47};
|
||||
|
||||
Reference in New Issue
Block a user