]> Chaos Git - corbenik/corbenik.git/commitdiff
Fix up a few bugs for something not yet exposed to the assembler, hopefully fix TWL...
authorchaoskagami <chaos.kagami@gmail.com>
Sat, 11 Jun 2016 15:45:02 +0000 (11:45 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sat, 11 Jun 2016 15:45:02 +0000 (11:45 -0400)
host/bytecode_asm.py
patch/twl_fix.pco
source/interp.c

index 1915043aae7c8c317587d85f36d601bcf61d3813..0dd38dc31ae2e550e92314195abfca5165149979 100755 (executable)
@@ -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:
index 006ec736e0f483165fec5762222d076e6f9e66aa..f556ee8a5ae3677014c7a163f458bfe7fa40a75e 100644 (file)
@@ -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)
index c7d19702f3b32d82498ca729c7c7808ea89423c9..5d37a53da408b8dbf6a36d14b1e6e6ae1182f5e3 100644 (file)
@@ -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)