From f1306345db71812eec648815d5852a35131751de Mon Sep 17 00:00:00 2001 From: Popax21 Date: Wed, 11 Jan 2023 12:06:43 +0100 Subject: [PATCH] Clean up ReadFileSHA256 patch comments --- arm9/source/large_patches.s | 5 +++-- arm9/source/patches.c | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arm9/source/large_patches.s b/arm9/source/large_patches.s index 359fd9a7e..7893bc22d 100644 --- a/arm9/source/large_patches.s +++ b/arm9/source/large_patches.s @@ -300,6 +300,7 @@ rebootPatchSize: readFileSHA256Vtab11Patch: //Result Write(this, u32 off, u8 *data, u32 size) push {r0-r4, lr} + @ Allocate memory for DataChainProcessor struct sub sp, #0x14 push {sp} @@ -318,8 +319,8 @@ readFileSHA256Vtab11Patch: //Result Write(this, u32 off, u8 *data, u32 size) @ DataChainProcessor::Process(&proc, this, off, 0, size); ldr r0, [sp] - ldr r2, [sp, #0x24] - str r2, [sp] @ Set size field on stack + ldr r1, [sp, #0x24] + str r1, [sp] @ size argument ldr r1, [sp, #0x18] ldr r2, [sp, #0x1c] diff --git a/arm9/source/patches.c b/arm9/source/patches.c index 245dc1522..8ad8f586a 100644 --- a/arm9/source/patches.c +++ b/arm9/source/patches.c @@ -767,13 +767,13 @@ u32 patchReadFileSHA256Vtab11(u8 *pos, u32 size, u32 process9MemAddr) if((*ncchVtable11Ptr & 0x1) == 0 || (*shaVtable11Ptr & 0x1) == 0) return 1; //Must be Thumb - //Find our function address by inspecting all bl branch targets + //Find needed function addresses by inspecting all bl branch targets u16 *ncchWriteFnc = (u16 *)(pos + ((*ncchVtable11Ptr & ~0x1) - process9MemAddr)); if(*(u32 *)ncchWriteFnc != 0x0005b5f0) return 1; //Check if we got the right function readFileSHA256Vtab11PatchCtorPtr = readFileSHA256Vtab11PatchInitPtr = readFileSHA256Vtab11PatchProcessPtr = 0; - for(; ((*ncchWriteFnc) & 0xff00) != 0xbd00; ncchWriteFnc++) { + for(; ((*ncchWriteFnc) & 0xff00) != 0xbd00; ncchWriteFnc++) { //Stop whe encountering a pop {..., pc} if((ncchWriteFnc[0] & 0xf800) != 0xf000 || (ncchWriteFnc[1] & 0xf800) != 0xf800) continue; //Check the instruction opcode s32 callOff = ((ncchWriteFnc[0] & 0x07ff) << 11) | (ncchWriteFnc[1] & 0x07ff);