From 121792bebeaa9500889c52cb1feae891d57e0e2a Mon Sep 17 00:00:00 2001 From: Aurora Date: Thu, 13 Oct 2016 15:19:37 +0200 Subject: [PATCH] Fix A9LH patches not being applied after firmlaunch --- source/firm.c | 6 +++--- source/firm.h | 2 +- source/main.c | 7 +++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/firm.c b/source/firm.c index 34bb8d8..51f7cec 100755 --- a/source/firm.c +++ b/source/firm.c @@ -109,7 +109,7 @@ u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStora return firmVersion; } -u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isSdMode, u32 devMode) +u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lhInstalled, bool isSdMode, u32 devMode) { u8 *arm9Section = (u8 *)firm + firm->section[2].offset, *arm11Section1 = (u8 *)firm + firm->section[1].offset; @@ -145,7 +145,7 @@ u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, boo if(nandType != FIRMWARE_SYSNAND) ret += patchEmuNand(arm9Section, firm->section[2].size, process9Offset, process9Size, emuHeader, firm->section[2].address); //Apply FIRM0/1 writes patches on sysNAND to protect A9LH - else if(ISA9LH || (ISFIRMLAUNCH && BOOTCFG_A9LH != 0)) ret += patchFirmWrites(process9Offset, process9Size); + else if(isA9lhInstalled) ret += patchFirmWrites(process9Offset, process9Size); //Apply firmlaunch patches ret += patchFirmlaunches(process9Offset, process9Size, process9MemAddr, isSdMode); @@ -165,7 +165,7 @@ u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, boo //Apply UNITINFO patch if(devMode == 2) ret += patchUnitInfoValueSet(arm9Section, firm->section[2].size); - if(devMode != 0 && ISA9LH) + if(devMode != 0 && isA9lhInstalled) { //ARM11 exception handlers u32 codeSetOffset, diff --git a/source/firm.h b/source/firm.h index e4192e7..97dd422 100644 --- a/source/firm.h +++ b/source/firm.h @@ -25,7 +25,7 @@ #include "types.h" u32 loadFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadFromStorage, bool isSdMode); -u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isSdMode, u32 devMode); +u32 patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32 emuHeader, bool isA9lhInstalled, bool isSdMode, u32 devMode); u32 patchTwlFirm(u32 firmVersion, u32 devMode); u32 patchAgbFirm(u32 devMode); u32 patch1x2xNativeAndSafeFirm(u32 devMode); diff --git a/source/main.c b/source/main.c index 992820e..0db90b0 100644 --- a/source/main.c +++ b/source/main.c @@ -36,6 +36,7 @@ extern FirmwareSource firmSource; void main(void) { + bool isA9lhInstalled; u32 configTemp, emuHeader; FirmwareType firmType; @@ -65,6 +66,7 @@ void main(void) nandType = (FirmwareSource)BOOTCFG_NAND; firmSource = (FirmwareSource)BOOTCFG_FIRM; + isA9lhInstalled = BOOTCFG_A9LH != 0; } else { @@ -75,6 +77,7 @@ void main(void) } firmType = NATIVE_FIRM; + isA9lhInstalled = ISA9LH; //Get pressed buttons u32 pressed = HID_PAD; @@ -231,11 +234,11 @@ void main(void) switch(firmType) { case NATIVE_FIRM: - res = patchNativeFirm(firmVersion, nandType, emuHeader, isSdMode, devMode); + res = patchNativeFirm(firmVersion, nandType, emuHeader, isA9lhInstalled, isSdMode, devMode); break; case SAFE_FIRM: case NATIVE_FIRM1X2X: - res = ISA9LH ? patch1x2xNativeAndSafeFirm(devMode) : 0; + res = isA9lhInstalled ? patch1x2xNativeAndSafeFirm(devMode) : 0; break; case TWL_FIRM: res = patchTwlFirm(firmVersion, devMode);