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.
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);
}
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;
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
{
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.
// 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++) {
// 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
}
// 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");
}
}