Virtually full support for 4.x sysNAND
(see also: previous commit)
This commit is contained in:
parent
b71dedccfc
commit
c610ec3319
@ -158,7 +158,7 @@ static void findUsefulSymbols(void)
|
||||
for(off = (u32 *)officialSVCs[0x71]; *off != 0xE2101102; off++);
|
||||
KProcessHwInfo__MapProcessMemory = (Result (*)(KProcessHwInfo *, KProcessHwInfo *, void *, void *, u32))decodeARMBranch(off - 1);
|
||||
|
||||
// On < 6.x the pattern will match but the result will be wrong
|
||||
// From 4.x to 6.x the pattern will match but the result will be wrong
|
||||
for(off = (u32 *)officialSVCs[0x72]; *off != 0xE2041102; off++);
|
||||
KProcessHwInfo__UnmapProcessMemory = (Result (*)(KProcessHwInfo *, void *, u32))decodeARMBranch(off - 1);
|
||||
|
||||
|
@ -170,8 +170,9 @@ u32 loadNintendoFirm(FirmwareType *firmType, FirmwareSource nandType, bool loadF
|
||||
*firmType = NATIVE_FIRM1X2X;
|
||||
}
|
||||
|
||||
//We can't boot a 3.x/4.x NATIVE_FIRM, load one from SD/CTRNAND
|
||||
else if(firmVersion < 0x25) mustLoadFromStorage = true;
|
||||
//We can't boot a 3.x/4.x NATIVE_FIRM EmuNAND, load one from SD/CTRNAND
|
||||
//We can't boot a 3.x NATIVE_FIRM, load one from SD/CTRNAND too
|
||||
else if(firmVersion < (nandType == FIRMWARE_SYSNAND ? 0x1D : 0x25)) mustLoadFromStorage = true;
|
||||
}
|
||||
|
||||
bool loadedFromStorage = false;
|
||||
|
@ -46,25 +46,24 @@ static Result ProcessPatchesMenu_DoPatchUnpatchSM(u32 textTotalRoundedSize)
|
||||
{
|
||||
static bool patched = false;
|
||||
static u32 *off;
|
||||
static u32 origData[7];
|
||||
static u32 origData;
|
||||
|
||||
if(patched)
|
||||
{
|
||||
memcpy(off, &origData, sizeof(origData));
|
||||
*off = origData;
|
||||
patched = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
for(off = (u32 *)0x00100000; off < (u32 *)(0x00100000 + textTotalRoundedSize) - 6 &&
|
||||
(off[0] != 0xE1A01006 || off[1] != 0xE1A00005 || off[3] != 0xE3500000 || off[6] != 0xE2850004);
|
||||
for(off = (u32 *)0x00100000; off < (u32 *)(0x00100000 + textTotalRoundedSize) - 3 &&
|
||||
(off[0] != 0xE1A01006 || (off[1] & 0xFFFF) != 5);
|
||||
off++);
|
||||
|
||||
if(off >= (u32 *)(0x00100000 + textTotalRoundedSize) - 6)
|
||||
if(off >= (u32 *)(0x00100000 + textTotalRoundedSize) - 3)
|
||||
return -1;
|
||||
|
||||
memcpy(&origData, off, sizeof(origData));
|
||||
|
||||
off[2] = off[3] = off[4] = off[5] = 0xE320F000; // nop
|
||||
off += 2;
|
||||
*off = 0xE3A00001; // mov r0, #1
|
||||
patched = true;
|
||||
}
|
||||
|
||||
@ -76,9 +75,10 @@ static Result ProcessPatchesMenu_DoPatchUnpatchFS(u32 textTotalRoundedSize)
|
||||
{
|
||||
static bool patched = false;
|
||||
static u16 *off;
|
||||
static const u16 origData[2] = {
|
||||
0x4618, // mov r0, r3
|
||||
0x3481, // adds r4, #0x81
|
||||
static u16 origData[2];
|
||||
static const u16 pattern[2] = {
|
||||
0x7401, // strb r1, [r0, #16]
|
||||
0x2000, // movs r0, #0
|
||||
};
|
||||
|
||||
if(patched)
|
||||
@ -88,10 +88,12 @@ static Result ProcessPatchesMenu_DoPatchUnpatchFS(u32 textTotalRoundedSize)
|
||||
}
|
||||
else
|
||||
{
|
||||
off = (u16 *)memsearch((u8 *)0x00100000, &origData, textTotalRoundedSize, sizeof(origData));
|
||||
off = (u16 *)memsearch((u8 *)0x00100000, &pattern, textTotalRoundedSize, sizeof(pattern));
|
||||
if(off == NULL)
|
||||
return -1;
|
||||
|
||||
off += 4;
|
||||
memcpy(origData, off, 4);
|
||||
off[0] = 0x2001; // mov r0, #1
|
||||
off[1] = 0x4770; // bx lr
|
||||
|
||||
|
Reference in New Issue
Block a user