From 2cbaf39fd5289015fc553452e09ff1004af44eb3 Mon Sep 17 00:00:00 2001 From: Aurora Date: Thu, 22 Sep 2016 22:35:17 +0200 Subject: [PATCH] Make error() reboot if in a firmlaunch environment, improve errors --- source/crypto.c | 2 +- source/firm.c | 19 +++++++------------ source/utils.c | 2 ++ 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/source/crypto.c b/source/crypto.c index 95e82640..cc1a5409 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -486,8 +486,8 @@ void computePinHash(u8 *outbuf, const u8 *inbuf) if(!didShaHashBackup) { - didShaHashBackup = true; memcpy(shaHashBackup, (void *)REG_SHA_HASH, sizeof(shaHashBackup)); + didShaHashBackup = true; } sdmmc_get_cid(1, (u32 *)cid); diff --git a/source/firm.c b/source/firm.c index 2303ae2c..1eb3f641 100755 --- a/source/firm.c +++ b/source/firm.c @@ -295,9 +295,9 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource, bo { //We can't boot < 3.x EmuNANDs if(firmSource != FIRMWARE_SYSNAND) - error("An old unsupported EmuNAND has been detected.\nLuma3DS is unable to boot it"); + error("An old unsupported EmuNAND has been detected.\nLuma3DS is unable to boot it."); - if(BOOTCFG_SAFEMODE != 0) error("SAFE_MODE is not supported on 1.x/2.x FIRM"); + if(BOOTCFG_SAFEMODE != 0) error("SAFE_MODE is not supported on 1.x/2.x FIRM."); *firmType = NATIVE_FIRM1X2X; } @@ -312,23 +312,18 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource, bo if(firmSize > 0) { - bool isValidFirm = true; - if(memcmp(firm, "FIRM", 4) != 0) { u8 cetk[0xA50]; if(fileRead(cetk, *firmType == NATIVE_FIRM1X2X ? cetkFiles[0] : cetkFiles[(u32)*firmType], sizeof(cetk)) == sizeof(cetk)) decryptNusFirm(cetk, (u8 *)firm, firmSize); - else isValidFirm = false; + else error("The firmware.bin in /luma is encrypted\nor corrupted."); } - //Check that the SD FIRM is decrypted and is right for the console from the ARM9 section address - if(isValidFirm && (section[3].offset ? section[3].address : section[2].address) != (isN3DS ? (u8 *)0x8006000 : (u8 *)0x8006800)) - { - if(isFirmlaunch) mcuReboot(); - error("The firmware.bin in /luma is not valid for your\nconsole, or corrupted"); - } + //Check that the SD FIRM is right for the console from the ARM9 section address + if((section[3].offset ? section[3].address : section[2].address) != (isN3DS ? (u8 *)0x8006000 : (u8 *)0x8006800)) + error("The firmware.bin in /luma is not valid for this\nconsole."); firmVersion = 0xFFFFFFFF; } @@ -336,7 +331,7 @@ static inline u32 loadFirm(FirmwareType *firmType, FirmwareSource firmSource, bo if(firmVersion != 0xFFFFFFFF) { - if(mustLoadFromSd) error("An old unsupported FIRM has been detected.\nCopy a firmware.bin in /luma to boot"); + if(mustLoadFromSd) error("An old unsupported FIRM has been detected.\nCopy a firmware.bin in /luma to boot."); decryptExeFs((u8 *)firm); } diff --git a/source/utils.c b/source/utils.c index 017fc82f..e1325b04 100644 --- a/source/utils.c +++ b/source/utils.c @@ -112,6 +112,8 @@ void chrono(u32 seconds) void error(const char *message) { + if(isFirmlaunch) mcuReboot(); + initScreens(); drawString("An error has occurred:", true, 10, 10, COLOR_RED);