Made N3DS >9.6 key generation version independent

This commit is contained in:
Aurora 2016-04-11 22:16:51 +02:00
parent 49d49e637a
commit 0e9ff44746
5 changed files with 15 additions and 15 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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