From: chaoskagami Date: Sat, 11 Jun 2016 15:45:02 +0000 (-0400) Subject: Fix up a few bugs for something not yet exposed to the assembler, hopefully fix TWL... X-Git-Tag: v0.0.9~10 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=4434cb0f3447b085418fd024039f75be61ad3c37;p=corbenik%2Fcorbenik.git Fix up a few bugs for something not yet exposed to the assembler, hopefully fix TWL patches --- diff --git a/host/bytecode_asm.py b/host/bytecode_asm.py index 1915043..0dd38dc 100755 --- a/host/bytecode_asm.py +++ b/host/bytecode_asm.py @@ -278,6 +278,8 @@ def parse_op(token_list, instr_offs): val = bytearray(struct.pack(">H", instr_offs[num])) val.reverse() return bytearray.fromhex("87") + val + elif token_list[0] == "n3ds": # Sets the eq flag if this is an n3ds. + return bytearray.fromhex("10") def pad_zero_r(x, c): while len(x) < c: diff --git a/patch/twl_fix.pco b/patch/twl_fix.pco index 006ec73..f556ee8 100644 --- a/patch/twl_fix.pco +++ b/patch/twl_fix.pco @@ -3,86 +3,80 @@ # $ver 01 # $uuid 34 -# TODO - Make dynamic. Not that hard, but some -# fixes need more context bytes than on Steveice10's -# pastebin - -# Relative to twl_firm (0) +# TODO - Use proper section rel twl ########################################### -# New3ds # Disable main signature checks (1) -seek 00165D64 -test C117491C31D0 -jmpne 20 -set 00204EB070BD +find C117491C31D0 +set 00204EB070BD +rewind -# Patch RSA function to not report invalid signatures (5) -seek 0017474A +# Patch RSA function to not report invalid signatures (4) +# TODO - Check O3DS +find 18ee0020 +fwd 02 set 0120 +rewind -# Disable header Nintendo logo check (not generally needed) (7) -seek 0017553E +# Disable header Nintendo logo check (not generally needed) (8) +# TODO - Check O3DS +find c03006f0 +fwd 02 set 00200000 +rewind -# Disable whitelist check (9) -seek 001756A0 +# Disable whitelist check (12) +find FFF7B6FB set 00200000 +rewind -# Disable cartridge blacklist check (mostly, if not entirely, demo carts) (11) -seek 00175A8E +# Disable cartridge blacklist check (mostly, if not entirely, demo carts) (15) +# TODO - Check O3DS +find 012520000ef0 +fwd 04 set 01200000 +rewind -# Disable save type check (13) -seek 00175A9A -set 01200000 - -# Disable DSi cartridge save exploit check (15) -seek 00175AA6 -set 01200000 - -# Stub function commonly used to compare SHA hashes to always succeed (17) -seek 00175B92 +# Stub function commonly used to compare SHA hashes to always succeed (19) +find 10B51422 set 01207047 +rewind -jmp 36 - -########################################### -# Old3ds - -# Disable main signature checks (20) -seek 001650C0 -set 00204EB070BD +##################################### (22) -# Patch RSA function to not report invalid signatures (22) -seek 00173A0E -set 0120 +# There's not enough context for the patterns below to patch both o3ds and n3ds, so +# we have to split them up. -# Disable header Nintendo logo check (not generally needed) (24) -seek 00174802 -set 00200000 +n3ds +jmpeq 25 +jmp 32 -# Disable whitelist check (26) -seek 00174964 -set 00200000 +# new: (25) -# Disable cartridge blacklist check (mostly, if not entirely, demo carts) (28) -seek 00174D52 +# Disable save type check +find FCF745FE set 01200000 +rewind -# Disable save type check (30) -seek 00174D5E +# Disable DSi cartridge save exploit check (28) +find FCF765FD set 01200000 +rewind -# Disable DSi cartridge save exploit check (32) -seek 00174D6A -set 01200000 +jmp 38 -# Stub function commonly used to compare SHA hashes to always succeed (34) -seek 00174E56 -set 01207047 +# old: (32) + +# Disable save type check +find FCF771FE +set 01200000 +rewind -# end (36) +# Disable DSi cartridge save exploit check (35) +find FCF791FD +set 01200000 +rewind +# end (38) diff --git a/source/interp.c b/source/interp.c index c7d1970..5d37a53 100644 --- a/source/interp.c +++ b/source/interp.c @@ -138,7 +138,7 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) #endif struct mode *current_mode = &modes[set_mode]; - uint32_t offset = 0; + uint32_t offset = 0, new_offset = 0; uint32_t i; @@ -350,10 +350,9 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug) break; case OP_N3DS: if (debug) - log("ver\n"); + log("n3ds\n"); code++; eq = is_n3ds; - code += 2; break; case OP_SEEK: // Jump to offset if greater than or equal if (debug)