From 1861d556a6046f3436fd025bb47839a75de2ae1a Mon Sep 17 00:00:00 2001 From: Aurora Date: Fri, 25 Mar 2016 18:17:12 +0100 Subject: [PATCH] Spaces and stuff Makes things more uniform --- source/crypto.c | 18 +++++++++--------- source/emunand.c | 2 +- source/memory.c | 3 +-- source/patches.c | 4 ++-- source/utils.c | 4 ++-- 5 files changed, 15 insertions(+), 16 deletions(-) diff --git a/source/crypto.c b/source/crypto.c index b8eac027..8763c989 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -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; } } \ No newline at end of file diff --git a/source/emunand.c b/source/emunand.c index b1dd5ba9..6056e7c9 100644 --- a/source/emunand.c +++ b/source/emunand.c @@ -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){ diff --git a/source/memory.c b/source/memory.c index 8b8c9eae..8f1d1252 100644 --- a/source/memory.c +++ b/source/memory.c @@ -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; } \ No newline at end of file diff --git a/source/patches.c b/source/patches.c index bf7dfa6b..ef81bae4 100644 --- a/source/patches.c +++ b/source/patches.c @@ -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); } \ No newline at end of file diff --git a/source/utils.c b/source/utils.c index 8b38244a..a172ef45 100644 --- a/source/utils.c +++ b/source/utils.c @@ -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; }