Merge master into developer
This commit is contained in:
commit
6afc8b3b5c
@ -325,7 +325,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
case 0x000400300000B102LL: // TWN Menu
|
||||
{
|
||||
static const u8 regionFreePattern[] = {
|
||||
0x00, 0x00, 0x55, 0xE3, 0x01, 0x10, 0xA0, 0xE3
|
||||
0x00, 0x00, 0x55, 0xE3, 0x01, 0x10, 0xA0
|
||||
};
|
||||
static const u8 regionFreePatch[] = {
|
||||
0x01, 0x00, 0xA0, 0xE3, 0x1E, 0xFF, 0x2F, 0xE1
|
||||
@ -384,7 +384,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
case 0x0004013000003202LL: // FRIENDS
|
||||
{
|
||||
static const u8 fpdVerPattern[] = {
|
||||
0xE0, 0x1E, 0xFF, 0x2F, 0xE1, 0x01, 0x01, 0x01
|
||||
0xE0, 0x1E, 0xFF, 0x2F, 0xE1, 0x01, 0x01
|
||||
};
|
||||
|
||||
static const u8 mostRecentFpdVer = 0x06;
|
||||
@ -445,7 +445,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
if(cpuSetting)
|
||||
{
|
||||
static const u8 cfgN3dsCpuPattern[] = {
|
||||
0x00, 0x40, 0xA0, 0xE1, 0x07, 0x00
|
||||
0x00, 0x40, 0xA0, 0xE1, 0x07
|
||||
};
|
||||
|
||||
u32 *cfgN3dsCpuLoc = (u32 *)memsearch(code, cfgN3dsCpuPattern, size, sizeof(cfgN3dsCpuPattern));
|
||||
@ -464,7 +464,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
case 0x0004013000001702LL: // CFG
|
||||
{
|
||||
static const u8 secureinfoSigCheckPattern[] = {
|
||||
0x06, 0x46, 0x10, 0x48, 0xFC
|
||||
0x06, 0x46, 0x10, 0x48
|
||||
};
|
||||
static const u8 secureinfoSigCheckPatch[] = {
|
||||
0x00, 0x26
|
||||
@ -538,23 +538,22 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 0x0004003000008A02LL: // ErrDisp
|
||||
{
|
||||
if(MULTICONFIG(2) == 0)
|
||||
{
|
||||
static const u8 unitinfoCheckPattern1[] = {
|
||||
0x14, 0x00, 0xD0, 0xE5, 0xDB, 0x9A, 0x9F, 0xED
|
||||
0x14, 0x00, 0xD0, 0xE5, 0xDB
|
||||
};
|
||||
|
||||
|
||||
static const u8 unitinfoCheckPattern2[] = {
|
||||
0x14, 0x00, 0xD0, 0xE5, 0x01, 0x00, 0x10, 0xE3
|
||||
0x14, 0x00, 0xD0, 0xE5, 0x01
|
||||
} ;
|
||||
|
||||
|
||||
static const u8 unitinfoCheckPatch[] = {
|
||||
0x00, 0x00, 0xA0, 0xE3
|
||||
} ;
|
||||
|
||||
|
||||
patchMemory(code, size,
|
||||
unitinfoCheckPattern1,
|
||||
sizeof(unitinfoCheckPattern1), 0,
|
||||
@ -603,4 +602,4 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -63,14 +63,14 @@ static inline void *getFreeK9Space(u8 *pos, u32 size)
|
||||
const u8 pattern[] = {0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00};
|
||||
|
||||
//Looking for the last free space before Process9
|
||||
return memsearch(pos + 0x13500, pattern, size - 0x13500, 6) + 0x455;
|
||||
return memsearch(pos + 0x13500, pattern, size - 0x13500, sizeof(pattern)) + 0x455;
|
||||
}
|
||||
|
||||
static inline u32 getSdmmc(u8 *pos, u32 size)
|
||||
{
|
||||
//Look for struct code
|
||||
const u8 pattern[] = {0x21, 0x20, 0x18, 0x20};
|
||||
const u8 *off = memsearch(pos, pattern, size, 4);
|
||||
const u8 *off = memsearch(pos, pattern, size, sizeof(pattern));
|
||||
|
||||
return *(u32 *)(off + 9) + *(u32 *)(off + 0xD);
|
||||
}
|
||||
@ -82,8 +82,8 @@ static inline void patchNandRw(u8 *pos, u32 size, u32 branchOffset)
|
||||
//Look for read/write code
|
||||
const u8 pattern[] = {0x1E, 0x00, 0xC8, 0x05};
|
||||
|
||||
u16 *readOffset = (u16 *)memsearch(pos, pattern, size, 4) - 3,
|
||||
*writeOffset = (u16 *)memsearch((u8 *)(readOffset + 5), pattern, 0x100, 4) - 3;
|
||||
u16 *readOffset = (u16 *)memsearch(pos, pattern, size, sizeof(pattern)) - 3,
|
||||
*writeOffset = (u16 *)memsearch((u8 *)(readOffset + 5), pattern, 0x100, sizeof(pattern)) - 3;
|
||||
|
||||
*readOffset = nandRedir[0];
|
||||
readOffset[1] = nandRedir[1];
|
||||
@ -98,7 +98,7 @@ static inline void patchMpu(u8 *pos, u32 size)
|
||||
//Look for MPU pattern
|
||||
const u8 pattern[] = {0x03, 0x00, 0x24, 0x00};
|
||||
|
||||
u32 *off = (u32 *)memsearch(pos, pattern, size, 4);
|
||||
u32 *off = (u32 *)memsearch(pos, pattern, size, sizeof(pattern));
|
||||
|
||||
off[0] = 0x00360003;
|
||||
off[6] = 0x00200603;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "memory.h"
|
||||
#include "screen.h"
|
||||
#include "draw.h"
|
||||
#include "i2c.h"
|
||||
#include "utils.h"
|
||||
#include "../build/arm9_exceptions.h"
|
||||
#include "../build/arm11_exceptions.h"
|
||||
|
@ -305,9 +305,8 @@ static inline void patchNativeFirm(u32 firmVersion, FirmwareSource nandType, u32
|
||||
//Find Kernel11 SVC table and free space locations
|
||||
u8 *freeK11Space;
|
||||
u32 *arm11SvcHandler,
|
||||
*arm11ExceptionsPage;
|
||||
|
||||
u32 *arm11SvcTable = getKernel11Info(arm11Section1, section[1].size, &freeK11Space, &arm11SvcHandler, &arm11ExceptionsPage);
|
||||
*arm11ExceptionsPage,
|
||||
*arm11SvcTable = getKernel11Info(arm11Section1, section[1].size, &freeK11Space, &arm11SvcHandler, &arm11ExceptionsPage);
|
||||
|
||||
//Apply signature patches
|
||||
patchSignatureChecks(process9Offset, process9Size);
|
||||
|
@ -43,7 +43,7 @@ u32 *getKernel11Info(u8 *pos, u32 size, u8 **freeK11Space, u32 **arm11SvcHandler
|
||||
{
|
||||
const u8 pattern[] = {0x00, 0xB0, 0x9C, 0xE5};
|
||||
|
||||
*arm11ExceptionsPage = (u32 *)memsearch(pos, pattern, size, 4) - 0xB;
|
||||
*arm11ExceptionsPage = (u32 *)memsearch(pos, pattern, size, sizeof(pattern)) - 0xB;
|
||||
u32 svcOffset = (-(((*arm11ExceptionsPage)[2] & 0xFFFFFF) << 2) & (0xFFFFFF << 2)) - 8; //Branch offset + 8 for prefetch
|
||||
u32 *arm11SvcTable = (u32 *)(pos + *(u32 *)(pos + 0xFFFF0008 - svcOffset - 0xFFF00000 + 8) - 0xFFF00000); //SVC handler address
|
||||
*arm11SvcHandler = arm11SvcTable;
|
||||
@ -51,7 +51,7 @@ u32 *getKernel11Info(u8 *pos, u32 size, u8 **freeK11Space, u32 **arm11SvcHandler
|
||||
|
||||
const u8 pattern2[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
|
||||
*freeK11Space = memsearch(pos, pattern2, size, 5) + 1;
|
||||
*freeK11Space = memsearch(pos, pattern2, size, sizeof(pattern2)) + 1;
|
||||
|
||||
return arm11SvcTable;
|
||||
}
|
||||
@ -64,8 +64,8 @@ void patchSignatureChecks(u8 *pos, u32 size)
|
||||
const u8 pattern[] = {0xC0, 0x1C, 0x76, 0xE7},
|
||||
pattern2[] = {0xB5, 0x22, 0x4D, 0x0C};
|
||||
|
||||
u16 *off = (u16 *)memsearch(pos, pattern, size, 4),
|
||||
*off2 = (u16 *)(memsearch(pos, pattern2, size, 4) - 1);
|
||||
u16 *off = (u16 *)memsearch(pos, pattern, size, sizeof(pattern)),
|
||||
*off2 = (u16 *)(memsearch(pos, pattern2, size, sizeof(pattern2)) - 1);
|
||||
|
||||
*off = sigPatch[0];
|
||||
off2[0] = sigPatch[0];
|
||||
@ -77,7 +77,7 @@ void patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr)
|
||||
//Look for firmlaunch code
|
||||
const u8 pattern[] = {0xE2, 0x20, 0x20, 0x90};
|
||||
|
||||
u8 *off = memsearch(pos, pattern, size, 4) - 0x13;
|
||||
u8 *off = memsearch(pos, pattern, size, sizeof(pattern)) - 0x13;
|
||||
|
||||
//Firmlaunch function offset - offset in BLX opcode (A4-16 - ARM DDI 0100E) + 1
|
||||
u32 fOpenOffset = (u32)(off + 9 - (-((*(u32 *)off & 0x00FFFFFF) << 2) & (0xFFFFFF << 2)) - pos + process9MemAddr);
|
||||
@ -96,7 +96,7 @@ void patchFirmWrites(u8 *pos, u32 size)
|
||||
u8 *const off1 = memsearch(pos, "exe:", size, 4);
|
||||
const u8 pattern[] = {0x00, 0x28, 0x01, 0xDA};
|
||||
|
||||
u16 *off2 = (u16 *)memsearch(off1 - 0x100, pattern, 0x100, 4);
|
||||
u16 *off2 = (u16 *)memsearch(off1 - 0x100, pattern, 0x100, sizeof(pattern));
|
||||
|
||||
off2[0] = 0x2000;
|
||||
off2[1] = 0x46C0;
|
||||
@ -107,7 +107,7 @@ void patchOldFirmWrites(u8 *pos, u32 size)
|
||||
//Look for FIRM writing code
|
||||
const u8 pattern[] = {0x04, 0x1E, 0x1D, 0xDB};
|
||||
|
||||
u16 *off = (u16 *)memsearch(pos, pattern, size, 4);
|
||||
u16 *off = (u16 *)memsearch(pos, pattern, size, sizeof(pattern));
|
||||
|
||||
off[0] = 0x2400;
|
||||
off[1] = 0xE01D;
|
||||
@ -167,7 +167,7 @@ void patchTitleInstallMinVersionCheck(u8 *pos, u32 size)
|
||||
{
|
||||
const u8 pattern[] = {0x0A, 0x81, 0x42, 0x02};
|
||||
|
||||
u8 *off = memsearch(pos, pattern, size, 4);
|
||||
u8 *off = memsearch(pos, pattern, size, sizeof(pattern));
|
||||
|
||||
if(off != NULL) off[4] = 0xE0;
|
||||
}
|
||||
@ -237,7 +237,7 @@ void patchArm9ExceptionHandlersInstall(u8 *pos, u32 size)
|
||||
{
|
||||
const u8 pattern[] = {0x03, 0xA0, 0xE3, 0x18};
|
||||
|
||||
u32* off = (u32 *)(memsearch(pos, pattern, size, 4) + 0x13);
|
||||
u32* off = (u32 *)(memsearch(pos, pattern, size, sizeof(pattern)) + 0x13);
|
||||
|
||||
for(u32 r0 = 0x08000000; *off != 0xE3A01040; off++) //Until mov r1, #0x40
|
||||
{
|
||||
@ -265,11 +265,11 @@ u32 getInfoForArm11ExceptionHandlers(u8 *pos, u32 size, u32 *codeSetOffset)
|
||||
const u8 pattern[] = {0xE3, 0xDC, 0x05, 0xC0}, //Get TitleID from CodeSet
|
||||
pattern2[] = {0xE1, 0x0F, 0x00, 0xBD}; //Call exception dispatcher
|
||||
|
||||
u32 *loadCodeSet = (u32 *)(memsearch(pos, pattern, size, 4) - 0xB);
|
||||
u32 *loadCodeSet = (u32 *)(memsearch(pos, pattern, size, sizeof(pattern)) - 0xB);
|
||||
|
||||
*codeSetOffset = *loadCodeSet & 0xFFF;
|
||||
|
||||
return *(u32 *)(memsearch(pos, pattern2, size, 4) + 0xD);
|
||||
return *(u32 *)(memsearch(pos, pattern2, size, sizeof(pattern2)) + 0xD);
|
||||
}
|
||||
|
||||
void patchSvcBreak9(u8 *pos, u32 size, u32 kernel9Address)
|
||||
@ -280,7 +280,7 @@ void patchSvcBreak9(u8 *pos, u32 size, u32 kernel9Address)
|
||||
//Look for the svc handler
|
||||
const u8 pattern[] = {0x00, 0xE0, 0x4F, 0xE1}; //mrs lr, spsr
|
||||
|
||||
u32 *arm9SvcTable = (u32 *)memsearch(pos, pattern, size, 4);
|
||||
u32 *arm9SvcTable = (u32 *)memsearch(pos, pattern, size, sizeof(pattern));
|
||||
while(*arm9SvcTable) arm9SvcTable++; //Look for SVC0 (NULL)
|
||||
|
||||
u32 *addr = (u32 *)(pos + arm9SvcTable[0x3C] - kernel9Address);
|
||||
@ -298,7 +298,7 @@ void patchKernel9Panic(u8 *pos, u32 size)
|
||||
{
|
||||
const u8 pattern[] = {0xDF, 0xFF, 0xEA, 0x04};
|
||||
|
||||
u32 *off = (u32 *)(memsearch(pos, pattern, size, 4) - 0x11);
|
||||
u32 *off = (u32 *)(memsearch(pos, pattern, size, sizeof(pattern)) - 0x11);
|
||||
*off = 0xE12FFF7E;
|
||||
}
|
||||
|
||||
@ -306,7 +306,7 @@ void patchKernel11Panic(u8 *pos, u32 size)
|
||||
{
|
||||
const u8 pattern[] = {0x02, 0x0B, 0x44, 0xE2};
|
||||
|
||||
u32 *off = (u32 *)memsearch(pos, pattern, size, 4);
|
||||
u32 *off = (u32 *)memsearch(pos, pattern, size, sizeof(pattern));
|
||||
*off = 0xE12FFF7E;
|
||||
}
|
||||
|
||||
@ -314,7 +314,7 @@ void patchP9AccessChecks(u8 *pos, u32 size)
|
||||
{
|
||||
const u8 pattern[] = {0xE0, 0x00, 0x40, 0x39};
|
||||
|
||||
u16 *off = (u16 *)memsearch(pos, pattern, size, 4) - 7;
|
||||
u16 *off = (u16 *)memsearch(pos, pattern, size, sizeof(pattern)) - 7;
|
||||
|
||||
off[0] = 0x2001; //mov r0, #1
|
||||
off[1] = 0x4770; //bx lr
|
||||
@ -338,7 +338,7 @@ void patchK11ModuleChecks(u8 *pos, u32 size, u8 **freeK11Space)
|
||||
//Look for the code that decompresses the .code section of the builtin modules
|
||||
const u8 pattern[] = {0xE5, 0x48, 0x00, 0x9D};
|
||||
|
||||
u32 *off = (u32 *)(memsearch(pos, pattern, size, 4) - 0xB);
|
||||
u32 *off = (u32 *)(memsearch(pos, pattern, size, sizeof(pattern)) - 0xB);
|
||||
|
||||
//Inject a jump (BL) instruction to our code at the offset we found
|
||||
*off = 0xEB000000 | (((((u32)*freeK11Space) - ((u32)off + 8)) >> 2) & 0xFFFFFF);
|
||||
@ -351,7 +351,7 @@ void patchUnitInfoValueSet(u8 *pos, u32 size)
|
||||
//Look for UNITINFO value being set during kernel sync
|
||||
const u8 pattern[] = {0x01, 0x10, 0xA0, 0x13};
|
||||
|
||||
u8 *off = memsearch(pos, pattern, size, 4);
|
||||
u8 *off = memsearch(pos, pattern, size, sizeof(pattern));
|
||||
|
||||
off[0] = isDevUnit ? 0 : 1;
|
||||
off[3] = 0xE3;
|
||||
|
Reference in New Issue
Block a user