Offer fixing of BOSS files on failed verification

Fixes #442
This commit is contained in:
d0k3 2018-12-08 18:12:25 +01:00
parent 75a23a15c3
commit d4ea225677

View File

@ -672,7 +672,6 @@ u32 VerifyBossFile(const char* path) {
TruncateString(pathstr, path, 32, 8);
// read file header
if (fvx_open(&file, path, FA_READ | FA_OPEN_EXISTING) != FR_OK)
return 1;
fvx_lseek(&file, 0);
@ -723,8 +722,14 @@ u32 VerifyBossFile(const char* path) {
free(buffer);
if (memcmp(hash, boss.hash_payload, 0x20) != 0) {
ShowPrompt(false, "%s\nBOSS payload hash mismatch", pathstr);
return 1;
if (ShowPrompt(true, "%s\nBOSS payload hash mismatch.\n \nTry to fix it?", pathstr)) {
// fix hash, reencrypt BOSS header if required, write to file
memcpy(boss.hash_payload, hash, 0x20);
if (encrypted) CryptBoss((void*) &boss, 0, sizeof(BossHeader), &boss);
if (!CheckWritePermissions(path) ||
(fvx_qwrite(path, &boss, 0, sizeof(BossHeader), NULL) != FR_OK))
return 1;
} else return 1;
}
return 0;