Made N3DS >9.6 key generation version independent
This commit is contained in:
parent
49d49e637a
commit
0e9ff44746
@ -379,10 +379,10 @@ void arm9Loader(u8 *arm9Section, u32 mode)
|
|||||||
memcpy(arm9BinCTR, arm9Section + 0x20, 0x10);
|
memcpy(arm9BinCTR, arm9Section + 0x20, 0x10);
|
||||||
|
|
||||||
//Calculate the size of the ARM9 binary
|
//Calculate the size of the ARM9 binary
|
||||||
u32 size = 0;
|
u32 arm9BinSize = 0;
|
||||||
//http://stackoverflow.com/questions/12791077/atoi-implementation-in-c
|
//http://stackoverflow.com/questions/12791077/atoi-implementation-in-c
|
||||||
for(u8 *tmp = arm9Section + 0x30; *tmp; tmp++)
|
for(u8 *tmp = arm9Section + 0x30; *tmp; tmp++)
|
||||||
size = (size << 3) + (size << 1) + (*tmp) - '0';
|
arm9BinSize = (arm9BinSize << 3) + (arm9BinSize << 1) + (*tmp) - '0';
|
||||||
|
|
||||||
if(mode)
|
if(mode)
|
||||||
{
|
{
|
||||||
@ -401,13 +401,13 @@ void arm9Loader(u8 *arm9Section, u32 mode)
|
|||||||
aes_use_keyslot(arm9BinSlot);
|
aes_use_keyslot(arm9BinSlot);
|
||||||
|
|
||||||
//Decrypt arm9bin
|
//Decrypt arm9bin
|
||||||
aes(arm9Section + 0x800, arm9Section + 0x800, size/AES_BLOCK_SIZE, arm9BinCTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
|
aes(arm9Section + 0x800, arm9Section + 0x800, arm9BinSize / AES_BLOCK_SIZE, arm9BinCTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
|
||||||
|
|
||||||
//Set >=9.6 KeyXs
|
//Set >=9.6 KeyXs
|
||||||
if(mode)
|
if(mode)
|
||||||
{
|
{
|
||||||
u8 *keyData = arm9Section + 0x89814;
|
u8 keyData[] = {0xDD, 0xDA, 0xA4, 0xC6, 0x2C, 0xC4, 0x50, 0xE9, 0xDA, 0xB6, 0x9B, 0x0D, 0x9D, 0x2A, 0x21, 0x98};
|
||||||
u8 *decKey = keyData + 0x10;
|
u8 decKey[0x10];
|
||||||
|
|
||||||
//Set keys 0x19..0x1F keyXs
|
//Set keys 0x19..0x1F keyXs
|
||||||
aes_use_keyslot(0x11);
|
aes_use_keyslot(0x11);
|
||||||
|
@ -277,7 +277,7 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhInstalle
|
|||||||
u32 unitInfoOffset;
|
u32 unitInfoOffset;
|
||||||
|
|
||||||
getUnitInfoValueSet(arm9Section, section[2].size, &unitInfoOffset);
|
getUnitInfoValueSet(arm9Section, section[2].size, &unitInfoOffset);
|
||||||
*((u8*)unitInfoOffset + 3) = unitInfoPatch[0];
|
*((u8*)unitInfoOffset + 3) = unitInfoPatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Replace the FIRM loader with the injector
|
//Replace the FIRM loader with the injector
|
||||||
@ -286,11 +286,11 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhInstalle
|
|||||||
|
|
||||||
static inline void patchEmuNAND(u8 *arm9Section, u8 *proc9Offset, u32 emuHeader)
|
static inline void patchEmuNAND(u8 *arm9Section, u8 *proc9Offset, u32 emuHeader)
|
||||||
{
|
{
|
||||||
//Copy nandType code
|
//Copy emuNAND code
|
||||||
void *emuCodeOffset = getEmuCode(proc9Offset);
|
void *emuCodeOffset = getEmuCode(proc9Offset);
|
||||||
memcpy(emuCodeOffset, emunand, emunand_size);
|
memcpy(emuCodeOffset, emunand, emunand_size);
|
||||||
|
|
||||||
//Add the data of the found nandType
|
//Add the data of the found emuNAND
|
||||||
u32 *pos_offset = (u32 *)memsearch(emuCodeOffset, "NAND", emunand_size, 4);
|
u32 *pos_offset = (u32 *)memsearch(emuCodeOffset, "NAND", emunand_size, 4);
|
||||||
u32 *pos_header = (u32 *)memsearch(emuCodeOffset, "NCSD", emunand_size, 4);
|
u32 *pos_header = (u32 *)memsearch(emuCodeOffset, "NCSD", emunand_size, 4);
|
||||||
*pos_offset = emuOffset;
|
*pos_offset = emuOffset;
|
||||||
@ -304,7 +304,7 @@ static inline void patchEmuNAND(u8 *arm9Section, u8 *proc9Offset, u32 emuHeader)
|
|||||||
u32 branchOffset = (u32)emuCodeOffset - (u32)firm -
|
u32 branchOffset = (u32)emuCodeOffset - (u32)firm -
|
||||||
section[2].offset + (u32)section[2].address;
|
section[2].offset + (u32)section[2].address;
|
||||||
|
|
||||||
//Add emunand hooks
|
//Add emuNAND hooks
|
||||||
u32 emuRead,
|
u32 emuRead,
|
||||||
emuWrite;
|
emuWrite;
|
||||||
|
|
||||||
@ -425,4 +425,4 @@ static inline void launchFirm(u32 bootType)
|
|||||||
|
|
||||||
//Final jump to arm9 kernel
|
//Final jump to arm9 kernel
|
||||||
((void (*)())firm->arm9Entry)();
|
((void (*)())firm->arm9Entry)();
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ const u16 sigPatch[2] = {0x2000, 0x4770};
|
|||||||
|
|
||||||
const u16 writeBlock[2] = {0x2000, 0x46C0};
|
const u16 writeBlock[2] = {0x2000, 0x46C0};
|
||||||
|
|
||||||
const u8 unitInfoPatch[1] = {0xE3};
|
const u8 unitInfoPatch = 0xE3;
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* Functions
|
* Functions
|
||||||
@ -83,4 +83,4 @@ void getUnitInfoValueSet(u8 *pos, u32 size, u32 *off)
|
|||||||
const u8 pattern[] = {0x01, 0x10, 0xA0, 0x13};
|
const u8 pattern[] = {0x01, 0x10, 0xA0, 0x13};
|
||||||
|
|
||||||
*off = (u32)memsearch(pos, pattern, size, 4);
|
*off = (u32)memsearch(pos, pattern, size, 4);
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ const u32 mpuPatch[3];
|
|||||||
const u16 nandRedir[2];
|
const u16 nandRedir[2];
|
||||||
const u16 sigPatch[2];
|
const u16 sigPatch[2];
|
||||||
const u16 writeBlock[2];
|
const u16 writeBlock[2];
|
||||||
const u8 unitInfoPatch[1];
|
const u8 unitInfoPatch;
|
||||||
|
|
||||||
/**************************************************
|
/**************************************************
|
||||||
* Functions
|
* Functions
|
||||||
@ -26,4 +26,4 @@ void *getReboot(u8 *pos, u32 size);
|
|||||||
u32 getfOpen(u8 *proc9Offset, void *rebootOffset);
|
u32 getfOpen(u8 *proc9Offset, void *rebootOffset);
|
||||||
u16 *getFirmWrite(u8 *pos, u32 size);
|
u16 *getFirmWrite(u8 *pos, u32 size);
|
||||||
void getLoader(u8 *pos, u32 size, u32 *loaderOffset, u32 *loaderSize);
|
void getLoader(u8 *pos, u32 size, u32 *loaderOffset, u32 *loaderSize);
|
||||||
void getUnitInfoValueSet(u8 *pos, u32 size, u32* off);
|
void getUnitInfoValueSet(u8 *pos, u32 size, u32* off);
|
@ -32,7 +32,7 @@ void deinitScreens(void)
|
|||||||
*(vu32 *)0x10202A44 = 0;
|
*(vu32 *)0x10202A44 = 0;
|
||||||
*(vu32 *)0x10202244 = 0;
|
*(vu32 *)0x10202244 = 0;
|
||||||
*(vu32 *)0x10202014 = 0;
|
*(vu32 *)0x10202014 = 0;
|
||||||
|
|
||||||
//Wait for the entry to be set
|
//Wait for the entry to be set
|
||||||
while(!*arm11Entry);
|
while(!*arm11Entry);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user