d0k3 / GodMode9

GodMode9 Explorer - A full access file browser for the Nintendo 3DS console :godmode:
GNU General Public License v3.0
2.15k stars 194 forks source link

Fix dumping of TWL ROM images flashed to NTR dev carts #645

Closed GerbilSoft closed 3 years ago

GerbilSoft commented 3 years ago

We've encountered a few NTR dev cartridges that have TWL-enhanced ROM images flashed to them. These cartridges work fine on a Nintendo DS, and on some 3DS units. Attempting to dump them with GodMode9 (and wooddumper) fails because the ROM header indicates that the cartridge is TWL-enhanced, but the NTR dev cart doesn't support the TWL secure area init command (0x3D), so TWL key exchange fails.

This PR checks the TWL flag in the chip ID. If it's not present, then it won't attempt to use TWL secure area init, even if the TWL flag is set in the ROM header.

We're also using the ROM size value in the chip ID now for the full cartridge size if it's present. If not, it falls back to using the ROM header value.

d0k3 commented 3 years ago

Okay, this already looks pretty good! It may also fix #457. Will this have any adverse effects on carts that previously worked?

d0k3 commented 3 years ago

Test build here: https://f.secretalgorithm.com/SPO0o/godmode9-v1.9.2pre1-21-titleman-devcartdump.zip

GerbilSoft commented 3 years ago

This shouldn't affect other carts that worked before:

I don't think it'll fix dumping TWL dev carts. That requires using the TWL secure init command, but with a different Blowfish key. I did extract the Blowfish key, but I'm not sure if it can be included in GM9 directly, or if there's any way to properly distinguish between retail and dev carts.

d0k3 commented 3 years ago

Partially merged. The gamecart ID will be added to the filename, thus the additional file is not required. Everything else is included.