mirror of
https://github.com/rvtr/SafeNANDManager.git
synced 2026-01-26 13:43:04 -05:00
Add footer check, and print if sectors we're written
This commit is contained in:
parent
c24113f20d
commit
149d0d42df
@ -155,12 +155,23 @@ int restoreNAND(nocash_footer_t *footer){
|
|||||||
wait(60); //don't spam getbatterylevel too much
|
wait(60); //don't spam getbatterylevel too much
|
||||||
}
|
}
|
||||||
|
|
||||||
char *filename="nand.bin";
|
|
||||||
int fail=0;
|
int fail=0;
|
||||||
|
bool nandWritten = false;
|
||||||
|
|
||||||
FILE *f = fopen("nand.bin", "rb");
|
FILE *f = fopen("nand.bin", "rb");
|
||||||
if(!f) death("Could not open nand file");
|
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("Restoring... \n");
|
||||||
iprintf("Do not turn off the power.\n");
|
iprintf("Do not turn off the power.\n");
|
||||||
iprintf("Progress: 0%% \r");
|
iprintf("Progress: 0%% \r");
|
||||||
@ -185,6 +196,7 @@ int restoreNAND(nocash_footer_t *footer){
|
|||||||
fail=1;
|
fail=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
nandWritten = true;
|
||||||
}
|
}
|
||||||
iprintf("Progress: %lu%% \r", (i+0x200)/(rwTotal/100));
|
iprintf("Progress: %lu%% \r", (i+0x200)/(rwTotal/100));
|
||||||
}
|
}
|
||||||
@ -194,7 +206,7 @@ int restoreNAND(nocash_footer_t *footer){
|
|||||||
fclose(f);
|
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;
|
done=1;
|
||||||
|
|
||||||
return fail;
|
return fail;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user