]> Chaos Git - corbenik/corbenik.git/commitdiff
Okay, irrational breakage...
authorchaoskagami <chaos.kagami@gmail.com>
Fri, 2 Sep 2016 06:19:14 +0000 (02:19 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Fri, 2 Sep 2016 06:19:14 +0000 (02:19 -0400)
source/config-backend-file.c
source/firm/firm.c
source/firm/version.c

index d5edd43fc205c8310460513fe87c1fe7c0188e6c..3ea12e2bb0d043b35b85b2041b8df4dd2652335b 100644 (file)
@@ -65,12 +65,9 @@ update_config()
         updated = 1;
     }
 
-    if (config->firm[0][0] == 0)
-        strncpy(config->firm[0], PATH_NATIVE_F, 255);
-    if (config->firm[1][0] == 0)
-        strncpy(config->firm[1], PATH_TWL_F, 255);
-    if (config->firm[2][0] == 0)
-        strncpy(config->firm[2], PATH_AGB_F, 255);
+    strncpy(config->firm[0], PATH_NATIVE_F, 255);
+    strncpy(config->firm[1], PATH_TWL_F, 255);
+    strncpy(config->firm[2], PATH_AGB_F, 255);
 
     if (updated) {
         save_config(); // Save the configuration.
index c200ea59e82a9f497ddb133f49efb7991a5f1f88..1a7b1fccd77ca5a43387c4ef37fa40aca7d4569f 100644 (file)
@@ -72,6 +72,12 @@ void dump_firm(firm_h** buffer, uint8_t index) {
 
     struct firm_signature* sig = get_firm_info(firm);
 
+    sig->k9l = 0;
+    if(index == 1)
+        sig->k9l = 2;
+
+    fprintf(stderr, "  FIRM: K9L%u, Console:%u, Type:%u\n", sig->k9l, sig->console, sig->type);
+
     if(decrypt_arm9bin((arm9bin_h*)((uint8_t*)firm + firm->section[2].offset), sig)) {
         abort("  Failed to decrypt FIRM%u arm9loader.\n", index);
     }
@@ -327,6 +333,9 @@ extern int patch_services();
 firm_h*
 load_firm(const char *path, const char *path_firmkey, const char *path_cetk, uint32_t *size)
 {
+    if (path == NULL || path_firmkey == NULL || path_cetk == NULL || size == NULL)
+        return NULL;
+
     firm_h *dest;
 
     int status = 0;
@@ -360,6 +369,8 @@ load_firm(const char *path, const char *path_firmkey, const char *path_cetk, uin
 
     struct firm_signature *fsig = get_firm_info(dest);
 
+    fprintf(stderr, "  FIRM: K9L%u, Console:%u, Type:%u\n", fsig->k9l, fsig->console, fsig->type);
+
     // The N3DS firm has an additional encryption layer for ARM9
     if (fsig->console == console_n3ds) {
         // Look for the arm9 section
@@ -428,6 +439,8 @@ boot_firm()
 {
     struct firm_signature *fsig = get_firm_info(firm_loc);
 
+    fprintf(stderr, "  FIRM: K9L%u, Console:%u, Type:%u\n", fsig->k9l, fsig->console, fsig->type);
+
     // Set up the keys needed to boot a few firmwares, due to them being unset,
     // depending on which firmware you're booting from.
     // TODO: Don't use the hardcoded offset.
index 1401d5e108aea6a180e46f596874f9cc655bf77a..a24d5a8502c5f9143bcffd19f16ef47a26887f97 100644 (file)
@@ -27,15 +27,15 @@ get_firm_info(firm_h *firm)
         // Check for the presence of a TWL/AGB only sysmodule
         if( memfind((uint8_t*)firm + firm->section[0].offset, firm->section[0].size, "TwlBg", 5)) {
             signature->type = type_twl;
-//            fprintf(stderr, "  TwlBg module found; probably TWL\n");
+            fprintf(stderr, "  TwlBg module found; probably TWL\n");
         } else if( memfind((uint8_t*)firm + firm->section[0].offset, firm->section[0].size, "AgbBg", 5)) {
             signature->type = type_agb;
-//            fprintf(stderr, "  AgbBg module found; probably AGB\n");
+            fprintf(stderr, "  AgbBg module found; probably AGB\n");
         } else {
-//            fprintf(stderr, "  Warning: Native, but there is a 4th section. Report this IMMEDIATELY.\n");
+            fprintf(stderr, "  Warning: Native, but there is a 4th section. Report this IMMEDIATELY.\n");
         }
     } else {
-//        fprintf(stderr, "  Section #4 is empty; this is probably native\n");
+        fprintf(stderr, "  Section #4 is empty; this is probably native\n");
     }
 
     for (firm_section_h *section = firm->section; section < firm->section + 4; section++) {
@@ -49,10 +49,10 @@ get_firm_info(firm_h *firm)
                 //        Only N3DS FIRMs have this property.
                 uint8_t* k9l = (uint8_t*)memfind((uint8_t*)firm + section->offset, section->size, "K9L", 3);
                 if (k9l == NULL) { // O3DS.
-//                    fprintf(stderr, "  No K9L; this is likely an O3DS FIRM\n");
+                    fprintf(stderr, "  No K9L; this is likely an O3DS FIRM\n");
                     signature->console = console_o3ds;
                 } else { // N3DS.
-//                    fprintf(stderr, "  K9L found; this is likely an N3DS FIRM\n");
+                    fprintf(stderr, "  K9L found; this is likely an N3DS FIRM\n");
                     signature->console = console_n3ds;
                     signature->k9l = (unsigned int)(k9l[3] - '0'); // String is "K9LN" where N is the version
                 }
@@ -64,10 +64,10 @@ get_firm_info(firm_h *firm)
                 //        which allows determining which console it is intended for.
                 if (section->address == 0x08006800) { // O3DS entry
                     signature->console = console_o3ds;
-//                    fprintf(stderr, "  Entry point seems correct for O3DS\n");
+                    fprintf(stderr, "  Entry point seems correct for O3DS\n");
                 } else if (section->address == 0x08006000) { // N3DS entry
                     signature->console = console_n3ds;
-//                    fprintf(stderr, "  Entry point seems correct for N3DS\n");
+                    fprintf(stderr, "  Entry point seems correct for N3DS\n");
                 }
             }