forked from Mirror/GodMode9
gamecart: Use the chip ID's TWL flag to check if we should do TWL secure area init.
It's possible to flash a TWL-enhanced ROM image to an NTR dev cart. This cart would function properly as a Nintendo DS game, but might have issues on a DSi or 3DS. GodMode9 couldn't dump this type of cartridge before because the ROM header indicates TWL, but the cartridge doesn't understand the 0x3D TWL secure area init command, so key exchange failed.
This commit is contained in:
parent
cadd21508f
commit
d63db4bc6d
@ -144,9 +144,14 @@ u32 InitCartRead(CartData* cdata) {
|
|||||||
if ((cdata->arm9i_rom_offset < nds_header->ntr_rom_size) ||
|
if ((cdata->arm9i_rom_offset < nds_header->ntr_rom_size) ||
|
||||||
(cdata->arm9i_rom_offset + MODC_AREA_SIZE > cdata->data_size))
|
(cdata->arm9i_rom_offset + MODC_AREA_SIZE > cdata->data_size))
|
||||||
return 1; // safety first
|
return 1; // safety first
|
||||||
Cart_Init();
|
|
||||||
NTR_CmdReadHeader(cdata->twl_header);
|
// Some NTR dev carts have TWL ROMs flashed to them.
|
||||||
if (!NTR_Secure_Init(cdata->twl_header, Cart_GetID(), 1)) return 1;
|
// We'll only want to use TWL secure init if this is a TWL cartridge.
|
||||||
|
if (cdata->cart_id & 0x40000000U) { // TWL cartridge
|
||||||
|
Cart_Init();
|
||||||
|
NTR_CmdReadHeader(cdata->twl_header);
|
||||||
|
if (!NTR_Secure_Init(cdata->twl_header, Cart_GetID(), 1)) return 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// last safety check
|
// last safety check
|
||||||
|
Loading…
x
Reference in New Issue
Block a user