VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Boot/Windows/BootMain.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Boot/Windows/BootMain.cpp b/src/Boot/Windows/BootMain.cpp
index e85f2be5..f6024d34 100644
--- a/src/Boot/Windows/BootMain.cpp
+++ b/src/Boot/Windows/BootMain.cpp
@@ -342,61 +342,61 @@ static bool OpenVolume (uint8 drive, Password &password, int pim, CRYPTO_INFO **
{
int volumeType;
bool hiddenVolume;
uint64 headerSec;
AcquireSectorBuffer();
for (volumeType = 1; volumeType <= 2; ++volumeType)
{
hiddenVolume = (volumeType == 2);
if (hiddenVolume)
{
if (skipHidden || PartitionFollowingActive.Drive != drive || PartitionFollowingActive.SectorCount <= ActivePartition.SectorCount)
continue;
headerSec = PartitionFollowingActive.StartSector + TC_HIDDEN_VOLUME_HEADER_OFFSET / TC_LB_SIZE;
}
else
{
if (skipNormal)
continue;
headerSec.HighPart = 0;
headerSec.LowPart = TC_BOOT_VOLUME_HEADER_SECTOR;
}
if (ReadSectors (SectorBuffer, drive, headerSec, 1) != BiosResultSuccess)
continue;
- if (ReadVolumeHeader (!hiddenVolume, (char *) SectorBuffer, &password, pim, cryptoInfo, nullptr) == ERR_SUCCESS)
+ if (ReadVolumeHeader (!hiddenVolume, SectorBuffer, &password, pim, cryptoInfo, nullptr) == ERR_SUCCESS)
{
// Prevent opening a non-system hidden volume
if (hiddenVolume && !((*cryptoInfo)->HeaderFlags & TC_HEADER_FLAG_ENCRYPTED_SYSTEM))
{
crypto_close (*cryptoInfo);
continue;
}
if (headerSaltCrc32)
*headerSaltCrc32 = GetCrc32 (SectorBuffer, PKCS5_SALT_SIZE);
break;
}
}
ReleaseSectorBuffer();
return volumeType != 3;
}
static bool CheckMemoryRequirements ()
{
uint16 codeSeg;
__asm mov codeSeg, cs
if (codeSeg == TC_BOOT_LOADER_LOWMEM_SEGMENT)
{
PrintErrorNoEndl ("BIOS reserved too much memory: ");
uint16 memFree;
__asm
@@ -890,61 +890,61 @@ static void DecryptDrive (uint8 drive)
sectorsRemaining = sectorsRemaining - fragmentSectorCount;
headerUpdateRequired = true;
continue;
askBadSectorSkip:
if (!AskYesNo ("Skip all bad sectors"))
break;
skipBadSectors = true;
sector = sector + fragmentSectorCount;
fragmentSectorCount = 1;
}
crypto_close (BootCryptoInfo);
if (headerUpdateRequired)
{
Print ("\rUpdating header...");
AcquireSectorBuffer();
uint64 headerSector;
headerSector.HighPart = 0;
headerSector.LowPart = TC_BOOT_VOLUME_HEADER_SECTOR;
// Update encrypted area size in volume header
CRYPTO_INFO *headerCryptoInfo = crypto_open();
while (ReadSectors (SectorBuffer, drive, headerSector, 1) != BiosResultSuccess);
- if (ReadVolumeHeader (TRUE, (char *) SectorBuffer, &bootArguments->BootPassword, (int) (bootArguments->Flags >> 16), NULL, headerCryptoInfo) == 0)
+ if (ReadVolumeHeader (TRUE, SectorBuffer, &bootArguments->BootPassword, (int) (bootArguments->Flags >> 16), NULL, headerCryptoInfo) == 0)
{
DecryptBuffer (SectorBuffer + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo);
uint64 encryptedAreaLength = sectorsRemaining << TC_LB_SIZE_BIT_SHIFT_DIVISOR;
for (int i = 7; i >= 0; --i)
{
SectorBuffer[TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH + i] = (uint8) encryptedAreaLength.LowPart;
encryptedAreaLength = encryptedAreaLength >> 8;
}
uint32 headerCrc32 = GetCrc32 (SectorBuffer + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC);
for (i = 3; i >= 0; --i)
{
SectorBuffer[TC_HEADER_OFFSET_HEADER_CRC + i] = (uint8) headerCrc32;
headerCrc32 >>= 8;
}
EncryptBuffer (SectorBuffer + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo);
}
crypto_close (headerCryptoInfo);
while (WriteSectors (SectorBuffer, drive, headerSector, 1) != BiosResultSuccess);
ReleaseSectorBuffer();
Print ("Done!\r\n");
}
@@ -1067,61 +1067,61 @@ static void RepairMenu ()
if (selection == RestoreVolumeHeader)
{
while (true)
{
bool validHeaderPresent = false;
uint32 masterKeyScheduleCrc;
Password password;
int pim;
uint8 exitKey = AskPassword (password, pim);
if (exitKey != TC_BIOS_KEY_ENTER)
goto abort;
CRYPTO_INFO *cryptoInfo;
CopyMemory (SectorBuffer, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, TC_LB_SIZE);
ReleaseSectorBuffer();
// Restore volume header only if the current one cannot be used
if (OpenVolume (TC_FIRST_BIOS_DRIVE, password, pim, &cryptoInfo, nullptr, false, true))
{
validHeaderPresent = true;
masterKeyScheduleCrc = GetCrc32 (cryptoInfo->ks, sizeof (cryptoInfo->ks));
crypto_close (cryptoInfo);
}
AcquireSectorBuffer();
CopyMemory (TC_BOOT_LOADER_BUFFER_SEGMENT, 0, SectorBuffer, TC_LB_SIZE);
- if (ReadVolumeHeader (TRUE, (char *) SectorBuffer, &password, pim, &cryptoInfo, nullptr) == 0)
+ if (ReadVolumeHeader (TRUE, SectorBuffer, &password, pim, &cryptoInfo, nullptr) == 0)
{
if (validHeaderPresent)
{
if (masterKeyScheduleCrc == GetCrc32 (cryptoInfo->ks, sizeof (cryptoInfo->ks)))
{
Print ("Original header preserved.\r\n");
goto err;
}
Print ("WARNING: Drive 0 contains a valid header!\r\n");
}
crypto_close (cryptoInfo);
break;
}
Print ("Incorrect password.\r\n\r\n");
}
}
}
if (!writeConfirmed && !AskYesNo ("Modify drive 0"))
goto abort;
writeConfirmed = true;
if (WriteSectors (SectorBuffer, TC_FIRST_BIOS_DRIVE, sector, 1) != BiosResultSuccess)
goto err;
}
done:
switch (selection)