diff options
author | Arisotura <thetotalworm@gmail.com> | 2019-10-20 18:52:33 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2019-10-20 18:52:33 +0200 |
commit | f9ac26078b7d88803ea7079490f419b4a0bfe660 (patch) | |
tree | db5c4d58106e534e1a11f6224521c302c4295e76 /src | |
parent | 1c72df43ab8a45c3d7253274d8b1cb6e286a41eb (diff) |
look for NAND nocash footer at the end of the file rather than using a hardcoded offset. check whether the footer is present.
Diffstat (limited to 'src')
-rw-r--r-- | src/DSi.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/DSi.cpp b/src/DSi.cpp index 71ef6d3..15f06a2 100644 --- a/src/DSi.cpp +++ b/src/DSi.cpp @@ -361,12 +361,25 @@ bool LoadNAND() #define printhex(str, size) { for (int z = 0; z < (size); z++) printf("%02X", (str)[z]); printf("\n"); } #define printhex_rev(str, size) { for (int z = (size)-1; z >= 0; z--) printf("%02X", (str)[z]); printf("\n"); } - fseek(f, 0xF000010, SEEK_SET); + // read the nocash footer + + fseek(f, -0x40, SEEK_END); + + char nand_footer[16]; + const char* nand_footer_ref = "DSi eMMC CID/CPU"; + fread(nand_footer, 1, 16, f); + if (memcmp(nand_footer, nand_footer_ref, 16)) + { + printf("ERROR: NAND missing nocash footer\n"); + fclose(f); + return false; + } + fread(eMMC_CID, 1, 16, f); fread(&ConsoleID, 1, 8, f); printf("eMMC CID: "); printhex(eMMC_CID, 16); - printf("Console ID: %llx\n", ConsoleID); + printf("Console ID: %016llX\n", ConsoleID); fclose(f); } |