Add a hacky workaround for problematic carts

This adds a few strategically placed dummy commands which skip the bad
responses, allowing the cart to be dumped.
This commit is contained in:
Yuri Kunde Schlesner 2015-05-25 17:46:00 -03:00
parent ff6e6862ff
commit 43554a68d3
3 changed files with 11 additions and 0 deletions

View File

@ -189,3 +189,10 @@ void Cart_Secure_Init(u32 *buf, u32 *out)
ioDelay(0xF0000); ioDelay(0xF0000);
} }
} }
void Cart_Dummy(void) {
// Sends a dummy command to skip encrypted responses some problematic carts send.
u32 test;
const u32 A2_cmd[4] = { 0xA2000000, 0x00000000, rand1, rand2 };
CTR_SendCommand(A2_cmd, 4, 1, 0x100822C, &test);
}

View File

@ -22,3 +22,4 @@ void Cart_Init(void);
int Cart_IsInserted(void); int Cart_IsInserted(void);
u32 Cart_GetID(void); u32 Cart_GetID(void);
void Cart_Secure_Init(u32* buf, u32* out); void Cart_Secure_Init(u32* buf, u32* out);
void Cart_Dummy(void);

View File

@ -66,6 +66,7 @@ restart_program:
u32 blocks = 1 * 1024 * 1024 / mediaUnit; //1MB of blocks u32 blocks = 1 * 1024 * 1024 / mediaUnit; //1MB of blocks
// Read out the header 0x0000-0x1000 // Read out the header 0x0000-0x1000
Cart_Dummy();
CTR_CmdReadData(0, mediaUnit, 0x1000 / mediaUnit, target); CTR_CmdReadData(0, mediaUnit, 0x1000 / mediaUnit, target);
u32 NCSD_magic = *(u32*)(&target[0x100]); u32 NCSD_magic = *(u32*)(&target[0x100]);
@ -105,6 +106,8 @@ restart_program:
u8* read_ptr = target; u8* read_ptr = target;
while (read_ptr < target + target_buf_size && current_sector < cartSize) { while (read_ptr < target + target_buf_size && current_sector < cartSize) {
Cart_Dummy();
Cart_Dummy();
CTR_CmdReadData(current_sector, mediaUnit, blocks, read_ptr); CTR_CmdReadData(current_sector, mediaUnit, blocks, read_ptr);
read_ptr += mediaUnit * blocks; read_ptr += mediaUnit * blocks;
current_sector += blocks; current_sector += blocks;