mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-09-20 21:06:22 +02:00
Windows: only update MBR first 512 bytes if they have changed and don't update full MBR bootload in case of PostOOBE
This commit is contained in:
parent
faa541f613
commit
343d1a95dc
@ -3489,6 +3489,8 @@ namespace VeraCrypt
|
||||
EfiBootInst.WriteConfig (L"\\EFI\\VeraCrypt\\DcsProp", preserveUserConfig, pim, hashAlg, NULL, ParentWindow);
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
|
||||
CreateBootLoaderInMemory (bootLoaderBuf, sizeof (bootLoaderBuf), false, hiddenOSCreation);
|
||||
@ -3519,6 +3521,9 @@ namespace VeraCrypt
|
||||
}
|
||||
}
|
||||
|
||||
// perform actual write only if content is different
|
||||
if (memcmp (mbr, bootLoaderBuf, TC_MAX_MBR_BOOT_CODE_SIZE))
|
||||
{
|
||||
memcpy (mbr, bootLoaderBuf, TC_MAX_MBR_BOOT_CODE_SIZE);
|
||||
|
||||
device.SeekAt (0);
|
||||
@ -3530,11 +3535,21 @@ namespace VeraCrypt
|
||||
|
||||
if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0)
|
||||
throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
|
||||
}
|
||||
|
||||
if (!PostOOBEMode)
|
||||
{
|
||||
// Write boot loader
|
||||
device.SeekAt (TC_SECTOR_SIZE_BIOS);
|
||||
device.Write (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, sizeof (bootLoaderBuf) - TC_SECTOR_SIZE_BIOS);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
if (!PostOOBEMode)
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsAdmin() && IsUacSupported())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user