From: chaoskagami Date: Fri, 10 Jun 2016 17:27:13 +0000 (-0400) Subject: Stuff. X-Git-Tag: v0.0.9~13 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=595cbea3e224dda0acc007ef1b3e448ec9602953;p=corbenik%2Fcorbenik.git Stuff. --- diff --git a/README.txt b/README.txt index 49140f5..35ac94e 100644 --- a/README.txt +++ b/README.txt @@ -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. diff --git a/external/Makefile b/external/Makefile index 27b623f..bbe93fe 100644 --- a/external/Makefile +++ b/external/Makefile @@ -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: diff --git a/external/svc/Makefile b/external/bits/Makefile similarity index 75% rename from external/svc/Makefile rename to external/bits/Makefile index 600ae21..a25dfa7 100644 --- a/external/svc/Makefile +++ b/external/bits/Makefile @@ -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 $@ $< diff --git a/external/svc/README.md b/external/bits/README.md similarity index 100% rename from external/svc/README.md rename to external/bits/README.md diff --git a/external/svc/7b.s b/external/bits/backdoor.s similarity index 100% rename from external/svc/7b.s rename to external/bits/backdoor.s diff --git a/external/svc/emunand.s b/external/bits/emunand.s similarity index 100% rename from external/svc/emunand.s rename to external/bits/emunand.s diff --git a/external/svc/link.ld b/external/bits/link.ld similarity index 100% rename from external/svc/link.ld rename to external/bits/link.ld diff --git a/external/svc/reboot_code.s b/external/bits/reboot_code.s similarity index 100% rename from external/svc/reboot_code.s rename to external/bits/reboot_code.s diff --git a/external/svc/reboot_hook.s b/external/bits/reboot_hook.s similarity index 100% rename from external/svc/reboot_hook.s rename to external/bits/reboot_hook.s diff --git a/external/svc/stub.s b/external/bits/stub.s similarity index 100% rename from external/svc/stub.s rename to external/bits/stub.s diff --git a/source/config.h b/source/config.h index 59316cf..100822a 100644 --- a/source/config.h +++ b/source/config.h @@ -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. diff --git a/source/interp.c b/source/interp.c index e413f06..ddf7575 100644 --- a/source/interp.c +++ b/source/interp.c @@ -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(); diff --git a/source/menu.c b/source/menu.c index 26d0d0e..57d99fc 100644 --- a/source/menu.c +++ b/source/menu.c @@ -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 }, diff --git a/source/patch/reboot.c b/source/patch/reboot.c index a7077cb..6d36ba8 100644 --- a/source/patch/reboot.c +++ b/source/patch/reboot.c @@ -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"); diff --git a/source/patch/svc.c b/source/patch/svc.c index 15df995..752448b 100644 --- a/source/patch/svc.c +++ b/source/patch/svc.c @@ -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); diff --git a/source/patch_format.h b/source/patch_format.h index e236551..dc1b077 100644 --- a/source/patch_format.h +++ b/source/patch_format.h @@ -50,12 +50,15 @@ #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"