Don't overwrite the essential backup on safe restore

This commit is contained in:
d0k3 2017-02-22 17:41:01 +01:00
parent f76c753340
commit e772d1b2f7

View File

@ -198,12 +198,15 @@ u32 SafeRestoreNandDump(const char* path) {
ShowPrompt(false, "Error: A9LH not detected.");
return 1;
}
if (!ShowUnlockSequence(5, "!WARNING!\n \nProceeding will overwrite the\nSysNAND with this backup.\n"))
return false;
if (!SetWritePermissions(PERM_SYS_LVL2, true)) return 1;
// inject essential backup to NAND
// build essential backup from NAND
EssentialBackup* essential = (EssentialBackup*) TEMP_BUFFER;
if (BuildEssentialBackup("1:/nand.bin", essential) == 0)
WriteNandSectors((u8*) essential, ESSENTIAL_SECTOR, (sizeof(EssentialBackup) + 0x1FF) / 0x200, 0xFF, NAND_SYSNAND);
if (BuildEssentialBackup("1:/nand.bin", essential) != 0)
memset(essential, 0, sizeof(EssentialBackup));
// open file, get size
if (fvx_open(&file, path, FA_READ | FA_OPEN_EXISTING) != FR_OK)
@ -229,5 +232,8 @@ u32 SafeRestoreNandDump(const char* path) {
}
fvx_close(&file);
// inject essential backup to NAND
WriteNandSectors((u8*) essential, ESSENTIAL_SECTOR, (sizeof(EssentialBackup) + 0x1FF) / 0x200, 0xFF, NAND_SYSNAND);
return ret;
}