Skip to content

Commit

Permalink
Clean up ReadFileSHA256 patch comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Popax21 committed Apr 17, 2024
1 parent 43d241c commit da7740e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions arm9/source/large_patches.s
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,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}

Expand All @@ -254,8 +255,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]
Expand Down
4 changes: 2 additions & 2 deletions arm9/source/patches.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,13 +880,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);
Expand Down

0 comments on commit da7740e

Please sign in to comment.