From ec08a449adf13f26579de0be4571b1783feabf2e Mon Sep 17 00:00:00 2001 From: sup39 Date: Fri, 11 Nov 2022 17:14:11 +0900 Subject: [PATCH] add gecko-jump.s --- ReadFile.c | 2 +- gecko-jump.s | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gecko-jump.s diff --git a/ReadFile.c b/ReadFile.c index cae9a25..c354433 100644 --- a/ReadFile.c +++ b/ReadFile.c @@ -44,7 +44,7 @@ int onReadOptionBlock(TCardManager *this, CARDFileInfo *fileInfo) { } else { // everything is good => apply gecko code // TODO entry - ((void(*)())0x817f0000)(); + ((void(*)())0x817f4000)(); } // close file diff --git a/gecko-jump.s b/gecko-jump.s new file mode 100644 index 0000000..5e049f5 --- /dev/null +++ b/gecko-jump.s @@ -0,0 +1,29 @@ +.set gpApplication, 0x803e6000 # TODO version +.set dst, 0x817fb000 + +## TODO prevent softlock: check app state >= 4 + lis r5, gpApplication+8@ha + lbz r5, gpApplication+8@l(r5) + cmplwi r5, 4 + bltlr +## r5 = 00D0C0DE + lis r5, 0x00D0 + ori r5, r5, 0xC0DE +## check if code is loaded (check header) + lis r3, dst@ha +### first 00D0C0DE +### r3 = &dst + lwzu r0, dst@l(r3) + cmplw r0, r5 + bnelr +### second 00D0C0DE + lwz r0, 4(r3) + cmplw r0, r5 + bnelr +## backup r15 (pointer to current gecko instruction) at dst-4 + add r0, r15, r4 + stw r0, -4(r3) +## update r15 = dst + 8(header) - r4(this C0 code size) + addi r15, r3, 8 + sub r15, r15, r4 + blr