From a0b4e7fd5db8d410668d058264f73d29dc63e439 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 11 Oct 2016 00:41:58 +0200 Subject: [PATCH] Fix other derps --- source/crypto.c | 6 +++--- source/emunand.c | 3 ++- source/patches.c | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/crypto.c b/source/crypto.c index a3fcea5..250b486 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -388,8 +388,8 @@ bool decryptExeFs(Cxi *cxi) { isCxi = true; - u8 *exeFsOffset = (u8 *)cxi + cxi->ncch.exeFsOffset * 0x200; - u32 exeFsSize = cxi->ncch.exeFsSize * 0x200; + u8 *exeFsOffset = (u8 *)cxi + (cxi->ncch.exeFsOffset + 1) * 0x200; + u32 exeFsSize = (cxi->ncch.exeFsSize - 1) * 0x200; u8 __attribute__((aligned(4))) ncchCtr[AES_BLOCK_SIZE] = {0}; for(u32 i = 0; i < 8; i++) @@ -399,7 +399,7 @@ bool decryptExeFs(Cxi *cxi) aes_setkey(0x2C, cxi, AES_KEYY, AES_INPUT_BE | AES_INPUT_NORMAL); aes_advctr(ncchCtr, 0x200 / AES_BLOCK_SIZE, AES_INPUT_BE | AES_INPUT_NORMAL); aes_use_keyslot(0x2C); - aes(cxi, exeFsOffset + 0x200, exeFsSize / AES_BLOCK_SIZE, ncchCtr, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL); + aes(cxi, exeFsOffset, exeFsSize / AES_BLOCK_SIZE, ncchCtr, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL); } else isCxi = false; diff --git a/source/emunand.c b/source/emunand.c index 3e27467..56e2260 100644 --- a/source/emunand.c +++ b/source/emunand.c @@ -209,7 +209,8 @@ u32 patchEmuNand(u8 *arm9Section, u32 arm9SectionSize, u8 *process9Offset, u32 p if(!ret) *posSdmmc = sdmmc; //Add EmuNAND hooks - ret += patchNandRw(process9Offset, process9Size, (u32)(freeK9Space - arm9Section + kernel9Address)); + u32 branchOffset = (u32)(freeK9Space - arm9Section + kernel9Address); + ret += patchNandRw(process9Offset, process9Size, branchOffset); //Set MPU ret += patchMpu(arm9Section, arm9SectionSize); diff --git a/source/patches.c b/source/patches.c index 12966d9..b727c5d 100644 --- a/source/patches.c +++ b/source/patches.c @@ -39,10 +39,10 @@ u8 *getProcess9Info(u8 *pos, u32 size, u32 *process9Size, u32 *process9MemAddr) Cxi *off = (Cxi *)(temp - 0x100); - *process9Size = off->ncch.contentSize * 0x200; + *process9Size = (off->ncch.exeFsSize - 1) * 0x200; *process9MemAddr = off->exHeader.systemControlInfo.textCodeSet.address; - return (u8 *)off + (off->ncch.exeFsOffset * 0x200) + 0x200; + return (u8 *)off + (off->ncch.exeFsOffset + 1) * 0x200; } u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 **arm11SvcHandler, u32 **arm11ExceptionsPage)