]> Chaos Git - corbenik/corbenik.git/commitdiff
Stuff.
authorchaoskagami <chaos.kagami@gmail.com>
Fri, 10 Jun 2016 17:27:13 +0000 (13:27 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Fri, 10 Jun 2016 17:27:13 +0000 (13:27 -0400)
16 files changed:
README.txt
external/Makefile
external/bits/Makefile [moved from external/svc/Makefile with 75% similarity]
external/bits/README.md [moved from external/svc/README.md with 100% similarity]
external/bits/backdoor.s [moved from external/svc/7b.s with 100% similarity]
external/bits/emunand.s [moved from external/svc/emunand.s with 100% similarity]
external/bits/link.ld [moved from external/svc/link.ld with 100% similarity]
external/bits/reboot_code.s [moved from external/svc/reboot_code.s with 100% similarity]
external/bits/reboot_hook.s [moved from external/svc/reboot_hook.s with 100% similarity]
external/bits/stub.s [moved from external/svc/stub.s with 100% similarity]
source/config.h
source/interp.c
source/menu.c
source/patch/reboot.c
source/patch/svc.c
source/patch_format.h

index 49140f57dc29dba86c914906e69c21daf8057f96..35ac94ee491ab98a721d16ad65172a1f19524ff3 100644 (file)
@@ -15,6 +15,28 @@ You should have recieved a copy either as part of the git repository,
 or as part of the tarball/zipfile you downloaded. If not, get a copy
 here: `http://www.gnu.org/licenses/gpl-3.0.txt`
 
+Upgrading
+-------------------------
+
+Skip to `Installing` if you are installing this for the first time.
+
+When updating Corbenik, usually you should (at minimum) perform the
+following steps to SAFELY update:
+
+ * Delete these files/directories in `/corbenik`:
+   * `cache`
+   * `config`
+   * `boot.log`
+   * `loader.log`
+ * If you're upgrading from earlier versions:
+   * 0.0.6 and older:
+     * Delete everything
+   * 0.0.7
+     * Delete `patch`.
+ * Unzip all files in-place, overwriting if prompted.
+ * Reconfigure settings on boot (follow `Setup` for defaults)
+
+
 Installing
 -------------------------
 
@@ -43,12 +65,26 @@ you can fetch the cetk for each of them to `/corbenik/keys/agb.cetk` and
 `/corbenik/keys/twl.cetk`. Boot up the system, go to system settings, and it
 will extract the firm keys for them after rebooting.
 
+Old 3DS TWL_FIRM (Firmware for DS/DSi games):
+  cetk: http://nus.cdn.c.shop.nintendowifi.net/ccs/download/0004013800000102/cetk
+  firm: http://nus.cdn.c.shop.nintendowifi.net/ccs/download/0004013800000102/00000016
+New 3DS TWL_FIRM (Firmware for DS/DSi games):
+  cetk: http://nus.cdn.c.shop.nintendowifi.net/ccs/download/0004013820000102/cetk
+  firm: http://nus.cdn.c.shop.nintendowifi.net/ccs/download/0004013820000102/00000000
+Old 3DS AGB_FIRM (Firmware for GBA games):
+  cetk: http://nus.cdn.c.shop.nintendowifi.net/ccs/download/0004013800000202/cetk
+  firm: http://nus.cdn.c.shop.nintendowifi.net/ccs/download/0004013800000202/0000000B
+New 3DS AGB_FIRM (Firmware for GBA games):
+  cetk: http://nus.cdn.c.shop.nintendowifi.net/ccs/download/0004013820000202/cetk
+  firm: http://nus.cdn.c.shop.nintendowifi.net/ccs/download/0004013820000202/00000000
+
 On New3DS units, there's additional crypto on arm9loader which requires the 9.6
-key to decrypt. It usually is named ``Slot0x11Key96.bin`, and I also can't tell
+key to decrypt. It usually is named `Slot0x11Key96.bin`, and I also can't tell
 you where to find this, aside from "check Plailect's guide." Corbenik will
 attempt to read this from the root as well as `/corbenik/keys/11.key`.
+In a future version, keydb reading may be implemented, but no guarantees.
 
-The folder `corbenik/locale` is automatically generated language emulation
+The folder `/corbenik/locale` is automatically generated language emulation
 files from 3dbrew for games that only specify one region and one language.
 Games which support more than one language are not generated, because there's
 no 'correct' language. You can remove this if the number of files unnerves
@@ -57,21 +93,25 @@ you. It isn't required. You can also add new files if you have specific needs.
 Setup
 -------------------------
 
-For starters, you'll want to go into options and enable `System Modules` to get
-loader to run patches as well.
+For starters, you'll want to go into options and enable `Loader Replacement`
+to get loader to run patches as well. Even if you don't plan to run any loader
+patches, this will at very least kill ASLR and anti-OOThax/anti-ninjhax
+features in the official Nintendo loader.
 
-If you're using 11.0 NATIVE_FIRM like I suggested, you'll want to tick
-`Svc Replacement` to fix the broken svcBackdoor if you plan on using anything
-which requires it. This includes HBMenu, NTR, etc. Your system will be more
-secure (as in against malicious code, not as in Nintendo) if you leave it off.
+If you're using 11.0 NATIVE_FIRM like I suggested, you may want to tick
+`svcBackdoor Fixup` to fix the broken svcBackdoor if you plan on using anything
+which requires it. This includes HBMenu, some Retroarch cores, etc. Your system
+will be more secure (as in against malicious code, not as in Nintendo) if you
+leave it off.
 
 If you need to use an EmuNAND, you'll want to enable `EmuNAND` in options. If
-you've been using multiple EmuNANDs you can also select the index while you're
-there with A to increase and X to decrease. This supports both Gateway-style
-(first sector at back) and standard copied NANDs (RedNAND)
+you've been using multiple EmuNANDs via Cakes or Luma you can also select the
+index while you're there with A to increase and X to decrease. This supports
+both Gateway-style (first sector at back) and standard copy NANDs (RedNAND)
 
-While you're there, you can enable `Autoboot` if you'd like, including
-`Silent mode` if you're using something like BootAnim9.
+You can enable `Autoboot` if you'd like, including `Silent mode` if you're
+using something like BootAnim9. As of 0.0.8, EmuNAND will be automatically
+disabled on AGB reboot, so you need not worry about your savedata with this.
 
 If you plan to use TWL/AGB patches or have an O3DS, you should enable
 `Reboot Hook` in options.
@@ -115,48 +155,70 @@ Optional, but recommended patches are:
 
 And these YOU SHOULD NOT ENABLE unless you have specialized needs:
 
- * Developer UNITINFO
- * ARM11 XN Disable
- * Force TestMenu
+ * Developer UNITINFO (Pretends to be a developer console/Panda)
+ * ARM11 XN Disable   (Grants +X maps by default)
+ * Force TestMenu     (Boots into TestMenu rather than HOME - requires
+                       it to be installed.)
+
+Before booting, you should select 'Save Configuration' from the menu.
+
+Reporting issues
+-------------------------
+
+If you think you've found a bug, please do the following first, to save
+me some time:
+
+ * Check if a recently enabled patch is the cause of the issue. If so,
+   you should include this in a report
+ * Enable Logging in `Options` and retrieve the files `/corbenik/boot.log`
+   and `/corbenik/loader.log` if they exist.
 
 Credits
 -------------------------
 
 The complete list:
 
- @yifanlu        For the absolutely insane and wonderful idea to use bytecode,
-                 as well as the open source loader replacement.
-                 https://github.com/yifanlu/3ds_injector
+ @yifanlu            For the absolutely insane and wonderful idea to use bytecode,
+                     as well as the open source loader replacement.
+                     https://github.com/yifanlu/3ds_injector
+
+ @mid-kid            General inspiration from Cakes, FIRM decryption code, reboot
+                     assembly code, some code for text display.
+                     https://github.com/mid-kid/CakesForeveryWan
+
+ @Wolfvak            Code segment dumping + loading
 
- @mid-kid        General inspiration from Cakes, FIRM decryption code, reboot
-                 assembly code, some code for text display.
-                 https://github.com/mid-kid/CakesForeveryWan
+ @AuroraWright       RE work, patches, EmuNAND, and Reboot/Firmlaunch C code.
+                     https://github.com/AuroraWright/Luma3ds
 
- @Wolfvak        Code segment dumping + loading
+ @Reisyukaku         For the 'Force TestMenu' patch, and RE work. Also coded
+                     ReiNand, which some parts of Luma are derived from and
+                     thus some parts of this.
 
- @AuroraWright   RE work, patches, EmuNAND, and Reboot/Firmlaunch C code.
-                 https://github.com/AuroraWright/Luma3ds
+ @d0k3               start.s, recursive directory listing, RE work.
+                     https://github.com/d0k3/GodMode9
 
- @Reisyukaku     For the 'Force TestMenu' patch, and RE work.
+ @TuxSH              RE work, code, and patches. Some code in loader is based
+                     on his extensions to it.
 
- @d0k3           start.s, recursive directory listing, RE work.
-                 https://github.com/d0k3/GodMode9
+ @Steveice10         RE work, patch offsets.
 
- @TuxSH          RE work, code, and patches. Some code in loader is based
-                 on his extensions to it.
+ @dark-samus         RE work, screen init.
 
- @Steveice10     RE work, patch offsets.
+ @b1l1s              RE work, screen init.
 
- @dark-samus     RE work, screen init.
+ @Normmatt           RE work, screen init, and sdmmc.c/h
 
- @b1l1s          RE work, screen init.
+ @delebile           RE work, screen init, and also the A9LH version I personally use.
 
- @Normmatt       RE work, screen init, and sdmmc.c/h
+ @smealum            Pioneering the open source hax frontier.
+                     (No actual code of his is in this repo itself, but ctrulib is
+                      basically essential for everything.)
 
- @delebile       RE work, screen init, and also the A9LH version I personally use.
+ @TiniVi             RE work, screen deinit.
 
@smealum        HANS code, and pioneering the open source hax frontier.
Temptress Cerise    A LOT of testing which was really helpful.
 
@TiniVi         RE work, screen deinit.
Crystal the Glaceon A LOT of testing which was really helpful.
 
- CyberConnect2   Because the name originates from .hack, which you should go play.
+ CyberConnect2       Because the name originates from .hack, which you should go play.
index 27b623f7bc104d688a1a495a4e9525f210aca596..bbe93feb7929202750f9d5ba16eba37a5d5767da 100644 (file)
@@ -1,27 +1,27 @@
 .PHONY: all
-all: loader svc screeninit
+all: loader bits screeninit
        mkdir -p ../out/corbenik/module
-       mkdir -p ../out/corbenik/svc
+       mkdir -p ../out/corbenik/bits
        mkdir -p ../out/corbenik/bits
        cp loader/loader.cxi ../out/corbenik/module/loader.cxi
-       cp svc/7b.bin ../out/corbenik/svc/7b.bin
-       cp svc/emunand.bin ../out/corbenik/bits/emunand.bin
-       cp svc/reboot_hook.bin ../out/corbenik/bits/reboot_hook.bin
-       cp svc/reboot_code.bin ../out/corbenik/bits/reboot_code.bin
+       cp bits/backdoor.bin ../out/corbenik/bits/backdoor.bin
+       cp bits/emunand.bin ../out/corbenik/bits/emunand.bin
+       cp bits/reboot_hook.bin ../out/corbenik/bits/reboot_hook.bin
+       cp bits/reboot_code.bin ../out/corbenik/bits/reboot_code.bin
        cp screeninit/build/screeninit.bin ../out/corbenik/bits/screeninit.bin
 
 .PHONY: clean
-clean: clean_loader clean_svc clean_screeninit
-       rm -rf ../out/corbenik/svc
+clean: clean_loader clean_bits clean_screeninit
+       rm -rf ../out/corbenik/bits
        rm -rf ../out/corbenik/module
 
 .PHONY: loader
 loader:
        make -C loader
 
-.PHONY: svc
-svc:
-       make -C svc
+.PHONY: bits
+bits:
+       make -C bits
 
 .PHONY: screeninit
 screeninit:
@@ -31,9 +31,9 @@ screeninit:
 clean_loader:
        make -C loader clean
 
-.PHONY: clean_svc
-clean_svc:
-       make -C svc clean
+.PHONY: clean_bits
+clean_bits:
+       make -C bits clean
 
 .PHONY: clean_screeninit
 screeninit_clean:
similarity index 75%
rename from external/svc/Makefile
rename to external/bits/Makefile
index 600ae212f8b4cdd71e16400b1f702edfb5dab537..a25dfa7cca681a190046d9060983a894f7c16423 100644 (file)
@@ -1,6 +1,6 @@
 PATH := $(PATH):$(DEVKITARM)/bin
 
-all: 7b.bin stub.bin emunand.bin reboot_hook.bin reboot_code.bin
+all: backdoor.bin stub.bin emunand.bin reboot_hook.bin reboot_code.bin
 
 %.o: %.s
        arm-none-eabi-as -o $@ $<
similarity index 100%
rename from external/svc/7b.s
rename to external/bits/backdoor.s
similarity index 100%
rename from external/svc/link.ld
rename to external/bits/link.ld
similarity index 100%
rename from external/svc/stub.s
rename to external/bits/stub.s
index 59316cfca147fde30307b398c00f5249aea9fb2b..100822acb0455ed71cbe69dedcb8d297abd01518 100644 (file)
@@ -88,9 +88,6 @@ struct options_s
 // Enable language emulation.
 #define OPTION_LOADER_LANGEMU 13
 
-// Force replacement of non-null svcs. Normally you don't want this.
-#define OPTION_REPLACE_ALLOCATED_SVC 14
-
 // Ignore patch UUID dependencies. Not recommended.
 #define IGNORE_PATCH_DEPS 14
 
@@ -113,6 +110,7 @@ struct options_s
 #define OPTION_LOADER_DUMPCODE_ALL 20
 
 // Load *all* code sections. This is intended for big patches that are currently not implementable and quick testing.
+// (e.g. SaltySD)
 #define OPTION_LOADER_LOADCODE 21
 
 // Save log files during boot and from loader.
index e413f06c3de25a67d26a4b5ff1aaa8834df54f77..ddf7575c0eb7eb8ad2015839c07bbe2b27777153 100644 (file)
@@ -348,12 +348,6 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug)
                     log("seek\n");
                 code++;
                 offset = code[0] + (code[1] << 8) + (code[2] << 16) + (code[3] << 24);
-                if (offset > current_mode->size) { // Went out of bounds. Error.
-#ifndef LOADER
-                    fprintf(stderr, "%x", offset);
-#endif
-                    abort("seeked out of bounds\n");
-                }
 
                 code += 4;
                 break;
@@ -387,6 +381,14 @@ exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug)
                 abort("Halting startup.\n");
                 break;
         }
+
+        if (offset > current_mode->size) { // Went out of bounds. Error.
+#ifndef LOADER
+            fprintf(stderr, "%x", offset);
+#endif
+            abort("seeked out of bounds\n");
+        }
+
 #ifndef LOADER
         if (debug)
             wait();
index 26d0d0ecf877bacc254bbef0d792784b1bb29088..57d99fc7e070623a45cb30bcd79bb66dc496cacc 100644 (file)
@@ -22,7 +22,7 @@ static struct options_s options[] = {
     // Patches.
     { 0, "\x1b[32;40mGeneral Options\x1b[0m", "", not_option, 0, 0 },
 
-    { OPTION_SVCS, "SVC Replacement", "Replaces ARM11 svc calls, including svcBackdoor. With 11.0 NATIVE_FIRM, you probably want this.", boolean_val, 0, 0 },
+    { OPTION_SVCS, "svcBackdoor Fixup", "Reinserts svcBackdoor on 11.0 NATIVE_FIRM.", boolean_val, 0, 0 },
 
     { OPTION_REBOOT, "Reboot Hook", "Hooks firmlaunch to allow largemem games on o3DS (and allow patching TWL/AGB on all consoles)", boolean_val, 0, 0 },
 
@@ -56,8 +56,6 @@ static struct options_s options[] = {
     // Patches.
     { 0, "\x1b[32;40mDeveloper Options\x1b[0m", "", not_option, 0, 0 },
 
-    { OPTION_REPLACE_ALLOCATED_SVC, "Force svc replace", "Replace ARM11 svc calls even if they exist. Don't use this unless you know what you're doing.",
-      boolean_val, 0, 0 },
     { OPTION_TRACE, "Step Through", "After each important step, [WAIT] will be shown and you'll need to press a key. Debug.", boolean_val, 0, 0 },
     { OPTION_OVERLY_VERBOSE, "Verbose", "Output more debug information than the average user needs.", boolean_val, 0, 0 },
     { OPTION_SAVE_LOGS, "Logging", "Save logs to the corbenik folder. Slows operation a bit.", boolean_val, 0, 0 },
index a7077cb6cbca54ad329e3b5e36dc6ebff59ec2e3..6d36ba83976a63ba6d4c82d4f967393fb83a4e74 100644 (file)
@@ -47,7 +47,7 @@ patch_reboot()
     wait();
 
     // Copy firmlaunch code
-    FILE *f = fopen(PATH_BITS "/reboot_hook.bin", "r");
+    FILE *f = fopen(PATH_REBOOT_HOOK, "r");
     if (!f)
         abort("reboot: hook not found on SD\n");
 
@@ -104,7 +104,7 @@ patch_reboot()
 
     fprintf(stderr, "reboot: rebc @ %x\n", pos_rebc);
 
-    f = fopen(PATH_BITS "/reboot_code.bin", "r");
+    f = fopen(PATH_REBOOT_CODE, "r");
     if (!f)
         abort("reboot: boot not found on SD\n");
 
index 15df9956f0f0c8d969415ba0119bff1240b552ef..752448b359fd5067ac85b76278aaa2079d035401 100644 (file)
@@ -30,11 +30,11 @@ PATCH(services)
     if (!svcTable[0x7B]) {
         fprintf(stderr, "svc: 0x7B (backdoor) missing.\n");
 
-        FILE *data = fopen(PATH_SVC "/7b.bin", "r");
+        FILE *data = fopen(PATH_BACKDOOR, "r");
         uint32_t size = fsize(data);
 
-        fprintf(stderr, "Svc: 7b, %d bytes\n", size);
-        fprintf(stderr, "Svc: Copy code to %x\n", (uint32_t)svc_tab_open);
+        fprintf(stderr, "Svc: backdoor is %d bytes\n", size);
+        fprintf(stderr, "Svc: Read code to %x\n", (uint32_t)svc_tab_open);
 
         fread(svc_tab_open, 1, size, data);
 
index e236551c7723d9847dcf5545111195d693556f68..dc1b0771f12bbeecaf0b0c689bfbc8ac601a6a2a 100644 (file)
 #define PATH_KEYS PATH_CFW "/keys" // Keyfiles will be loaded from this dir, and
                                    // additionally the root if not found.
 
-#define PATH_EXEFS PATH_CFW "/exe" // ExeFS overrides, named by titleid
+#define PATH_EXEFS PATH_CFW "/exe" // ExeFS overrides/dumps, named by titleid
 
 #define PATH_BITS PATH_CFW "/bits" // Path to misc bits we need (emunand code, reboot code, etc)
 
 #define PATH_EMUNAND_CODE PATH_BITS "/emunand.bin"       // Emunand hook.
 #define PATH_SCREENINIT_CODE PATH_BITS "/screeninit.bin" // Screeninit code (ARM11)
+#define PATH_BACKDOOR PATH_BITS "/backdoor.bin"   // svcBackdoor
+#define PATH_REBOOT_HOOK PATH_BITS "/reboot_hook.bin"   // Reboot hook
+#define PATH_REBOOT_CODE PATH_BITS "/reboot_code.bin"   // Reboot entry code
 
 #define PATH_NATIVE_F PATH_FIRMWARES "/native"
 #define PATH_AGB_F PATH_FIRMWARES "/agb"