Setting "Dev. options" to "None" now disables the exception handlers and related patches (again)
Port the UNITINFO patch to TWL/AGB (although it doesn't make debugging information display on fatal errors) and SAFE firms. On dev units this patch will set it to its "retail" value (i.e. 0)
This commit is contained in:
parent
7f672fb417
commit
2a84911d3b
@ -564,7 +564,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
|
||||
case 0x0004003000008A02LL: // ErrDisp
|
||||
{
|
||||
if(MULTICONFIG(2) == 1)
|
||||
if(MULTICONFIG(2) == 0)
|
||||
{
|
||||
static const u8 unitinfoCheckPattern1[] = {
|
||||
0x14, 0x00, 0xD0, 0xE5, 0xDB, 0x9A, 0x9F, 0xED
|
||||
|
@ -36,7 +36,7 @@ void configureCFW(const char *configPath)
|
||||
|
||||
const char *multiOptionsText[] = { "Screen brightness: 4( ) 3( ) 2( ) 1( )",
|
||||
"New 3DS CPU: Off( ) Clock( ) L2( ) Clock+L2( )",
|
||||
"Dev. features: None( ) ErrDisp( ) UNITINFO( )" };
|
||||
"Dev. features: ErrDisp( ) UNITINFO( ) None( )" };
|
||||
|
||||
const char *singleOptionsText[] = { "( ) Autoboot SysNAND",
|
||||
"( ) Use SysNAND FIRM if booting with R (A9LH)",
|
||||
@ -55,7 +55,7 @@ void configureCFW(const char *configPath)
|
||||
} multiOptions[] = {
|
||||
{ .posXs = {21, 26, 31, 36} },
|
||||
{ .posXs = {17, 26, 32, 44} },
|
||||
{ .posXs = {20, 31, 43, 0} }
|
||||
{ .posXs = {23, 35, 43, 0} }
|
||||
};
|
||||
|
||||
//Calculate the amount of the various kinds of options and pre-select the first single one
|
||||
|
@ -74,9 +74,12 @@ void main(void)
|
||||
//Attempt to read the configuration file
|
||||
needConfig = fileRead(&config, configPath) ? MODIFY_CONFIGURATION : CREATE_CONFIGURATION;
|
||||
|
||||
detectAndProcessExceptionDumps();
|
||||
installArm9Handlers();
|
||||
|
||||
if(DEV_OPTIONS != 2)
|
||||
{
|
||||
detectAndProcessExceptionDumps();
|
||||
installArm9Handlers();
|
||||
}
|
||||
|
||||
//Determine if this is a firmlaunch boot
|
||||
if(launchedFirmTIDLow[5] != 0)
|
||||
{
|
||||
@ -316,28 +319,31 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
|
||||
}
|
||||
|
||||
//Apply UNITINFO patch
|
||||
if(DEV_OPTIONS == 2) patchUnitInfoValueSet(arm9Section, section[2].size);
|
||||
|
||||
//Install arm11 exception handlers
|
||||
u32 stackAddress, codeSetOffset;
|
||||
u32 *exceptionsPage = getInfoForArm11ExceptionHandlers(arm11Section1, section[1].size, &stackAddress, &codeSetOffset);
|
||||
installArm11Handlers(exceptionsPage, stackAddress, codeSetOffset);
|
||||
|
||||
//Kernel9/Process9 debugging
|
||||
patchExceptionHandlersInstall(arm9Section, section[2].size);
|
||||
patchSvcBreak9(arm9Section, section[2].size, (u32)(section[2].address));
|
||||
patchKernel9Panic(arm9Section, section[2].size, NATIVE_FIRM);
|
||||
|
||||
//Stub svcBreak11 with "bkpt 65535"
|
||||
patchSvcBreak11(arm11Section1, section[1].size);
|
||||
//Stub kernel11panic with "bkpt 65534"
|
||||
patchKernel11Panic(arm11Section1, section[1].size);
|
||||
if(DEV_OPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[2].size, NATIVE_FIRM);
|
||||
|
||||
if(DEV_OPTIONS != 2)
|
||||
{
|
||||
//Install arm11 exception handlers
|
||||
u32 stackAddress, codeSetOffset;
|
||||
u32 *exceptionsPage = getInfoForArm11ExceptionHandlers(arm11Section1, section[1].size, &stackAddress, &codeSetOffset);
|
||||
installArm11Handlers(exceptionsPage, stackAddress, codeSetOffset);
|
||||
|
||||
//Kernel9/Process9 debugging
|
||||
patchExceptionHandlersInstall(arm9Section, section[2].size);
|
||||
patchSvcBreak9(arm9Section, section[2].size, (u32)(section[2].address));
|
||||
patchKernel9Panic(arm9Section, section[2].size, NATIVE_FIRM);
|
||||
|
||||
//Stub svcBreak11 with "bkpt 65535"
|
||||
patchSvcBreak11(arm11Section1, section[1].size);
|
||||
//Stub kernel11panic with "bkpt 65534"
|
||||
patchKernel11Panic(arm11Section1, section[1].size);
|
||||
}
|
||||
|
||||
if(CONFIG(8))
|
||||
{
|
||||
patchArm11SvcAccessChecks(arm11Section1, section[1].size);
|
||||
patchK11ModuleChecks(arm11Section1, section[1].size);
|
||||
patchP9AccessChecks(arm9Section, section[2].size);
|
||||
patchP9AccessChecks(process9Offset, process9Size);
|
||||
}
|
||||
|
||||
implementSvcGetCFWInfo((u8 *)firm + section[1].offset, section[1].size);
|
||||
@ -354,12 +360,20 @@ static inline void patchLegacyFirm(FirmwareType firmType)
|
||||
firm->arm9Entry = (u8 *)0x801301C;
|
||||
}
|
||||
|
||||
//Kernel9/Process9 debugging
|
||||
patchExceptionHandlersInstall(arm9Section, section[3].size);
|
||||
patchSvcBreak9(arm9Section, section[3].size, (u32)(section[3].address));
|
||||
patchKernel9Panic(arm9Section, section[3].size, firmType);
|
||||
//Apply UNITINFO patch
|
||||
if(DEV_OPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[3].size, firmType);
|
||||
|
||||
if(DEV_OPTIONS != 2)
|
||||
{
|
||||
//Kernel9/Process9 debugging
|
||||
patchExceptionHandlersInstall(arm9Section, section[3].size);
|
||||
patchSvcBreak9(arm9Section, section[3].size, (u32)(section[3].address));
|
||||
patchKernel9Panic(arm9Section, section[3].size, firmType);
|
||||
}
|
||||
|
||||
applyLegacyFirmPatches((u8 *)firm, firmType);
|
||||
fileWrite(arm9Section, "/luma/twl_arm9sec.bin", section[3].size);
|
||||
|
||||
}
|
||||
|
||||
static inline void patchSafeFirm(void)
|
||||
@ -375,10 +389,16 @@ static inline void patchSafeFirm(void)
|
||||
patchFirmWrites(arm9Section, section[2].size);
|
||||
}
|
||||
else patchFirmWriteSafe(arm9Section, section[2].size);
|
||||
|
||||
//Apply UNITINFO patch
|
||||
if(DEV_OPTIONS == 1) patchUnitInfoValueSet(arm9Section, section[2].size, SAFE_FIRM);
|
||||
|
||||
//Kernel9/Process9 debugging
|
||||
patchExceptionHandlersInstall(arm9Section, section[2].size);
|
||||
patchSvcBreak9(arm9Section, section[2].size, (u32)(section[2].address));
|
||||
if(DEV_OPTIONS != 2)
|
||||
{
|
||||
//Kernel9/Process9 debugging
|
||||
patchExceptionHandlersInstall(arm9Section, section[2].size);
|
||||
patchSvcBreak9(arm9Section, section[2].size, (u32)(section[2].address));
|
||||
}
|
||||
}
|
||||
|
||||
static inline void copySection0AndInjectSystemModules(FirmwareType firmType)
|
||||
|
@ -295,13 +295,16 @@ void patchP9AccessChecks(u8 *pos, u32 size)
|
||||
}
|
||||
|
||||
|
||||
void patchUnitInfoValueSet(u8 *pos, u32 size)
|
||||
void patchUnitInfoValueSet(u8 *pos, u32 size, FirmwareType firmType)
|
||||
{
|
||||
//Look for UNITINFO value being set
|
||||
//Look for UNITINFO value being set during kernel sync
|
||||
const u8 pattern[] = {0x01, 0x10, 0xA0, 0x13};
|
||||
const u8 patternSafe[] = {0x00, 0x20, 0x91, 0xE2, 0x01, 0x20, 0xA0, 0x13};
|
||||
bool safe = firmType == SAFE_FIRM && !isN3DS;
|
||||
|
||||
u8 *off = memsearch(pos, pattern, size, 4);
|
||||
u8 *off = (!safe) ? memsearch(pos, pattern, size, 4) : (memsearch(pos, patternSafe, size, 8) + 4);
|
||||
|
||||
off[0] = (*(vu8 *)0x10010010 == 0) ? 1 : 0;
|
||||
off[3] = 0xE3;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ void patchKernel11Panic(u8 *pos, u32 size);
|
||||
void patchArm11SvcAccessChecks(u8 *pos, u32 size);
|
||||
void patchK11ModuleChecks(u8 *pos, u32 size);
|
||||
void patchP9AccessChecks(u8 *pos, u32 size);
|
||||
void patchUnitInfoValueSet(u8 *pos, u32 size);
|
||||
void patchUnitInfoValueSet(u8 *pos, u32 size, FirmwareType firmType);
|
||||
void reimplementSvcBackdoor(u8 *pos, u32 size);
|
||||
void implementSvcGetCFWInfo(u8 *pos, u32 size);
|
||||
void applyLegacyFirmPatches(u8 *pos, FirmwareType firmType);
|
Reference in New Issue
Block a user