From: chaoskagami Date: Fri, 2 Sep 2016 06:19:14 +0000 (-0400) Subject: Okay, irrational breakage... X-Git-Tag: v0.3.0~22 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=a648cb6ce2f3afd069c57eb71bcfa4e737ba42a0;p=corbenik%2Fcorbenik.git Okay, irrational breakage... --- diff --git a/source/config-backend-file.c b/source/config-backend-file.c index d5edd43..3ea12e2 100644 --- a/source/config-backend-file.c +++ b/source/config-backend-file.c @@ -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. diff --git a/source/firm/firm.c b/source/firm/firm.c index c200ea5..1a7b1fc 100644 --- a/source/firm/firm.c +++ b/source/firm/firm.c @@ -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. diff --git a/source/firm/version.c b/source/firm/version.c index 1401d5e..a24d5a8 100644 --- a/source/firm/version.c +++ b/source/firm/version.c @@ -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"); } }