Spaces and stuff
Makes things more uniform
This commit is contained in:
parent
9b1df43687
commit
1861d556a6
@ -266,12 +266,12 @@ void decryptArm9Bin(u8 *arm9Section, u32 mode){
|
||||
u8 slot = mode ? 0x16 : 0x15;
|
||||
|
||||
//Setup keys needed for arm9bin decryption
|
||||
memcpy(keyY, arm9Section+0x10, 0x10);
|
||||
memcpy(CTR, arm9Section+0x20, 0x10);
|
||||
memcpy(keyY, arm9Section + 0x10, 0x10);
|
||||
memcpy(CTR, arm9Section + 0x20, 0x10);
|
||||
u32 size = 0;
|
||||
//http://stackoverflow.com/questions/12791077/atoi-implementation-in-c
|
||||
for(u8 *tmp = arm9Section+0x30; *tmp; tmp++)
|
||||
size = (size<<3)+(size<<1)+(*tmp)-'0';
|
||||
for(u8 *tmp = arm9Section + 0x30; *tmp; tmp++)
|
||||
size = (size << 3) + (size << 1) + (*tmp) - '0';
|
||||
|
||||
if(mode){
|
||||
u8 keyX[0x10];
|
||||
@ -279,7 +279,7 @@ void decryptArm9Bin(u8 *arm9Section, u32 mode){
|
||||
//Set 0x11 to key2 for the arm9bin and misc keys
|
||||
aes_setkey(0x11, key2, AES_KEYNORMAL, AES_INPUT_BE | AES_INPUT_NORMAL);
|
||||
aes_use_keyslot(0x11);
|
||||
aes(keyX, arm9Section+0x60, 1, NULL, AES_ECB_DECRYPT_MODE, 0);
|
||||
aes(keyX, arm9Section + 0x60, 1, NULL, AES_ECB_DECRYPT_MODE, 0);
|
||||
aes_setkey(slot, keyX, AES_KEYX, AES_INPUT_BE | AES_INPUT_NORMAL);
|
||||
}
|
||||
|
||||
@ -288,14 +288,14 @@ void decryptArm9Bin(u8 *arm9Section, u32 mode){
|
||||
aes_use_keyslot(slot);
|
||||
|
||||
//Decrypt arm9bin
|
||||
aes(arm9Section+0x800, arm9Section+0x800, size/AES_BLOCK_SIZE, CTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
|
||||
aes(arm9Section + 0x800, arm9Section + 0x800, size/AES_BLOCK_SIZE, CTR, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL);
|
||||
}
|
||||
|
||||
//Sets the N3DS 9.6 KeyXs
|
||||
void setKeyXs(u8 *arm9Section){
|
||||
|
||||
u8 *keyData = arm9Section+0x89814;
|
||||
u8 *decKey = keyData+0x10;
|
||||
u8 *keyData = arm9Section + 0x89814;
|
||||
u8 *decKey = keyData + 0x10;
|
||||
|
||||
//Set keys 0x19..0x1F keyXs
|
||||
aes_setkey(0x11, key2, AES_KEYNORMAL, AES_INPUT_BE | AES_INPUT_NORMAL);
|
||||
@ -303,6 +303,6 @@ void setKeyXs(u8 *arm9Section){
|
||||
for(u8 slot = 0x19; slot < 0x20; slot++){
|
||||
aes(decKey, keyData, 1, NULL, AES_ECB_DECRYPT_MODE, 0);
|
||||
aes_setkey(slot, decKey, AES_KEYX, AES_INPUT_BE | AES_INPUT_NORMAL);
|
||||
*(keyData+0xF) += 1;
|
||||
*(keyData + 0xF) += 1;
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ u32 getSDMMC(void *pos, u32 size){
|
||||
const unsigned char pattern[] = {0x21, 0x20, 0x18, 0x20};
|
||||
const u8 *off = (u8 *)memsearch(pos, pattern, size, 4) - 1;
|
||||
|
||||
return *(u32 *)(off+0x0A) + *(u32 *)(off+0x0E);
|
||||
return *(u32 *)(off + 0x0A) + *(u32 *)(off + 0x0E);
|
||||
}
|
||||
|
||||
void getEmuRW(void *pos, u32 size, u32 *readOff, u32 *writeOff){
|
||||
|
@ -36,8 +36,7 @@ int memcmp(const void *buf1, const void *buf2, u32 size){
|
||||
}
|
||||
|
||||
void *memsearch(void *start_pos, const void *search, u32 size, u32 size_search){
|
||||
for(void *pos = start_pos + size - size_search; pos >= start_pos; pos--){
|
||||
for(void *pos = start_pos + size - size_search; pos >= start_pos; pos--)
|
||||
if(memcmp(pos, search, size_search) == 0) return pos;
|
||||
}
|
||||
return NULL;
|
||||
}
|
@ -63,8 +63,8 @@ u32 getfOpen(void *pos, u32 size, u8 *proc9Offset){
|
||||
|
||||
void *getFirmWrite(void *pos, u32 size){
|
||||
//Look for FIRM writing code
|
||||
u8 *firmwrite = (u8 *)memsearch(pos, "exe:", size, 4);
|
||||
u8 *const off = (u8 *)memsearch(pos, "exe:", size, 4);
|
||||
const unsigned char pattern[] = {0x00, 0x28, 0x01, 0xDA};
|
||||
|
||||
return memsearch(firmwrite - 0x100, pattern, 0x100, 4);
|
||||
return memsearch(off - 0x100, pattern, 0x100, 4);
|
||||
}
|
@ -42,9 +42,9 @@ static u16 waitInput(void){
|
||||
for(u32 i = 0x13000; i; i--){
|
||||
if (key != HID_PAD)
|
||||
break;
|
||||
if(i==1) pressedkey = 1;
|
||||
if(i == 1) pressedkey = 1;
|
||||
}
|
||||
} while (!pressedkey);
|
||||
} while(!pressedkey);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
Reference in New Issue
Block a user