forked from Mirror/GodMode9
Improve FIRM v2.1.0 mount code
... maybe all older FIRMS, unsure.
This commit is contained in:
parent
3ac2297f39
commit
c93295df42
@ -9,6 +9,7 @@
|
||||
|
||||
#define FIRM_MAX_SIZE 0x400000 // 4MB, due to FIRM partition size
|
||||
#define ARM9BIN_OFFSET 0x800
|
||||
#define ARM11V2_OFFSET 0x2B000
|
||||
|
||||
// see: https://www.3dbrew.org/wiki/FIRM#Firmware_Section_Headers
|
||||
typedef struct {
|
||||
|
@ -415,23 +415,26 @@ bool BuildVGameFirmDir(void) {
|
||||
}
|
||||
} else if (section->type == 1) { // ARM11 section, search for modules
|
||||
NcchHeader firm_ncch;
|
||||
for (u32 p = 0; p < section->size; p += firm_ncch.size * NCCH_MEDIA_UNIT) {
|
||||
char name[8];
|
||||
if ((ReadImageBytes((u8*) &firm_ncch, section->offset + p, 0x200) != 0) ||
|
||||
(ReadImageBytes((u8*) name, section->offset + p + 0x200, 0x8) != 0) ||
|
||||
(ValidateNcchHeader(&firm_ncch) != 0))
|
||||
break;
|
||||
|
||||
snprintf(templates[n].name, 32, NAME_FIRM_NCCH, firm_ncch.programId, name, ".app");
|
||||
templates[n].offset = section->offset + p;
|
||||
templates[n].size = firm_ncch.size * NCCH_MEDIA_UNIT;
|
||||
templates[n].keyslot = 0xFF;
|
||||
templates[n].flags = VFLAG_NCCH;
|
||||
n++;
|
||||
memcpy(templates + n, templates + n - 1, sizeof(VirtualFile));
|
||||
snprintf(templates[n].name, 32, NAME_FIRM_NCCH, firm_ncch.programId, name, "");
|
||||
templates[n].flags |= VFLAG_DIR;
|
||||
n++;
|
||||
for (u32 v = 0; v < 2; v++) {
|
||||
u32 start = v ? ARM11V2_OFFSET : 0;
|
||||
for (u32 p = start; p < section->size; p += firm_ncch.size * NCCH_MEDIA_UNIT) {
|
||||
char name[8];
|
||||
if ((ReadImageBytes((u8*) &firm_ncch, section->offset + p, 0x200) != 0) ||
|
||||
(ReadImageBytes((u8*) name, section->offset + p + 0x200, 0x8) != 0) ||
|
||||
(ValidateNcchHeader(&firm_ncch) != 0))
|
||||
break;
|
||||
|
||||
snprintf(templates[n].name, 32, NAME_FIRM_NCCH, firm_ncch.programId, name, ".app");
|
||||
templates[n].offset = section->offset + p;
|
||||
templates[n].size = firm_ncch.size * NCCH_MEDIA_UNIT;
|
||||
templates[n].keyslot = 0xFF;
|
||||
templates[n].flags = VFLAG_NCCH;
|
||||
n++;
|
||||
memcpy(templates + n, templates + n - 1, sizeof(VirtualFile));
|
||||
snprintf(templates[n].name, 32, NAME_FIRM_NCCH, firm_ncch.programId, name, "");
|
||||
templates[n].flags |= VFLAG_DIR;
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user