]> Chaos Git - corbenik/corbenik.git/commitdiff
Multiple changes:
authorchaoskagami <chaos.kagami@gmail.com>
Sat, 28 May 2016 02:25:45 +0000 (22:25 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sat, 28 May 2016 02:25:45 +0000 (22:25 -0400)
 - Menus now reference config #defines, so config entries can be out of order in file
 - Anti-anti-downgrade fix courtesy of Luma3DS (Thanks, @TuxSH!)

copy.sh
source/config.h
source/menu.c
source/patch/aadowngrade.c [new file with mode: 0644]
source/patcher.c

diff --git a/copy.sh b/copy.sh
index b6e50f95a9b84b645e54944a2ad6ead4d2d56350..10df3f296c55b8a0e0023ec4171689d050085371 100644 (file)
--- 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
index a006a13d01c48885494b0d57050a0a353b7d1403..b9493933e5dc410a8c8dda4ca94c558bccc72972 100644 (file)
@@ -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                                                     \
-    // 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.
index 86e6050acef15f089dafb2982645b79f9c63fb3f..33231e82ec55595eb74b4021d34c51005894aa2c 100644 (file)
 #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 (file)
index 0000000..bdd62e2
--- /dev/null
@@ -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;
+}
index 973e0d4eb8e13212a6f505c53c9091897ca88e95..fb55a2c3a3a5e28f53b5ea725ef8862b318af4fc 100644 (file)
@@ -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;
 }