From: chaoskagami Date: Sat, 28 May 2016 02:25:45 +0000 (-0400) Subject: Multiple changes: X-Git-Tag: stable-1~37 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=36302feb32c0389eebbf6d95a4d494ee6ac22649;p=corbenik%2Fcorbenik.git Multiple changes: - Menus now reference config #defines, so config entries can be out of order in file - Anti-anti-downgrade fix courtesy of Luma3DS (Thanks, @TuxSH!) --- diff --git a/copy.sh b/copy.sh index b6e50f9..10df3f2 100644 --- a/copy.sh +++ b/copy.sh @@ -4,7 +4,9 @@ # You don't and shouldn't need to use it. mnt=/media/sd -dev=/dev/sdc +dev=/dev/sdd + +mnt=/mnt/ext1 mount ${dev}1 $mnt || exit 0 cp out/arm9loaderhax.bin $mnt/anim/boot/none.bin || exit 0 diff --git a/source/config.h b/source/config.h index a006a13..b949393 100644 --- a/source/config.h +++ b/source/config.h @@ -52,22 +52,24 @@ struct options_s #define OPTION_TRACE 7 // Pause for A key on each step. #define OPTION_TRANSP_BG 8 // Background color is not drawn under text. -#define OPTION_NO_CLEAR_BG \ - 9 // Framebuffer is preserved from whatever ran before us. +#define OPTION_NO_CLEAR_BG 9 + // Framebuffer is preserved from whatever ran before us. #define OPTION_READ_ME 10 // Remove Help/Readme from menu. #define OPTION_LOADER_CPU_L2 11 // Enable L2 cache. #define OPTION_LOADER_CPU_800MHZ 12 // Enable 800Mhz mode. #define OPTION_LOADER_LANGEMU 13 // Enable 800Mhz mode. -#define OPTION_REPLACE_ALLOCATED_SVC \ - 14 // Replace allocated services. Normally you don't want this. +#define OPTION_REPLACE_ALLOCATED_SVC 14 + // Replace allocated services. Normally you don't want this. #define IGNORE_PATCH_DEPS 14 // Ignore patch UUID dependencies. Not recommended. -#define IGNORE_BROKEN_SHIT \ - 15 // Allow enabling patches which are marked as 'incompatible'. Chances are +#define IGNORE_BROKEN_SHIT 15 + // Allow enabling patches which are marked as 'incompatible'. Chances are // there's a reason. +#define OPTION_AADOWNGRADE 16 // Anti-anti-downgrade. + //#define HEADER_COLOR 12 // Color of header text. //#define BG_COLOR 13 // Color of background. //#define TEXT_COLOR 14 // Color of most text. diff --git a/source/menu.c b/source/menu.c index 86e6050..33231e8 100644 --- a/source/menu.c +++ b/source/menu.c @@ -11,31 +11,39 @@ #define MENU_POWER 7 #define MENU_BOOTME 8 +#define OPTION_AADOWNGRADE 16 // Anti-anti-downgrade. + static struct options_s options[] = { - { 0, "Signature Patch", boolean_val, 0, 0 }, - { 1, "FIRM Protection", boolean_val, 0, 0 }, - { 2, "SysModule Replacement", boolean_val, 0, 0 }, - { 3, "Service Replacement", boolean_val, 0, 0 }, - { 4, "ARM9 Thread", boolean_val, 0, 0 }, - { 5, "Autoboot", boolean_val, 0, 0 }, - { 6, "Silence w/ Autoboot", boolean_val, 0, 0 }, - { 7, "Step through with button", boolean_val, 0, 0 }, + { OPTION_SIGPATCH, "Signature Patch", boolean_val, 0, 0 }, + + { OPTION_FIRMPROT, "FIRM Protection", boolean_val, 0, 0 }, + + { OPTION_LOADER, "System Modules (loader)", boolean_val, 0, 0 }, + { OPTION_LOADER_CPU_L2, " CPU - L2 cache", boolean_val, 0, 0 }, + { OPTION_LOADER_CPU_800MHZ, " CPU - 800Mhz", boolean_val, 0, 0 }, + { OPTION_LOADER_LANGEMU, " Language Emulation", boolean_val, 0, 0 }, + + { OPTION_SERVICES, "Service Replacement", boolean_val, 0, 0 }, + { OPTION_REPLACE_ALLOCATED_SVC, " Force replacement (unsafe)", boolean_val, 0, 0 }, + + { OPTION_AADOWNGRADE, "Anti-anti-downgrade", boolean_val, 0, 0 }, - { 8, "Don't draw background color", boolean_val, 0, 0 }, - { 9, "Preserve framebuffer data", boolean_val, 0, 0 }, + { OPTION_ARM9THREAD, "ARM9 Thread", boolean_val, 0, 0 }, - { 10, "Hide Help from menu", boolean_val, 0, 0 }, + { OPTION_AUTOBOOT, "Autoboot", boolean_val, 0, 0 }, + { OPTION_SILENCE, "Silence w/ Autoboot", boolean_val, 0, 0 }, + { OPTION_TRACE, "Step through with button", boolean_val, 0, 0 }, - { 11, "Loader: CPU L2 enable", boolean_val, 0, 0 }, - { 12, "Loader: CPU 800Mhz mode", boolean_val, 0, 0 }, - { 13, "Loader: Language Emulation", boolean_val, 0, 0 }, + { OPTION_TRANSP_BG, "Don't draw background color", boolean_val, 0, 0 }, + { OPTION_NO_CLEAR_BG, "Preserve framebuffer data", boolean_val, 0, 0 }, - { 14, "Svc: Force replace allocated", boolean_val, 0, 0 }, + { OPTION_READ_ME, "Hide Help from menu", boolean_val, 0, 0 }, - { 15, "No dependency tracking", boolean_val, 0, 0 }, - { 16, "Allow unsafe options", boolean_val, 0, 0 }, + { IGNORE_PATCH_DEPS, "No dependency tracking", boolean_val, 0, 0 }, + { IGNORE_BROKEN_SHIT, "Allow unsafe options", boolean_val, 0, 0 }, + // Sentinel. { -1, "", 0, 0, 0 }, }; diff --git a/source/patch/aadowngrade.c b/source/patch/aadowngrade.c new file mode 100644 index 0000000..bdd62e2 --- /dev/null +++ b/source/patch/aadowngrade.c @@ -0,0 +1,23 @@ +#include "patch_file.h" + +// Do you like examples? + +PATCH(aadowngrade) +{ + uint8_t* firm_mem = (uint8_t*)firm_p9_exefs + sizeof(exefs_h) + + firm_p9_exefs->fileHeaders[0].offset; + uint32_t size = firm_p9_exefs->fileHeaders[0].size; + + const uint8_t pattern[] = {0x89, 0x0A, 0x81, 0x42, 0x02, 0xD2}; + + uint8_t *off = memfind(firm_mem, size, pattern, 6); + + if(off == NULL) + return 1; // Not found. + + fprintf(stderr, "aadowngrade: %x\n", (uint32_t)off); + + off[5] = 0xE0; + + return 0; +} diff --git a/source/patcher.c b/source/patcher.c index 973e0d4..fb55a2c 100644 --- a/source/patcher.c +++ b/source/patcher.c @@ -14,6 +14,7 @@ extern int patch_signatures(); extern int patch_firmprot(); extern int patch_services(); extern int patch_modules(); +extern int patch_aadowngrade(); extern int doing_autoboot; @@ -37,25 +38,23 @@ patch_firm_all() // Use builtin signature patcher? - wait(); - if (config.options[OPTION_SIGPATCH]) { // TODO - Patch menu. This is okay-ish for now. // if(execp(PATH_PATCHES "/signatures.vco")) { if (patch_signatures()) { abort("Fatal. Sigpatch has failed."); } - } - wait(); + wait(); + } if (config.options[OPTION_FIRMPROT]) { if (patch_firmprot()) { abort("Fatal. Firmprot has failed."); } - } - wait(); + wait(); + } // Replace loader? if (config.options[OPTION_LOADER]) { @@ -63,15 +62,15 @@ patch_firm_all() abort("Fatal. Service patch has failed."); } // This requires OPTION_SIGPATCH. + wait(); } - wait(); - // Inject services? if (config.options[OPTION_SERVICES]) { if (patch_services()) { abort("Fatal. Service patch has failed."); } + wait(); } // Use ARM9 hook thread? @@ -79,9 +78,16 @@ patch_firm_all() // Yes. // FIXME - NYI + wait(); } - wait(); + if (config.options[OPTION_AADOWNGRADE]) { + if (patch_aadowngrade()) { + abort("Anti-anti-downgrade patch failed."); + } + + wait(); + } return 0; }