From 2424865fa109610b81cf9babe351addd72f86cd7 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Sat, 28 May 2016 16:13:22 +0200 Subject: [PATCH] Make developer features multi-choice, since modifying UNITINFO prevents accessing eShop on retail consoles (you can now choose "ErrDisp" for a less aggressive patch) --- injector/source/patcher.c | 34 ++++++++++++++++++++++++++++++++++ source/config.c | 11 ++++++----- source/config.h | 2 +- source/firm.c | 2 +- 4 files changed, 42 insertions(+), 7 deletions(-) diff --git a/injector/source/patcher.c b/injector/source/patcher.c index b78ddf8..7d6d621 100644 --- a/injector/source/patcher.c +++ b/injector/source/patcher.c @@ -514,6 +514,40 @@ void patchCode(u64 progId, u8 *code, u32 size) break; } + + + case 0x0004003000008A02LL: // ErrDisp + { + if(MULTICONFIG(2) == 1) + { + static const u8 unitinfoCheckPattern1[] = { + 0x14, 0x00, 0xD0, 0xE5, 0xDB, 0x9A, 0x9F, 0xED + }; + + static const u8 unitinfoCheckPattern2[] = { + 0x14, 0x00, 0xD0, 0xE5, 0x01, 0x00, 0x10, 0xE3 + } ; + + static const u8 unitinfoCheckPatch[] = { + 0x00, 0x00, 0xA0, 0xE3 + } ; + + patchMemory(code, size, + unitinfoCheckPattern1, + sizeof(unitinfoCheckPattern1), 0, + unitinfoCheckPatch, + sizeof(unitinfoCheckPatch), 1 + ); + + patchMemory(code, size, + unitinfoCheckPattern2, + sizeof(unitinfoCheckPattern2), 0, + unitinfoCheckPatch, + sizeof(unitinfoCheckPatch), 3 + ); + } + break; + } default: if(CONFIG(4)) diff --git a/source/config.c b/source/config.c index d78f44c..b84c6c6 100644 --- a/source/config.c +++ b/source/config.c @@ -18,7 +18,8 @@ void configureCFW(const char *configPath) drawString("Press A to select, START to save", 10, 30, COLOR_WHITE); const char *multiOptionsText[] = { "Screen-init brightness: 4( ) 3( ) 2( ) 1( )", - "New 3DS CPU: Off( ) Clock( ) L2( ) Clock+L2( )" }; + "New 3DS CPU: Off( ) Clock( ) L2( ) Clock+L2( )", + "Dev. features: None( ) ErrDisp( ) UNITINFO( )" }; const char *singleOptionsText[] = { "( ) Autoboot SysNAND", "( ) SysNAND is updated (A9LH-only)", @@ -27,8 +28,7 @@ void configureCFW(const char *configPath) "( ) Enable region/language emulation", "( ) Show current NAND in System Settings", "( ) Show GBA boot screen in patched AGB_FIRM", - "( ) Enable splash screen with no screen-init", - "( ) Enable developer features" }; + "( ) Enable splash screen with no screen-init" }; struct multiOption { int posXs[4]; @@ -36,7 +36,8 @@ void configureCFW(const char *configPath) u32 enabled; } multiOptions[] = { { .posXs = {26, 31, 36, 41} }, - { .posXs = {17, 26, 32, 44} } + { .posXs = {17, 26, 32, 44} }, + { .posXs = {20, 31, 43, 0} } }; //Calculate the amount of the various kinds of options and pre-select the first single one @@ -145,7 +146,7 @@ void configureCFW(const char *configPath) { u32 oldEnabled = multiOptions[selectedOption].enabled; drawCharacter(selected, 10 + multiOptions[selectedOption].posXs[oldEnabled] * SPACING_X, multiOptions[selectedOption].posY, COLOR_BLACK); - multiOptions[selectedOption].enabled = oldEnabled == 3 ? 0 : oldEnabled + 1; + multiOptions[selectedOption].enabled = (oldEnabled == 3 || !multiOptions[selectedOption].posXs[oldEnabled + 1]) ? 0 : oldEnabled + 1; } else { diff --git a/source/config.h b/source/config.h index 7c94e15..49122af 100644 --- a/source/config.h +++ b/source/config.h @@ -10,7 +10,7 @@ #define MULTICONFIG(a) ((config >> (a * 2 + 6)) & 3) #define BOOTCONFIG(a, b) ((config >> a) & b) -#define DEVMODE CONFIG(8) +#define DEVMODE MULTICONFIG(2) extern u32 config; diff --git a/source/firm.c b/source/firm.c index b1f98c7..06e690c 100755 --- a/source/firm.c +++ b/source/firm.c @@ -330,7 +330,7 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhMode) if(DEVMODE) { //Apply UNITINFO patch - patchUnitInfoValueSet(arm9Section, section[2].size); + if(DEVMODE == 2) patchUnitInfoValueSet(arm9Section, section[2].size); //Make FCRAM (and VRAM as a side effect) globally executable from arm11 kernel patchKernelFCRAMAndVRAMMappingPermissions(arm11Section1, section[1].size);