VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Boot/Windows/BootMain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Boot/Windows/BootMain.cpp')
-rw-r--r--src/Boot/Windows/BootMain.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/src/Boot/Windows/BootMain.cpp b/src/Boot/Windows/BootMain.cpp
index 8bfbe4b3..e85f2be5 100644
--- a/src/Boot/Windows/BootMain.cpp
+++ b/src/Boot/Windows/BootMain.cpp
@@ -57,61 +57,61 @@ static void InitScreen ()
PrintEndl (2);
}
static void PrintMainMenu ()
{
if (PreventBootMenu)
return;
Print (" Keyboard Controls:\r\n");
Print (" [F5] Hide/Show Password and PIM\r\n");
Print (" [Esc] ");
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
Print ((BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE) != TC_HIDDEN_OS_CREATION_PHASE_NONE
? "Boot Non-Hidden System (Boot Manager)"
: "Skip Authentication (Boot Manager)");
#else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE
Print ("Skip Authentication (Boot Manager)");
Print ("\r\n [F8] "); Print ("Repair Options");
#endif // TC_WINDOWS_BOOT_RESCUE_DISK_MODE
PrintEndl (3);
}
-static bool IsMenuKey (byte scanCode)
+static bool IsMenuKey (uint8 scanCode)
{
#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
return scanCode == TC_MENU_KEY_REPAIR;
#else
return false;
#endif
}
static bool AskYesNo (const char *message)
{
Print (message);
Print ("? (y/n): ");
while (true)
{
switch (GetKeyboardChar())
{
case 'y':
case 'Y':
case 'z':
case 'Z':
Print ("y\r\n");
return true;
case 'n':
case 'N':
Print ("n\r\n");
return false;
default:
@@ -122,66 +122,66 @@ static bool AskYesNo (const char *message)
static int AskSelection (const char *options[], size_t optionCount)
{
for (int i = 0; i < optionCount; ++i)
{
Print ("["); Print (i + 1); Print ("] ");
Print (options[i]);
PrintEndl();
}
Print ("[Esc] Cancel\r\n\r\n");
Print ("To select, press 1-9: ");
char str;
while (true)
{
if (GetString (&str, 1) == 0)
return 0;
if (str >= '1' && str <= optionCount + '0')
return str - '0';
Beep();
PrintBackspace();
}
}
-static byte AskPassword (Password &password, int& pim)
+static uint8 AskPassword (Password &password, int& pim)
{
size_t pos = 0;
- byte scanCode;
- byte asciiCode;
- byte hidePassword = 1;
+ uint8 scanCode;
+ uint8 asciiCode;
+ uint8 hidePassword = 1;
pim = 0;
Print ("Enter password");
Print (PreventNormalSystemBoot ? " for hidden system:\r\n" : ": ");
while (true)
{
asciiCode = GetKeyboardChar (&scanCode);
switch (scanCode)
{
case TC_BIOS_KEY_ENTER:
password.Length = pos;
Print ("\r");
if (!PreventNormalSystemBoot)
Print ("Enter password: ");
pos = 0;
while (pos < MAX_PASSWORD)
{
pos++;
if (pos < MAX_PASSWORD)
PrintChar ('*');
else
PrintCharAtCursor ('*');
}
ClearBiosKeystrokeBuffer();
PrintEndl();
@@ -285,87 +285,87 @@ static byte AskPassword (Password &password, int& pim)
default:
if (scanCode == TC_BIOS_KEY_ESC || IsMenuKey (scanCode))
{
burn (password.Text, sizeof (password.Text));
ClearBiosKeystrokeBuffer();
PrintEndl();
return scanCode;
}
}
if (!IsDigit (asciiCode) || pos == MAX_PIM)
{
Beep();
continue;
}
pim = 10*pim + (asciiCode - '0');
pos++;
if (hidePassword) asciiCode = '*';
if (pos < MAX_PIM)
PrintChar (asciiCode);
else
PrintCharAtCursor (asciiCode);
}
}
}
-static void ExecuteBootSector (byte drive, byte *sectorBuffer)
+static void ExecuteBootSector (uint8 drive, uint8 *sectorBuffer)
{
Print ("Booting...\r\n");
CopyMemory (sectorBuffer, 0x0000, 0x7c00, TC_LB_SIZE);
BootStarted = true;
uint32 addr = 0x7c00;
__asm
{
cli
mov dl, drive // Boot drive
mov dh, 0
xor ax, ax
mov si, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 0x7c00
sti
jmp cs:addr
}
}
-static bool OpenVolume (byte drive, Password &password, int pim, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32, bool skipNormal, bool skipHidden)
+static bool OpenVolume (uint8 drive, Password &password, int pim, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32, bool skipNormal, bool skipHidden)
{
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;
@@ -393,61 +393,61 @@ static bool OpenVolume (byte drive, Password &password, int pim, CRYPTO_INFO **c
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
{
push es
xor ax, ax
mov es, ax
mov ax, es:[0x413]
mov memFree, ax
pop es
}
Print (memFree);
PrintEndl();
Print (TC_BOOT_STR_UPGRADE_BIOS);
return false;
}
return true;
}
-static bool MountVolume (byte drive, byte &exitKey, bool skipNormal, bool skipHidden)
+static bool MountVolume (uint8 drive, uint8 &exitKey, bool skipNormal, bool skipHidden)
{
BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET;
int incorrectPasswordCount = 0, pim = 0;
EraseMemory (bootArguments, sizeof (*bootArguments));
// Open volume header
while (true)
{
exitKey = AskPassword (bootArguments->BootPassword, pim);
if (exitKey != TC_BIOS_KEY_ENTER)
return false;
Print ("Verifying password...");
if (OpenVolume (BootDrive, bootArguments->BootPassword, pim, &BootCryptoInfo, &bootArguments->HeaderSaltCrc32, skipNormal, skipHidden))
{
Print ("OK\r\n");
break;
}
if (GetShiftFlags() & TC_BIOS_SHIFTMASK_CAPSLOCK)
Print ("Warning: Caps Lock is on.\r\n");
Print ("Incorrect password.\r\n\r\n");
if (++incorrectPasswordCount == 4)
{
#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
Print ("If you are sure the password is correct, the key data may be damaged.\r\n"
@@ -472,163 +472,163 @@ static bool MountVolume (byte drive, byte &exitKey, bool skipNormal, bool skipHi
bootArguments->Flags |= TC_BOOT_ARGS_FLAG_EXTRA_BOOT_PARTITION;
TC_SET_BOOT_ARGUMENTS_SIGNATURE (bootArguments->Signature);
// Setup virtual encrypted partition
if (BootCryptoInfo->EncryptedAreaLength.HighPart != 0 || BootCryptoInfo->EncryptedAreaLength.LowPart != 0)
{
EncryptedVirtualPartition.Drive = BootDrive;
EncryptedVirtualPartition.StartSector = BootCryptoInfo->EncryptedAreaStart >> TC_LB_SIZE_BIT_SHIFT_DIVISOR;
PimValueOrHiddenVolumeStartUnitNo = EncryptedVirtualPartition.StartSector;
HiddenVolumeStartSector = PartitionFollowingActive.StartSector;
HiddenVolumeStartSector += EncryptedVirtualPartition.StartSector;
EncryptedVirtualPartition.SectorCount = BootCryptoInfo->EncryptedAreaLength >> TC_LB_SIZE_BIT_SHIFT_DIVISOR;
EncryptedVirtualPartition.EndSector = EncryptedVirtualPartition.SectorCount - 1;
EncryptedVirtualPartition.EndSector += EncryptedVirtualPartition.StartSector;
}
else
{
// Drive not encrypted
EncryptedVirtualPartition.Drive = TC_INVALID_BIOS_DRIVE;
}
return true;
}
-static bool GetSystemPartitions (byte drive)
+static bool GetSystemPartitions (uint8 drive)
{
size_t partCount;
if (!GetActivePartition (drive))
return false;
// Find partition following the active one
GetDrivePartitions (drive, &PartitionFollowingActive, 1, partCount, false, &ActivePartition);
// If there is an extra boot partition, use the partitions following it.
// The real boot partition is determined in BootEncryptedDrive().
if (ActivePartition.SectorCount.HighPart == 0 && ActivePartition.SectorCount.LowPart <= TC_MAX_EXTRA_BOOT_PARTITION_SIZE / TC_LB_SIZE
&& PartitionFollowingActive.Drive != TC_INVALID_BIOS_DRIVE)
{
ExtraBootPartitionPresent = true;
ActivePartition = PartitionFollowingActive;
GetDrivePartitions (drive, &PartitionFollowingActive, 1, partCount, false, &ActivePartition);
}
return true;
}
-static byte BootEncryptedDrive ()
+static uint8 BootEncryptedDrive ()
{
BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET;
- byte exitKey;
+ uint8 exitKey;
BootCryptoInfo = NULL;
if (!GetSystemPartitions (BootDrive))
goto err;
if (!MountVolume (BootDrive, exitKey, PreventNormalSystemBoot, false))
return exitKey;
if (!CheckMemoryRequirements ())
goto err;
if (BootCryptoInfo->hiddenVolume)
{
EncryptedVirtualPartition = ActivePartition;
bootArguments->DecoySystemPartitionStart = ActivePartition.StartSector << TC_LB_SIZE_BIT_SHIFT_DIVISOR;
}
if (ExtraBootPartitionPresent && !GetActivePartition (BootDrive))
goto err;
if (ReadWriteMBR (false, ActivePartition.Drive) != BiosResultSuccess)
goto err;
bootArguments->BootDriveSignature = *(uint32 *) (SectorBuffer + 0x1b8);
if (!InstallInterruptFilters())
goto err;
- bootArguments->BootArgumentsCrc32 = GetCrc32 ((byte *) bootArguments, (byte *) &bootArguments->BootArgumentsCrc32 - (byte *) bootArguments);
+ bootArguments->BootArgumentsCrc32 = GetCrc32 ((uint8 *) bootArguments, (uint8 *) &bootArguments->BootArgumentsCrc32 - (uint8 *) bootArguments);
while (true)
{
// Execute boot sector of the active partition
if (ReadSectors (SectorBuffer, ActivePartition.Drive, ActivePartition.StartSector, 1) == BiosResultSuccess)
{
if (*(uint16 *) (SectorBuffer + 510) != 0xaa55)
{
PrintError (TC_BOOT_STR_NO_BOOT_PARTITION);
GetKeyboardChar();
}
ExecuteBootSector (ActivePartition.Drive, SectorBuffer);
}
GetKeyboardChar();
}
err:
if (BootCryptoInfo)
{
crypto_close (BootCryptoInfo);
BootCryptoInfo = NULL;
}
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
PimValueOrHiddenVolumeStartUnitNo.LowPart = -1;
#endif
EncryptedVirtualPartition.Drive = TC_INVALID_BIOS_DRIVE;
EraseMemory ((void *) TC_BOOT_LOADER_ARGS_OFFSET, sizeof (BootArguments));
- byte scanCode;
+ uint8 scanCode;
GetKeyboardChar (&scanCode);
return scanCode;
}
static void BootMenu ()
{
BiosResult result;
Partition partitions[16];
Partition bootablePartitions[9];
size_t partitionCount;
size_t bootablePartitionCount = 0;
- for (byte drive = TC_FIRST_BIOS_DRIVE; drive <= TC_LAST_BIOS_DRIVE; ++drive)
+ for (uint8 drive = TC_FIRST_BIOS_DRIVE; drive <= TC_LAST_BIOS_DRIVE; ++drive)
{
if (GetDrivePartitions (drive, partitions, array_capacity (partitions), partitionCount, false, nullptr, true) == BiosResultSuccess)
{
for (size_t i = 0; i < partitionCount; ++i)
{
const Partition &partition = partitions[i];
result = ReadSectors (SectorBuffer, drive, partition.StartSector, 1);
if (result == BiosResultSuccess && *(uint16 *) (SectorBuffer + TC_LB_SIZE - 2) == 0xaa55)
{
// Windows writes boot loader on all NTFS/FAT filesytems it creates and, therefore,
// NTFS/FAT partitions must have the boot indicator set to be considered bootable.
if (!partition.Active
&& (*(uint32 *) (SectorBuffer + 3) == 0x5346544e // 'NTFS'
|| *(uint32 *) (SectorBuffer + 3) == 0x41465845 && SectorBuffer[7] == 'T' // 'exFAT'
|| *(uint16 *) (SectorBuffer + 54) == 0x4146 && SectorBuffer[56] == 'T' // 'FAT'
|| *(uint16 *) (SectorBuffer + 82) == 0x4146 && SectorBuffer[84] == 'T'))
{
continue;
}
// Bootable sector found
if (bootablePartitionCount < array_capacity (bootablePartitions))
bootablePartitions[bootablePartitionCount++] = partition;
}
}
}
}
if (bootablePartitionCount < 1)
@@ -662,61 +662,61 @@ static void BootMenu ()
}
else
{
Print ("[Esc] Cancel\r\n\r\n");
Print ("Press 1-9 to select partition: ");
if (GetString (&partChar, 1) == 0)
return;
PrintEndl();
if (partChar < '1' || partChar > '0' + bootablePartitionCount)
{
Beep();
continue;
}
}
const Partition &partition = bootablePartitions[partChar - '0' - 1];
if (ReadSectors (SectorBuffer, partition.Drive, partition.StartSector, 1) == BiosResultSuccess)
{
ExecuteBootSector (partition.Drive, SectorBuffer);
}
}
}
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
-static bool CopySystemPartitionToHiddenVolume (byte drive, byte &exitKey)
+static bool CopySystemPartitionToHiddenVolume (uint8 drive, uint8 &exitKey)
{
bool status = false;
uint64 sectorsRemaining;
uint64 sectorOffset;
sectorOffset.LowPart = 0;
sectorOffset.HighPart = 0;
int fragmentSectorCount = 0x7f; // Maximum safe value supported by BIOS
int statCount = 0;
if (!CheckMemoryRequirements ())
goto err;
if (!GetSystemPartitions (drive))
goto err;
if (PartitionFollowingActive.Drive == TC_INVALID_BIOS_DRIVE)
TC_THROW_FATAL_EXCEPTION;
// Check if BIOS can read the last sector of the hidden system
AcquireSectorBuffer();
if (ReadSectors (SectorBuffer, PartitionFollowingActive.Drive, PartitionFollowingActive.EndSector - (TC_VOLUME_HEADER_GROUP_SIZE / TC_LB_SIZE - 2), 1) != BiosResultSuccess
|| GetCrc32 (SectorBuffer, sizeof (SectorBuffer)) != OuterVolumeBackupHeaderCrc)
{
PrintErrorNoEndl ("Your BIOS does not support large drives");
Print (IsLbaSupported (PartitionFollowingActive.Drive) ? " due to a bug" : "\r\n- Enable LBA in BIOS");
PrintEndl();
Print (TC_BOOT_STR_UPGRADE_BIOS);
@@ -785,63 +785,63 @@ static bool CopySystemPartitionToHiddenVolume (byte drive, byte &exitKey)
Print ("\rRemaining: ");
PrintSectorCountInMB (sectorsRemaining);
}
}
crypto_close (BootCryptoInfo);
if (sectorsRemaining.HighPart == 0 && sectorsRemaining.LowPart == 0)
{
status = true;
Print ("\rCopying completed.");
}
PrintEndl (2);
goto ret;
err:
exitKey = TC_BIOS_KEY_ESC;
GetKeyboardChar();
ret:
PimValueOrHiddenVolumeStartUnitNo.LowPart = -1;
EraseMemory ((void *) TC_BOOT_LOADER_ARGS_OFFSET, sizeof (BootArguments));
return status;
}
#else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE
-static void DecryptDrive (byte drive)
+static void DecryptDrive (uint8 drive)
{
- byte exitKey;
+ uint8 exitKey;
if (!MountVolume (drive, exitKey, false, true))
return;
BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET;
bool headerUpdateRequired = false;
uint64 sectorsRemaining = EncryptedVirtualPartition.EndSector + 1 - EncryptedVirtualPartition.StartSector;
uint64 sector = EncryptedVirtualPartition.EndSector + 1;
int fragmentSectorCount = 0x7f; // Maximum safe value supported by BIOS
int statCount = 0;
bool skipBadSectors = false;
Print ("\r\nUse only if Windows cannot start. Decryption under Windows is much faster\r\n"
"(in VeraCrypt, select 'System' > 'Permanently Decrypt').\r\n\r\n");
if (!AskYesNo ("Decrypt now"))
{
crypto_close (BootCryptoInfo);
goto ret;
}
if (EncryptedVirtualPartition.Drive == TC_INVALID_BIOS_DRIVE)
{
// Drive already decrypted
sectorsRemaining.HighPart = 0;
sectorsRemaining.LowPart = 0;
}
else
@@ -898,69 +898,69 @@ askBadSectorSkip:
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)
{
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] = (byte) encryptedAreaLength.LowPart;
+ 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] = (byte) headerCrc32;
+ 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");
}
if (sectorsRemaining.HighPart == 0 && sectorsRemaining.LowPart == 0)
Print ("\rDrive decrypted.\r\n");
else
Print ("\r\nDecryption deferred.\r\n");
GetKeyboardChar();
ret:
EraseMemory (bootArguments, sizeof (*bootArguments));
}
static void RepairMenu ()
{
DriveGeometry bootLoaderDriveGeometry;
if (GetDriveGeometry (BootLoaderDrive, bootLoaderDriveGeometry, true) != BiosResultSuccess)
@@ -993,114 +993,114 @@ static void RepairMenu ()
(BootSectorFlags & TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER) ? array_capacity (options) : array_capacity (options) - 1);
PrintEndl();
switch (selection)
{
case RestoreNone:
return;
case DecryptVolume:
DecryptDrive (BootDrive);
continue;
case RestoreOriginalSystemLoader:
if (!AskYesNo ("Is the system partition/drive decrypted"))
{
Print ("Please decrypt it first.\r\n");
GetKeyboardChar();
continue;
}
break;
}
bool writeConfirmed = false;
BiosResult result;
uint64 sector;
sector.HighPart = 0;
ChsAddress chs;
- byte mbrPartTable[TC_LB_SIZE - TC_MAX_MBR_BOOT_CODE_SIZE];
+ uint8 mbrPartTable[TC_LB_SIZE - TC_MAX_MBR_BOOT_CODE_SIZE];
AcquireSectorBuffer();
for (int i = (selection == RestoreVolumeHeader ? TC_BOOT_VOLUME_HEADER_SECTOR : TC_MBR_SECTOR);
i < TC_BOOT_LOADER_AREA_SECTOR_COUNT; ++i)
{
sector.LowPart = i;
if (selection == RestoreOriginalSystemLoader)
sector.LowPart += TC_ORIG_BOOT_LOADER_BACKUP_SECTOR;
else if (selection == RestoreTrueCryptLoader)
sector.LowPart += TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR;
// The backup medium may be a floppy-emulated bootable CD. The emulation may fail if LBA addressing is used.
// Therefore, only CHS addressing can be used.
LbaToChs (bootLoaderDriveGeometry, sector, chs);
sector.LowPart = i;
if (i == TC_MBR_SECTOR)
{
// Read current partition table
result = ReadSectors (SectorBuffer, TC_FIRST_BIOS_DRIVE, sector, 1);
if (result != BiosResultSuccess)
goto err;
memcpy (mbrPartTable, SectorBuffer + TC_MAX_MBR_BOOT_CODE_SIZE, sizeof (mbrPartTable));
}
result = ReadSectors (SectorBuffer, BootLoaderDrive, chs, 1);
if (result != BiosResultSuccess)
goto err;
if (i == TC_MBR_SECTOR)
{
// Preserve current partition table
memcpy (SectorBuffer + TC_MAX_MBR_BOOT_CODE_SIZE, mbrPartTable, sizeof (mbrPartTable));
}
// Volume header
if (i == TC_BOOT_VOLUME_HEADER_SECTOR)
{
if (selection == RestoreTrueCryptLoader)
continue;
if (selection == RestoreVolumeHeader)
{
while (true)
{
bool validHeaderPresent = false;
uint32 masterKeyScheduleCrc;
Password password;
int pim;
- byte exitKey = AskPassword (password, 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 (validHeaderPresent)
{
if (masterKeyScheduleCrc == GetCrc32 (cryptoInfo->ks, sizeof (cryptoInfo->ks)))
{
Print ("Original header preserved.\r\n");
goto err;
}
@@ -1194,67 +1194,67 @@ void main ()
else
BootDriveGeometryValid = true;
}
else
BootDriveGeometryValid = true;
#ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
// Check whether the user is not using the Rescue Disk to create a hidden system
if (ReadWriteMBR (false, BootDrive, true) == BiosResultSuccess
&& *(uint32 *) (SectorBuffer + 6) == 0x61726556
&& *(uint32 *) (SectorBuffer + 10) == 0x70797243
&& (SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE) != TC_HIDDEN_OS_CREATION_PHASE_NONE)
{
PrintError ("It appears you are creating a hidden OS.");
if (AskYesNo ("Is this correct"))
{
Print ("Please remove the Rescue Disk from the drive and restart.");
while (true);
}
}
#endif // TC_WINDOWS_BOOT_RESCUE_DISK_MODE
// Main menu
while (true)
{
- byte exitKey;
+ uint8 exitKey;
InitScreen();
#ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE
// Hidden system setup
- byte hiddenSystemCreationPhase = BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
+ uint8 hiddenSystemCreationPhase = BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
if (hiddenSystemCreationPhase != TC_HIDDEN_OS_CREATION_PHASE_NONE)
{
PreventNormalSystemBoot = true;
PrintMainMenu();
if (hiddenSystemCreationPhase == TC_HIDDEN_OS_CREATION_PHASE_CLONING)
{
if (CopySystemPartitionToHiddenVolume (BootDrive, exitKey))
{
BootSectorFlags = (BootSectorFlags & ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE) | TC_HIDDEN_OS_CREATION_PHASE_WIPING;
UpdateBootSectorConfiguration (BootLoaderDrive);
}
else if (exitKey == TC_BIOS_KEY_ESC)
goto bootMenu;
else
continue;
}
}
else
PrintMainMenu();
exitKey = BootEncryptedDrive();
#else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE
PrintMainMenu();
exitKey = BootEncryptedDrive();
if (exitKey == TC_MENU_KEY_REPAIR)