From f9ac26078b7d88803ea7079490f419b4a0bfe660 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Sun, 20 Oct 2019 18:52:33 +0200 Subject: [PATCH] look for NAND nocash footer at the end of the file rather than using a hardcoded offset. check whether the footer is present. --- src/DSi.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/DSi.cpp b/src/DSi.cpp index 71ef6d3d..15f06a2d 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); }