From 697bc74535c8150279fc82189561757f85fa37b2 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 12 Apr 2016 00:56:41 +0200 Subject: [PATCH] Added tentative N3DS clock speed/L2 cache patch by @TuxSH. --- injector/source/patcher.c | 26 +++++++++++++++++++++++++- source/config.c | 5 +++-- source/firm.c | 6 +++--- 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/injector/source/patcher.c b/injector/source/patcher.c index 122fa18..5199c64 100644 --- a/injector/source/patcher.c +++ b/injector/source/patcher.c @@ -111,6 +111,7 @@ static int loadConfig() { ret = IFile_Read(&file, &total, &config, 3); IFile_Close(&file); + if(R_SUCCEEDED(ret)) config |= 1 << 24; } return ret; @@ -205,7 +206,7 @@ void patchCode(u64 progId, u8 *code, u32 size) case 0x0004001000027000LL: // KOR MSET case 0x0004001000028000LL: // TWN MSET { - if(R_SUCCEEDED(loadConfig()) && ((config >> 4) & 1)) + if(R_SUCCEEDED(loadConfig()) && ((config >> 6) & 1)) { static const u16 verPattern[] = u"Ver."; const u32 currentNand = ((config >> 16) & 3); @@ -278,5 +279,28 @@ void patchCode(u64 progId, u8 *code, u32 size) break; } + + case 0x0004013020002202LL: // N3DS PTM + { + if(R_SUCCEEDED(loadConfig()) && ((config >> 4) & 1)) + { + static const u8 configN3dsCpuPattern[] = { + 0x02, 0x98, 0x01, 0x79, 0x1C + }; + static const u8 configN3dsCpuPatch[] = { + 0x02, 0x98, 0x03, 0x21 + }; + + //Disable SecureInfo signature check + patchMemory(code, size, + configN3dsCpuPattern, + sizeof(configN3dsCpuPattern), 0, + configN3dsCpuPatch, + sizeof(configN3dsCpuPatch), 1 + ); + } + + break; + } } } \ No newline at end of file diff --git a/source/config.c b/source/config.c index a98e83e..9cf57c0 100644 --- a/source/config.c +++ b/source/config.c @@ -24,10 +24,11 @@ void configureCFW(const char *configPath) "( ) Updated SysNAND mode (A9LH-only)", "( ) Force A9LH detection", "( ) Use second EmuNAND as default", + "( ) Force max N3DS clock speed and L2 cache", + "( ) Use developer UNITINFO", "( ) Show current NAND in System Settings", "( ) Show GBA boot screen in patched AGB_FIRM", - "( ) Enable splash screen with no screen-init", - "( ) Use developer UNITINFO" }; + "( ) Enable splash screen with no screen-init" }; u32 optionsAmount = sizeof(optionsText) / sizeof(char *); diff --git a/source/firm.c b/source/firm.c index a21c280..c32403f 100755 --- a/source/firm.c +++ b/source/firm.c @@ -142,7 +142,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(6, 1)) loadSplash(); + if(PDN_GPU_CNT != 1 || CONFIG(8, 1)) loadSplash(); //Determine if we need to boot an emuNAND or sysNAND nandType = (pressed & BUTTON_L1) ? autoBootSys : ((pressed & BUTTON_R1) ? updatedSys : !autoBootSys); @@ -271,7 +271,7 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhInstalle *(u16 *)sigOffset2 = sigPatch[0]; *((u16 *)sigOffset2 + 1) = sigPatch[1]; - if(CONFIG(7, 1)) + if(CONFIG(5, 1)) { //Apply UNITINFO patch u32 unitInfoOffset; @@ -385,7 +385,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(5, 1)); + u32 numPatches = firmType == 1 ? (sizeof(twlPatches) / sizeof(patchData)) : (sizeof(agbPatches) / sizeof(patchData) - !CONFIG(7, 1)); const patchData *patches = firmType == 1 ? twlPatches : agbPatches; //Patch