Read ConsoleID register, if available

This commit is contained in:
RocketRobz 2024-04-25 12:44:03 -06:00
parent ab04f98396
commit e5d85dd5cd
2 changed files with 36 additions and 20 deletions

View File

@ -145,17 +145,23 @@ int main() {
} }
if (isDSiMode() || ((REG_SCFG_EXT & BIT(17)) && (REG_SCFG_EXT & BIT(18)))) { if (isDSiMode() || ((REG_SCFG_EXT & BIT(17)) && (REG_SCFG_EXT & BIT(18)))) {
/*for (int i = 0; i < 8; i++) {
*(u8*)(0x2FFFD00+i) = *(u8*)(0x4004D07-i); // Get ConsoleID
}*/
// For getting ConsoleID without reading from 0x4004D00... // For getting ConsoleID without reading from 0x4004D00...
u8 *out=(u8*)0x02F00000;
memset(out, 0, 16);
// first check whether we can read the console ID directly and it was not hidden by SCFG
if (((*(vu16*)0x04004000) & (1u << 10)) == 0 && ((*(vu8*)0x04004D08) & 0x1) == 0)
{
// The console id registers are readable, so use them!
memcpy(out, (u8*)0x04004D00, 8);
}
if(out[0] == 0 || out[1] == 0) {
u8 base[16]={0}; u8 base[16]={0};
u8 in[16]={0}; u8 in[16]={0};
u8 iv[16]={0}; u8 iv[16]={0};
u8 *scratch=(u8*)0x02F00200; u8 *scratch=(u8*)0x02F00200;
u8 *out=(u8*)0x02F00000;
u8 *key3=(u8*)0x40044D0; u8 *key3=(u8*)0x40044D0;
aes(in, base, iv, 2); aes(in, base, iv, 2);
@ -174,6 +180,7 @@ int main() {
} }
} }
} }
}
fifoSendValue32(FIFO_USER_03, REG_SCFG_EXT); fifoSendValue32(FIFO_USER_03, REG_SCFG_EXT);
fifoSendValue32(FIFO_USER_07, *(u16*)(0x4004700)); fifoSendValue32(FIFO_USER_07, *(u16*)(0x4004700));

View File

@ -31,8 +31,17 @@ void getConsoleID(u8 *consoleID){
u8 key_x[16];////key3_x - contains a DSi console id (which just happens to be the LFCS on 3ds) u8 key_x[16];////key3_x - contains a DSi console id (which just happens to be the LFCS on 3ds)
u8 key_y[16] = {0x76, 0xDC, 0xB9, 0x0A, 0xD3, 0xC4, 0x4D, 0xBD, 0x1D, 0xDD, 0x2D, 0x20, 0x05, 0x00, 0xA0, 0xE1}; //key3_y NAND constant u8 key_y[16] = {0x76, 0xDC, 0xB9, 0x0A, 0xD3, 0xC4, 0x4D, 0xBD, 0x1D, 0xDD, 0x2D, 0x20, 0x05, 0x00, 0xA0, 0xE1}; //key3_y NAND constant
u8 empty_buff[8] = {0};
tonccpy(key, fifo, 16); //receive the goods from arm7 tonccpy(key, fifo, 16); //receive the goods from arm7
if(memcmp(key + 8, empty_buff, 8) == 0)
{
//we got the consoleid directly or nothing at all, don't treat this as key3 output
tonccpy(consoleID, key, 8);
return;
}
F_XY_reverse((uint32_t*)key, (uint32_t*)key_xy); //work backwards from the normalkey to get key_x that has the consoleID F_XY_reverse((uint32_t*)key, (uint32_t*)key_xy); //work backwards from the normalkey to get key_x that has the consoleID
for(int i=0;i<16;i++){ for(int i=0;i<16;i++){