From 149d0d42df7ac9a41b0c6c2a89bdea813cd69695 Mon Sep 17 00:00:00 2001 From: RocketRobz Date: Wed, 2 Dec 2020 23:22:56 -0700 Subject: [PATCH] Add footer check, and print if sectors we're written --- arm9/source/arm9.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/arm9/source/arm9.c b/arm9/source/arm9.c index 4ef0a0f..c55a5e3 100644 --- a/arm9/source/arm9.c +++ b/arm9/source/arm9.c @@ -155,12 +155,23 @@ int restoreNAND(nocash_footer_t *footer){ wait(60); //don't spam getbatterylevel too much } - char *filename="nand.bin"; int fail=0; + bool nandWritten = false; FILE *f = fopen("nand.bin", "rb"); if(!f) death("Could not open nand file"); + fseek(f, (rwTotal==0xF580000 ? 0xF580000 : 0xF000000)+0x10, SEEK_SET); + + u8 CID[16]; + u8 consoleID[8]; + fread(&CID, 1, 16, f); + fread(&consoleID, 1, 8, f); + + if((memcmp(footer->nand_cid, &CID, 16) != 0) || (memcmp(footer->consoleid, &consoleID, 8) != 0)) death("Footer does not match"); + + fseek(f, 0, SEEK_SET); + iprintf("Restoring... \n"); iprintf("Do not turn off the power.\n"); iprintf("Progress: 0%% \r"); @@ -185,6 +196,7 @@ int restoreNAND(nocash_footer_t *footer){ fail=1; break; } + nandWritten = true; } iprintf("Progress: %lu%% \r", (i+0x200)/(rwTotal/100)); } @@ -194,7 +206,7 @@ int restoreNAND(nocash_footer_t *footer){ fclose(f); } - iprintf("\nDone.\nPress START to exit"); + iprintf(nandWritten ? "\nDone. Sectors we're written.\nPress START to exit" : "\nDone. No sectors we're written.\nPress START to exit"); done=1; return fail;