forked from Mirror/GodMode9
Only reserve space in trimmed NDS files for RSA key if it exists (#804)
This commit is contained in:
parent
64414e12ab
commit
cae3d272d3
@ -254,7 +254,7 @@ u32 InitCartRead(CartData* cdata) {
|
||||
if (nds_header->device_capacity >= 15) return 1; // too big, not valid
|
||||
if (cdata->cart_size == 0)
|
||||
cdata->cart_size = (128 * 1024) << nds_header->device_capacity;
|
||||
cdata->data_size = nds_header->ntr_rom_size + 0x88;
|
||||
cdata->data_size = nds_header->ntr_rom_size;
|
||||
cdata->arm9i_rom_offset = 0;
|
||||
|
||||
// TWL header
|
||||
@ -273,6 +273,15 @@ u32 InitCartRead(CartData* cdata) {
|
||||
NTR_CmdReadHeader(cdata->storage);
|
||||
if (!NTR_Secure_Init(cdata->storage, NULL, Cart_GetID(), 1)) return 1;
|
||||
}
|
||||
} else {
|
||||
// Check if immediately after the reported cart size
|
||||
// is the magic number string 'ac' (auth code).
|
||||
// If found, add 0x88 bytes for the download play RSA key.
|
||||
u16 rsaMagic;
|
||||
ReadCartBytes(&rsaMagic, cdata->data_size, 2, cdata, false);
|
||||
if(rsaMagic == 0x6361) {
|
||||
cdata->data_size += 0x88;
|
||||
}
|
||||
}
|
||||
|
||||
// store encrypted secure area
|
||||
|
@ -3296,12 +3296,21 @@ u64 GetGameFileTrimmedSize(const char* path) {
|
||||
trimsize = GetAnyFileTrimmedSize(path);
|
||||
} else if (filetype & GAME_NDS) {
|
||||
TwlHeader hdr;
|
||||
if (fvx_qread(path, &hdr, 0, sizeof(TwlHeader), NULL) != FR_OK)
|
||||
if (fvx_qread(path, &hdr, 0, sizeof(TwlHeader), NULL) != FR_OK) {
|
||||
return 0;
|
||||
if (hdr.unit_code != 0x00) // DSi or NDS+DSi
|
||||
} if (hdr.unit_code != 0x00) { // DSi or NDS+DSi
|
||||
trimsize = hdr.ntr_twl_rom_size;
|
||||
else if (hdr.ntr_rom_size) // regular NDS
|
||||
trimsize = hdr.ntr_rom_size + 0x88;
|
||||
} else if (hdr.ntr_rom_size) { // regular NDS
|
||||
trimsize = hdr.ntr_rom_size;
|
||||
|
||||
// Check if immediately after the reported cart size
|
||||
// is the magic number string 'ac' (auth code).
|
||||
// If found, add 0x88 bytes for the download play RSA key.
|
||||
u16 rsaMagic;
|
||||
if(fvx_qread(path, &rsaMagic, trimsize, 2, NULL) == FR_OK && rsaMagic == 0x6361) {
|
||||
trimsize += 0x88;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
u8 hdr[0x200];
|
||||
if (fvx_qread(path, &hdr, 0, 0x200, NULL) != FR_OK)
|
||||
|
Loading…
x
Reference in New Issue
Block a user