return NULL;
}
- // If this is a FIRM and not a k9l decrypted FIRM...
+ // If the firm's K9L is not decrypted...
if (!memcmp(firm->magic, "FIRM", 4) && memcmp(firm->magic + 4, "DEC", 3)) {
if (sig->console == console_n3ds) {
if (dec_k9l(firm)) {
// Recalc section hash.
sha256sum(arm9->hash, (uint8_t*)firm + arm9->offset, arm9->size);
- // Magic like D9.
+ // FIXME - Note that this is not technically correct as of recent 3dbrew docs;
+ // the second reserved field is "boot priority". We probably should stop tampering
+ // with it once firmhax becomes relevant, preferably sooner than that.
memcpy(firm->magic, "FIRMDEC", 7);
free(sig);
uint32_t offset;
uint32_t address;
uint32_t size;
- uint32_t type; // Firmware Type ('0'=ARM9/'1'=ARM11)
+ uint32_t type; // Copy method (0=NDMA/ARM9, 1=XDMA/ARM11, 2=CPU copy)
uint8_t hash[0x20]; // SHA-256 Hash of Firmware Section
} __attribute__((packed)) firm_section_h; // 0x30
typedef struct firm_h
{
- char magic[8]; // "FIRM" normally, but D9 has this as "FIRMDEC"
+ char magic[4]; // "FIRM" normally.
+ uint32_t bootprio; // Boot priority (normally 0)
uint32_t a11Entry; // ARM11 entry
uint32_t a9Entry; // ARM9 entry
- uint8_t reserved2[0x30];
+ uint8_t reserved[0x30];
firm_section_h section[4];
uint8_t sig[0x100];
} __attribute__((packed)) firm_h;