From efd08ff731001fb70be1d8aa48b06fc7c10cba7c Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 26 Apr 2016 22:00:29 +0200 Subject: [PATCH] Revert "Move the UNITINFO patch to the developer version" This reverts commit f9a1f1a79bfe6582e8686d33061e7d840ce72ad7. --- injector/source/patcher.c | 2 +- source/config.c | 1 + source/firm.c | 11 +++++++++-- source/patches.c | 10 ++++++++++ source/patches.h | 2 ++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/injector/source/patcher.c b/injector/source/patcher.c index 4b55b63..b45a3e2 100644 --- a/injector/source/patcher.c +++ b/injector/source/patcher.c @@ -393,7 +393,7 @@ void patchCode(u64 progId, u8 *code, u32 size) case 0x0004001000027000LL: // KOR MSET case 0x0004001000028000LL: // TWN MSET { - if(CONFIG(5)) + if(CONFIG(6)) { static const u16 verPattern[] = u"Ver."; const u32 currentNand = BOOTCONFIG(0, 3); diff --git a/source/config.c b/source/config.c index 081b9d4..939bc64 100644 --- a/source/config.c +++ b/source/config.c @@ -24,6 +24,7 @@ void configureCFW(const char *configPath) "( ) Force A9LH detection", "( ) Use second EmuNAND as default", "( ) Enable region/language emulation", + "( ) Use developer UNITINFO", "( ) Show current NAND in System Settings", "( ) Show GBA boot screen in patched AGB_FIRM", "( ) Enable splash screen with no screen-init" }; diff --git a/source/firm.c b/source/firm.c index 1620be5..12d8bfa 100755 --- a/source/firm.c +++ b/source/firm.c @@ -136,7 +136,7 @@ void main(void) configureCFW(configPath); //If screens are inited or the corresponding option is set, load splash screen - if(PDN_GPU_CNT != 1 || CONFIG(7)) loadSplash(); + if(PDN_GPU_CNT != 1 || CONFIG(8)) loadSplash(); u32 autoBootSys = CONFIG(0); @@ -255,6 +255,13 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhInstalle *(u16 *)sigOffset2 = sigPatch[0]; *((u16 *)sigOffset2 + 1) = sigPatch[1]; + if(CONFIG(5)) + { + //Apply UNITINFO patch + u8 *unitInfoOffset = getUnitInfoValueSet(arm9Section, section[2].size); + *unitInfoOffset = unitInfoPatch; + } + //Replace the FIRM loader with the injector injectLoader(); } @@ -359,7 +366,7 @@ static inline void patchTwlAgbFirm(u32 firmType) /* Calculate the amount of patches to apply. Only count the boot screen patch for AGB_FIRM if the matching option was enabled (keep it as last) */ u32 numPatches = firmType == 1 ? (sizeof(twlPatches) / sizeof(patchData)) : - (sizeof(agbPatches) / sizeof(patchData) - !CONFIG(6)); + (sizeof(agbPatches) / sizeof(patchData) - !CONFIG(7)); const patchData *patches = firmType == 1 ? twlPatches : agbPatches; //Patch diff --git a/source/patches.c b/source/patches.c index 94897c0..109e03b 100644 --- a/source/patches.c +++ b/source/patches.c @@ -15,6 +15,8 @@ const u16 nandRedir[2] = {0x4C00, 0x47A0}, sigPatch[2] = {0x2000, 0x4770}, writeBlock[2] = {0x2000, 0x46C0}; +const u8 unitInfoPatch = 0xE3; + /************************************************** * Functions **************************************************/ @@ -63,6 +65,14 @@ u16 *getFirmWrite(u8 *pos, u32 size) return (u16 *)memsearch(off - 0x100, pattern, 0x100, 4); } +u8 *getUnitInfoValueSet(u8 *pos, u32 size) +{ + //Look for UNITINFO value being set + const u8 pattern[] = {0x01, 0x10, 0xA0, 0x13}; + + return memsearch(pos, pattern, size, 4) + 3; +} + void *getLoader(u8 *pos, u32 size, u32 *loaderSize) { u8 *const off = memsearch(pos, "loade", size, 5); diff --git a/source/patches.h b/source/patches.h index 6e48a42..1e2f525 100644 --- a/source/patches.h +++ b/source/patches.h @@ -13,6 +13,7 @@ const u32 mpuPatch[3]; const u16 nandRedir[2], sigPatch[2], writeBlock[2]; +const u8 unitInfoPatch; /************************************************** * Functions @@ -22,4 +23,5 @@ void getSigChecks(u8 *pos, u32 size, u32 *off, u32 *off2); void *getReboot(u8 *pos, u32 size); u32 getfOpen(u8 *proc9Offset, void *rebootOffset); u16 *getFirmWrite(u8 *pos, u32 size); +u8 *getUnitInfoValueSet(u8 *pos, u32 size); void *getLoader(u8 *pos, u32 size, u32 *loaderSize); \ No newline at end of file