diff --git a/source/config.c b/source/config.c index ee3d17f..a98e83e 100644 --- a/source/config.c +++ b/source/config.c @@ -26,7 +26,8 @@ void configureCFW(const char *configPath) "( ) Use second EmuNAND as default", "( ) Show current NAND in System Settings", "( ) Show GBA boot screen in patched AGB_FIRM", - "( ) Enable splash screen with no screen-init" }; + "( ) Enable splash screen with no screen-init", + "( ) Use developer UNITINFO" }; u32 optionsAmount = sizeof(optionsText) / sizeof(char *); @@ -146,4 +147,4 @@ void configureCFW(const char *configPath) //Reboot i2cWriteRegister(I2C_DEV_MCU, 0x20, 1 << 2); while(1); -} \ No newline at end of file +} diff --git a/source/config.h b/source/config.h index c57f3fd..9aa0838 100644 --- a/source/config.h +++ b/source/config.h @@ -13,4 +13,4 @@ extern u32 config; -void configureCFW(const char *configPath); \ No newline at end of file +void configureCFW(const char *configPath); diff --git a/source/firm.c b/source/firm.c index 82be494..c55a447 100755 --- a/source/firm.c +++ b/source/firm.c @@ -271,6 +271,15 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhInstalle *(u16 *)sigOffset2 = sigPatch[0]; *((u16 *)sigOffset2 + 1) = sigPatch[1]; + if(CONFIG(7, 1)) + { + //Apply UNITINFO patch + u32 unitInfoOffset; + + getUnitInfoValueSet(arm9Section, section[2].size, &unitInfoOffset); + *((u8*)unitInfoOffset + 3) = unitInfoPatch[0]; + } + //Replace the FIRM loader with the injector injectLoader(); } @@ -416,4 +425,4 @@ static inline void launchFirm(u32 bootType) //Final jump to arm9 kernel ((void (*)())firm->arm9Entry)(); -} \ No newline at end of file +} diff --git a/source/patches.c b/source/patches.c index b072cd4..85fafb6 100644 --- a/source/patches.c +++ b/source/patches.c @@ -19,6 +19,8 @@ const u16 sigPatch[2] = {0x2000, 0x4770}; const u16 writeBlock[2] = {0x2000, 0x46C0}; +const u8 unitInfoPatch[1] = {0xE3}; + /************************************************** * Functions **************************************************/ @@ -73,4 +75,12 @@ void getLoader(u8 *pos, u32 size, u32 *loaderOffset, u32 *loaderSize) *loaderOffset = (u32)off - 0x200; *loaderSize = *(u32 *)(off - 0xFC) * 0x200; -} \ No newline at end of file +} + +void getUnitInfoValueSet(u8 *pos, u32 size, u32 *off) +{ + //Look for UNITINFO value being set + const u8 pattern[] = {0x01, 0x10, 0xA0, 0x13}; + + *off = (u32)memsearch(pos, pattern, size, 4); +} diff --git a/source/patches.h b/source/patches.h index 08d5b32..dfa29e0 100644 --- a/source/patches.h +++ b/source/patches.h @@ -15,6 +15,7 @@ const u32 mpuPatch[3]; const u16 nandRedir[2]; const u16 sigPatch[2]; const u16 writeBlock[2]; +const u8 unitInfoPatch[1]; /************************************************** * Functions @@ -24,4 +25,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); -void getLoader(u8 *pos, u32 size, u32 *loaderOffset, u32 *loaderSize); \ No newline at end of file +void getLoader(u8 *pos, u32 size, u32 *loaderOffset, u32 *loaderSize); +void getUnitInfoValueSet(u8 *pos, u32 size, u32* off);