diff options
Diffstat (limited to 'src/Common/BootEncryption.cpp')
-rw-r--r-- | src/Common/BootEncryption.cpp | 100 |
1 files changed, 50 insertions, 50 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 9f080f18..5670a1ac 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -67,9 +67,9 @@ namespace VeraCrypt if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
static void CopyFile (const string &sourceFile, const string &destinationFile)
@@ -100,9 +100,9 @@ namespace VeraCrypt if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
static void DeleteFile (const string &file)
@@ -123,9 +123,9 @@ namespace VeraCrypt if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
static void ReadWriteFile (BOOL write, BOOL device, const string &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone)
@@ -149,9 +149,9 @@ namespace VeraCrypt if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
if (!write)
memcpy (buffer, (BYTE *) bufferBstr.m_str, size);
@@ -193,9 +193,9 @@ namespace VeraCrypt if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
static void RegisterFilterDriver (bool registerDriver, BootEncryption::FilterType filterType)
@@ -205,9 +205,9 @@ namespace VeraCrypt DWORD result = ElevatedComInstance->RegisterFilterDriver (registerDriver ? TRUE : FALSE, filterType);
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
static void RegisterSystemFavoritesService (BOOL registerService)
@@ -217,9 +217,9 @@ namespace VeraCrypt DWORD result = ElevatedComInstance->RegisterSystemFavoritesService (registerService);
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
static void Release ()
@@ -239,9 +239,9 @@ namespace VeraCrypt DWORD result = ElevatedComInstance->SetDriverServiceStartType (startType);
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
protected:
@@ -249,9 +249,9 @@ namespace VeraCrypt {
if (IsAdmin())
{
SetLastError (ERROR_ACCESS_DENIED);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
if (!ElevatedComInstance || ElevatedComInstanceThreadId != GetCurrentThreadId())
{
@@ -337,9 +337,9 @@ namespace VeraCrypt if (!FileOpen)
{
SetLastError (LastError);
- throw SystemException ();
+ throw SystemException (SRC_POS);
}
if (Elevated)
{
@@ -358,9 +358,9 @@ namespace VeraCrypt {
if (!FileOpen)
{
SetLastError (LastError);
- throw SystemException ();
+ throw SystemException (SRC_POS);
}
FilePointerPosition = position;
@@ -378,9 +378,9 @@ namespace VeraCrypt if (!FileOpen)
{
SetLastError (LastError);
- throw SystemException ();
+ throw SystemException (SRC_POS);
}
try
{
@@ -545,9 +545,9 @@ namespace VeraCrypt }
}
throw ErrorException (wstring (GetString ("SYSTEM_PARTITION_NOT_ACTIVE"))
- + GetRemarksOnHiddenOS());
+ + GetRemarksOnHiddenOS(), SRC_POS);
}
activePartitionFound = true;
break;
@@ -580,29 +580,29 @@ namespace VeraCrypt if (!candidateForHiddenOSFound)
{
throw ErrorException (wstring (GetString ("NO_PARTITION_FOLLOWS_BOOT_PARTITION"))
- + GetRemarksOnHiddenOS());
+ + GetRemarksOnHiddenOS(), SRC_POS);
}
if (config.SystemPartition.Info.PartitionLength.QuadPart > TC_MAX_FAT_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
{
if ((double) candidatePartition.Info.PartitionLength.QuadPart / config.SystemPartition.Info.PartitionLength.QuadPart < MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_NTFS)
{
throw ErrorException (wstring (GetString ("PARTITION_TOO_SMALL_FOR_HIDDEN_OS_NTFS"))
- + GetRemarksOnHiddenOS());
+ + GetRemarksOnHiddenOS(), SRC_POS);
}
}
else if ((double) candidatePartition.Info.PartitionLength.QuadPart / config.SystemPartition.Info.PartitionLength.QuadPart < MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_FAT)
{
throw ErrorException (wstring (GetString ("PARTITION_TOO_SMALL_FOR_HIDDEN_OS"))
- + GetRemarksOnHiddenOS());
+ + GetRemarksOnHiddenOS(), SRC_POS);
}
}
else
{
// No active partition on the system drive
- throw ErrorException ("SYSTEM_PARTITION_NOT_ACTIVE");
+ throw ErrorException ("SYSTEM_PARTITION_NOT_ACTIVE", SRC_POS);
}
HiddenOSCandidatePartition = candidatePartition;
return candidatePartition;
@@ -883,9 +883,9 @@ namespace VeraCrypt bool BootEncryption::SystemDriveContainsPartitionType (byte type)
{
Device device (GetSystemDriveConfiguration().DevicePath, true);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
byte mbrBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrBuf, sizeof (mbrBuf));
@@ -1194,9 +1194,9 @@ namespace VeraCrypt // Checksum of the backup header of the outer volume for the hidden system
if (hiddenOSCreation)
{
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
byte headerSector[TC_SECTOR_SIZE_BIOS];
device.SeekAt (HiddenOSCandidatePartition.Info.StartingOffset.QuadPart + HiddenOSCandidatePartition.Info.PartitionLength.QuadPart - TC_VOLUME_HEADER_GROUP_SIZE + TC_VOLUME_HEADER_EFFECTIVE_SIZE);
device.Read (headerSector, sizeof (headerSector));
@@ -1283,9 +1283,9 @@ namespace VeraCrypt void BootEncryption::WriteBootSectorConfig (const byte newConfig[])
{
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
@@ -1299,16 +1299,16 @@ namespace VeraCrypt device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0)
- throw ErrorException ("ERROR_MBR_PROTECTED");
+ throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
}
void BootEncryption::WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage)
{
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
@@ -1338,9 +1338,9 @@ namespace VeraCrypt device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0)
- throw ErrorException ("ERROR_MBR_PROTECTED");
+ throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
}
unsigned int BootEncryption::GetHiddenOSCreationPhase ()
@@ -1437,9 +1437,9 @@ namespace VeraCrypt throw CryptoApiFailed (SRC_POS, CryptoAPILastError);
}
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened();
+ device.CheckOpened(SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
@@ -1496,9 +1496,9 @@ namespace VeraCrypt CreateBootLoaderInMemory (bootLoaderBuf, sizeof (bootLoaderBuf), false, hiddenOSCreation);
// Write MBR
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
@@ -1522,9 +1522,9 @@ namespace VeraCrypt device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0)
- throw ErrorException ("ERROR_MBR_PROTECTED");
+ throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
// Write boot loader
device.SeekAt (TC_SECTOR_SIZE_BIOS);
device.Write (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, sizeof (bootLoaderBuf) - TC_SECTOR_SIZE_BIOS);
@@ -1651,18 +1651,18 @@ namespace VeraCrypt }
else
{
Device bootDevice (GetSystemDriveConfiguration().DevicePath, true);
- bootDevice.CheckOpened ();
+ bootDevice.CheckOpened (SRC_POS);
bootDevice.SeekAt (TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET);
bootDevice.Read (image + TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET, TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE);
}
// Original system loader
try
{
File sysBakFile (GetSystemLoaderBackupPath(), true);
- sysBakFile.CheckOpened ();
+ sysBakFile.CheckOpened (SRC_POS);
sysBakFile.Read (image + TC_CD_BOOTSECTOR_OFFSET + TC_ORIG_BOOT_LOADER_BACKUP_SECTOR_OFFSET, TC_BOOT_LOADER_AREA_SIZE);
image[TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_SECTOR_CONFIG_OFFSET] |= TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER;
}
@@ -1716,9 +1716,9 @@ namespace VeraCrypt string path = "X:";
path[0] = drive;
Device driveDevice (path, true);
- driveDevice.CheckOpened ();
+ driveDevice.CheckOpened (SRC_POS);
size_t verifiedSectorCount = (TC_CD_BOOTSECTOR_OFFSET + TC_ORIG_BOOT_LOADER_BACKUP_SECTOR_OFFSET + TC_BOOT_LOADER_AREA_SIZE) / 2048;
Buffer buffer ((verifiedSectorCount + 1) * 2048);
DWORD bytesRead = driveDevice.Read (buffer.Ptr(), (DWORD) buffer.Size());
@@ -1779,9 +1779,9 @@ namespace VeraCrypt if (!VolumeHeaderValid)
throw ParameterIncorrect (SRC_POS);
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
device.SeekAt (TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET);
device.Write ((byte *) VolumeHeader, sizeof (VolumeHeader));
}
@@ -1811,9 +1811,9 @@ namespace VeraCrypt void BootEncryption::BackupSystemLoader ()
{
Device device (GetSystemDriveConfiguration().DevicePath, true);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (bootLoaderBuf, sizeof (bootLoaderBuf));
@@ -1838,14 +1838,14 @@ namespace VeraCrypt {
byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
File backupFile (GetSystemLoaderBackupPath(), true);
- backupFile.CheckOpened();
+ backupFile.CheckOpened(SRC_POS);
if (backupFile.Read (bootLoaderBuf, sizeof (bootLoaderBuf)) != sizeof (bootLoaderBuf))
throw ParameterIncorrect (SRC_POS);
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
// Preserve current partition table
byte mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
@@ -2047,31 +2047,31 @@ namespace VeraCrypt void BootEncryption::CheckRequirements ()
{
if (nCurrentOS == WIN_2000)
- throw ErrorException ("SYS_ENCRYPTION_UNSUPPORTED_ON_CURRENT_OS");
+ throw ErrorException ("SYS_ENCRYPTION_UNSUPPORTED_ON_CURRENT_OS", SRC_POS);
if (CurrentOSMajor == 6 && CurrentOSMinor == 0 && CurrentOSServicePack < 1)
- throw ErrorException ("SYS_ENCRYPTION_UNSUPPORTED_ON_VISTA_SP0");
+ throw ErrorException ("SYS_ENCRYPTION_UNSUPPORTED_ON_VISTA_SP0", SRC_POS);
if (IsNonInstallMode())
- throw ErrorException ("FEATURE_REQUIRES_INSTALLATION");
+ throw ErrorException ("FEATURE_REQUIRES_INSTALLATION", SRC_POS);
SystemDriveConfiguration config = GetSystemDriveConfiguration ();
if (config.SystemPartition.IsGPT)
- throw ErrorException ("GPT_BOOT_DRIVE_UNSUPPORTED");
+ throw ErrorException ("GPT_BOOT_DRIVE_UNSUPPORTED", SRC_POS);
if (SystemDriveIsDynamic())
- throw ErrorException ("SYSENC_UNSUPPORTED_FOR_DYNAMIC_DISK");
+ throw ErrorException ("SYSENC_UNSUPPORTED_FOR_DYNAMIC_DISK", SRC_POS);
if (config.InitialUnallocatedSpace < TC_BOOT_LOADER_AREA_SIZE)
- throw ErrorException ("NO_SPACE_FOR_BOOT_LOADER");
+ throw ErrorException ("NO_SPACE_FOR_BOOT_LOADER", SRC_POS);
DISK_GEOMETRY geometry = GetDriveGeometry (config.DriveNumber);
if (geometry.BytesPerSector != TC_SECTOR_SIZE_BIOS)
- throw ErrorException ("SYSENC_UNSUPPORTED_SECTOR_SIZE_BIOS");
+ throw ErrorException ("SYSENC_UNSUPPORTED_SECTOR_SIZE_BIOS", SRC_POS);
bool activePartitionFound = false;
if (!config.SystemPartition.IsGPT)
{
@@ -2145,24 +2145,24 @@ namespace VeraCrypt AbortProcessSilent();
}
throw ErrorException (wstring (GetString ("PAGING_FILE_NOT_ON_SYS_PARTITION"))
- + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"));
+ + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS);
}
// User profile
char *configPath = GetConfigPath ("dummy");
if (configPath && toupper (configPath[0]) != windowsDrive)
{
throw ErrorException (wstring (GetString ("USER_PROFILE_NOT_ON_SYS_PARTITION"))
- + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"));
+ + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS);
}
// Temporary files
if (toupper (GetTempPath()[0]) != windowsDrive)
{
throw ErrorException (wstring (GetString ("TEMP_NOT_ON_SYS_PARTITION"))
- + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"));
+ + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS);
}
}
@@ -2180,9 +2180,9 @@ namespace VeraCrypt if (encStatus.VolumeHeaderPresent)
{
// Verify CRC of header salt
Device device (config.DevicePath, true);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
byte header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
device.SeekAt (TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET);
device.Read (header, sizeof (header));
@@ -2228,9 +2228,9 @@ namespace VeraCrypt }
catch (Exception &e)
{
e.Show (ParentWindow);
- throw ErrorException ("SYS_LOADER_RESTORE_FAILED");
+ throw ErrorException ("SYS_LOADER_RESTORE_FAILED", SRC_POS);
}
}
@@ -2244,9 +2244,9 @@ namespace VeraCrypt SystemDriveConfiguration config = GetSystemDriveConfiguration ();
char header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
Device device (config.DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
// Only one algorithm is currently supported
if (pkcs5 != 0)
throw ParameterIncorrect (SRC_POS);
@@ -2281,9 +2281,9 @@ namespace VeraCrypt finally_do_arg (PCRYPTO_INFO, cryptoInfo, { if (finally_arg) crypto_close (finally_arg); });
if (status != 0)
{
- handleError (hwndDlg, status);
+ handleError (hwndDlg, status, SRC_POS);
return status;
}
// Change the PKCS-5 PRF if requested by user
@@ -2355,9 +2355,9 @@ namespace VeraCrypt crypto_close (tmpCryptoInfo);
if (status != 0)
{
- handleError (hwndDlg, status);
+ handleError (hwndDlg, status, SRC_POS);
return status;
}
device.SeekAt (headerOffset);
@@ -2460,9 +2460,9 @@ namespace VeraCrypt DISK_GEOMETRY geometry = GetDriveGeometry (config.DriveNumber);
Buffer sector (geometry.BytesPerSector);
Device device (config.DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
try
{
device.SeekAt (config.DrivePartition.Info.PartitionLength.QuadPart - geometry.BytesPerSector);
@@ -2582,9 +2582,9 @@ namespace VeraCrypt {
if (!IsUacSupported())
{
SetLastError (ERROR_ACCESS_DENIED);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
else
Elevator::CopyFile (sourceFile, destinationFile);
}
|