mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06: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:
@@ -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())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user