diff --git a/source/crypto.c b/source/crypto.c index 4a8d297..4ff21a3 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -387,6 +387,11 @@ void decryptExeFs(u8 *inbuf) //ARM9Loader replacement void arm9Loader(u8 *arm9Section) { +#ifdef DEV + //Check if FIRM is already decrypted + if(*(u32 *)(arm9Section + 0x800) == 0x47704770) return; +#endif + //Determine the arm9loader version u32 a9lVersion; switch(arm9Section[0x53]) diff --git a/source/firm.c b/source/firm.c index 58dca4b..9c30231 100755 --- a/source/firm.c +++ b/source/firm.c @@ -584,11 +584,11 @@ static inline void launchFirm(FirmwareType firmType) //Determine the ARM11 entry to use vu32 *arm11; - if(isFirmlaunch) arm11 = (u32 *)0x1FFFFFFC; + if(isFirmlaunch) arm11 = (vu32 *)0x1FFFFFFC; else { deinitScreens(); - arm11 = (u32 *)0x1FFFFFF8; + arm11 = (vu32 *)BRAHMA_ARM11_ENTRY; } //Set ARM11 kernel entrypoint diff --git a/source/fs.c b/source/fs.c index 83ca4fa..80b9a05 100644 --- a/source/fs.c +++ b/source/fs.c @@ -121,7 +121,7 @@ void loadPayload(u32 pressed) f_closedir(&dir); - if(result == FR_OK && info.fname[0]) + if(result == FR_OK && info.fname[0] != 0) { u32 *loaderAddress = (u32 *)0x24FFFF00; u8 *payloadAddress = (u8 *)0x24F00000; @@ -166,7 +166,7 @@ u32 firmRead(void *dest, u32 firmType) u32 firmVersion = 0xFFFFFFFF; //Parse the target directory - while(f_readdir(&dir, &info) == FR_OK && info.fname[0]) + while(f_readdir(&dir, &info) == FR_OK && info.fname[0] != 0) { //Not a cxi if(info.fname[9] != 'a') continue; @@ -203,7 +203,7 @@ void findDumpFile(const char *path, char *fileName) FILINFO info; u32 n = 0; - while(f_findfirst(&dir, &info, path, fileName) == FR_OK && info.fname[0]) + while(f_findfirst(&dir, &info, path, fileName) == FR_OK && info.fname[0] != 0) { u32 i = 18, tmp = ++n; diff --git a/source/screen.c b/source/screen.c index d0e8358..7a22638 100644 --- a/source/screen.c +++ b/source/screen.c @@ -32,7 +32,7 @@ #include "draw.h" #include "i2c.h" -vu32 *const arm11Entry = (vu32 *)0x1FFFFFF8; +vu32 *const arm11Entry = (vu32 *)BRAHMA_ARM11_ENTRY; static const u32 brightness[4] = {0x5F, 0x4C, 0x39, 0x26}; void __attribute__((naked)) arm11Stub(void) diff --git a/source/types.h b/source/types.h index 2434af9..892bef4 100644 --- a/source/types.h +++ b/source/types.h @@ -37,6 +37,8 @@ typedef volatile u32 vu32; typedef volatile u64 vu64; //Used by multiple files +#define BRAHMA_ARM11_ENTRY 0x1FFFFFF8 + typedef enum FirmwareSource { FIRMWARE_SYSNAND = 0,