VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-07-05 18:15:41 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-07-06 01:19:21 +0200
commit724043be0b9ed68382c49c54b4750ddeaebe81c4 (patch)
treef93ab6d2b1597b9fd2c3c354f0c730b805cc3c57
parentc3b77fba25539c433c882d980169f2c68329e996 (diff)
downloadVeraCrypt-724043be0b9ed68382c49c54b4750ddeaebe81c4.tar.gz
VeraCrypt-724043be0b9ed68382c49c54b4750ddeaebe81c4.zip
Windows: Display source location of errors in order to help diagnose issues reported by users
-rw-r--r--src/Common/BaseCom.cpp2
-rw-r--r--src/Common/BootEncryption.cpp100
-rw-r--r--src/Common/BootEncryption.h2
-rw-r--r--src/Common/Cmdline.c8
-rw-r--r--src/Common/Dlgcode.c116
-rw-r--r--src/Common/Dlgcode.h8
-rw-r--r--src/Common/Exception.h23
-rw-r--r--src/Common/Format.c10
-rw-r--r--src/Common/Keyfiles.c12
-rw-r--r--src/Common/Language.h2
-rw-r--r--src/Common/Password.c10
-rw-r--r--src/Common/Random.c12
-rw-r--r--src/ExpandVolume/DlgExpandVolume.cpp6
-rw-r--r--src/ExpandVolume/ExpandVolume.c6
-rw-r--r--src/ExpandVolume/InitDataArea.c8
-rw-r--r--src/ExpandVolume/WinMain.cpp4
-rw-r--r--src/Format/InPlace.c20
-rw-r--r--src/Format/Tcformat.c44
-rw-r--r--src/Mount/Favorites.cpp6
-rw-r--r--src/Mount/Hotkeys.c8
-rw-r--r--src/Mount/Mount.c56
-rw-r--r--src/Setup/SelfExtract.c10
-rw-r--r--src/Setup/Setup.c24
23 files changed, 270 insertions, 227 deletions
diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp
index 365fa293..d5a48c44 100644
--- a/src/Common/BaseCom.cpp
+++ b/src/Common/BaseCom.cpp
@@ -134,7 +134,7 @@ DWORD BaseCom::ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *buff
try
{
auto_ptr <File> file (device ? new Device (string (szFilePathA.m_psz), !write) : new File (string (szFilePathA.m_psz), !write));
- file->CheckOpened ();
+ file->CheckOpened (SRC_POS);
file->SeekAt (offset);
if (write)
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
@@ -68,7 +68,7 @@ namespace VeraCrypt
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
@@ -101,7 +101,7 @@ namespace VeraCrypt
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
@@ -124,7 +124,7 @@ namespace VeraCrypt
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
@@ -150,7 +150,7 @@ namespace VeraCrypt
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
if (!write)
@@ -194,7 +194,7 @@ namespace VeraCrypt
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
@@ -206,7 +206,7 @@ namespace VeraCrypt
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
@@ -218,7 +218,7 @@ namespace VeraCrypt
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
@@ -240,7 +240,7 @@ namespace VeraCrypt
if (result != ERROR_SUCCESS)
{
SetLastError (result);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
}
@@ -250,7 +250,7 @@ namespace VeraCrypt
if (IsAdmin())
{
SetLastError (ERROR_ACCESS_DENIED);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
if (!ElevatedComInstance || ElevatedComInstanceThreadId != GetCurrentThreadId())
@@ -338,7 +338,7 @@ namespace VeraCrypt
if (!FileOpen)
{
SetLastError (LastError);
- throw SystemException ();
+ throw SystemException (SRC_POS);
}
if (Elevated)
@@ -359,7 +359,7 @@ namespace VeraCrypt
if (!FileOpen)
{
SetLastError (LastError);
- throw SystemException ();
+ throw SystemException (SRC_POS);
}
FilePointerPosition = position;
@@ -379,7 +379,7 @@ namespace VeraCrypt
if (!FileOpen)
{
SetLastError (LastError);
- throw SystemException ();
+ throw SystemException (SRC_POS);
}
try
@@ -546,7 +546,7 @@ namespace VeraCrypt
}
throw ErrorException (wstring (GetString ("SYSTEM_PARTITION_NOT_ACTIVE"))
- + GetRemarksOnHiddenOS());
+ + GetRemarksOnHiddenOS(), SRC_POS);
}
activePartitionFound = true;
@@ -581,7 +581,7 @@ 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)
@@ -589,19 +589,19 @@ namespace VeraCrypt
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;
@@ -884,7 +884,7 @@ 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);
@@ -1195,7 +1195,7 @@ namespace VeraCrypt
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);
@@ -1284,7 +1284,7 @@ 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);
@@ -1300,14 +1300,14 @@ namespace VeraCrypt
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);
@@ -1339,7 +1339,7 @@ namespace VeraCrypt
device.Read (mbrVerificationBuf, sizeof (mbr));
if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0)
- throw ErrorException ("ERROR_MBR_PROTECTED");
+ throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
}
@@ -1438,7 +1438,7 @@ namespace VeraCrypt
}
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened();
+ device.CheckOpened(SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
@@ -1497,7 +1497,7 @@ namespace VeraCrypt
// Write MBR
Device device (GetSystemDriveConfiguration().DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
byte mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
@@ -1523,7 +1523,7 @@ namespace VeraCrypt
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);
@@ -1652,7 +1652,7 @@ 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);
}
@@ -1661,7 +1661,7 @@ namespace VeraCrypt
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;
@@ -1717,7 +1717,7 @@ namespace VeraCrypt
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);
@@ -1780,7 +1780,7 @@ namespace VeraCrypt
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));
@@ -1812,7 +1812,7 @@ 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);
@@ -1839,12 +1839,12 @@ 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];
@@ -2048,29 +2048,29 @@ 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)
@@ -2146,7 +2146,7 @@ namespace VeraCrypt
}
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
@@ -2154,14 +2154,14 @@ namespace VeraCrypt
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);
}
}
@@ -2181,7 +2181,7 @@ namespace VeraCrypt
{
// 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);
@@ -2229,7 +2229,7 @@ namespace VeraCrypt
catch (Exception &e)
{
e.Show (ParentWindow);
- throw ErrorException ("SYS_LOADER_RESTORE_FAILED");
+ throw ErrorException ("SYS_LOADER_RESTORE_FAILED", SRC_POS);
}
}
@@ -2245,7 +2245,7 @@ namespace VeraCrypt
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)
@@ -2282,7 +2282,7 @@ namespace VeraCrypt
if (status != 0)
{
- handleError (hwndDlg, status);
+ handleError (hwndDlg, status, SRC_POS);
return status;
}
@@ -2356,7 +2356,7 @@ namespace VeraCrypt
if (status != 0)
{
- handleError (hwndDlg, status);
+ handleError (hwndDlg, status, SRC_POS);
return status;
}
@@ -2461,7 +2461,7 @@ namespace VeraCrypt
Buffer sector (geometry.BytesPerSector);
Device device (config.DevicePath);
- device.CheckOpened ();
+ device.CheckOpened (SRC_POS);
try
{
@@ -2583,7 +2583,7 @@ namespace VeraCrypt
if (!IsUacSupported())
{
SetLastError (ERROR_ACCESS_DENIED);
- throw SystemException();
+ throw SystemException(SRC_POS);
}
else
Elevator::CopyFile (sourceFile, destinationFile);
diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h
index a73ce6fc..e8b57211 100644
--- a/src/Common/BootEncryption.h
+++ b/src/Common/BootEncryption.h
@@ -26,7 +26,7 @@ namespace VeraCrypt
File (string path,bool readOnly = false, bool create = false);
virtual ~File () { Close(); }
- void CheckOpened () { if (!FileOpen) { SetLastError (LastError); throw SystemException ();} }
+ void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} }
void Close ();
DWORD Read (byte *buffer, DWORD size);
void Write (byte *buffer, DWORD size);
diff --git a/src/Common/Cmdline.c b/src/Common/Cmdline.c
index 6e325fe3..929b777d 100644
--- a/src/Common/Cmdline.c
+++ b/src/Common/Cmdline.c
@@ -22,6 +22,10 @@
#include "Language.h"
#include <Strsafe.h>
+#ifndef SRC_POS
+#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
+#endif
+
/* Except in response to the WM_INITDIALOG message, the dialog box procedure
should return nonzero if it processes the message, and zero if it does
not. - see DialogProc */
@@ -92,7 +96,7 @@ int Win32CommandLine (char *lpszCommandLine, char ***lpszArgs)
LPWSTR *arguments = CommandLineToArgvW (GetCommandLineW(), &argumentCount);
if (!arguments)
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
return 0;
}
@@ -120,7 +124,7 @@ int Win32CommandLine (char *lpszCommandLine, char ***lpszArgs)
int len = WideCharToMultiByte (CP_ACP, 0, arguments[i + 1], -1, arg, (int) argLen + 1, NULL, NULL);
if (len == 0)
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
AbortProcessSilent();
}
}
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 5e26ef0f..a317f607 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -548,10 +548,10 @@ BOOL IsDiskError (DWORD error)
}
-DWORD handleWin32Error (HWND hwndDlg)
+DWORD handleWin32Error (HWND hwndDlg, const char* srcPos)
{
PWSTR lpMsgBuf;
- DWORD dwError = GetLastError ();
+ DWORD dwError = GetLastError ();
if (Silent || dwError == 0 || dwError == ERROR_INVALID_WINDOW_HANDLE)
return dwError;
@@ -559,7 +559,7 @@ DWORD handleWin32Error (HWND hwndDlg)
// Access denied
if (dwError == ERROR_ACCESS_DENIED && !IsAdmin ())
{
- Error ("ERR_ACCESS_DENIED", hwndDlg);
+ ErrorDirect ( AppendSrcPos (GetString ("ERR_ACCESS_DENIED"), srcPos).c_str (), hwndDlg);
SetLastError (dwError); // Preserve the original error code
return dwError;
}
@@ -574,7 +574,7 @@ DWORD handleWin32Error (HWND hwndDlg)
NULL
);
- MessageBoxW (hwndDlg, lpMsgBuf, lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (lpMsgBuf, srcPos).c_str (), lpszTitle, ICON_HAND);
LocalFree (lpMsgBuf);
// User-friendly hardware error explanation
@@ -1265,7 +1265,7 @@ void InitDialog (HWND hwndDlg)
hFixedDigitFont = CreateFontIndirectW (&lf);
if (hFixedDigitFont == NULL)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
AbortProcess ("NOFONT");
}
@@ -1279,7 +1279,7 @@ void InitDialog (HWND hwndDlg)
hBoldFont = CreateFontIndirectW (&lf);
if (hBoldFont == NULL)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
AbortProcess ("NOFONT");
}
@@ -1293,7 +1293,7 @@ void InitDialog (HWND hwndDlg)
hTitleFont = CreateFontIndirectW (&lf);
if (hTitleFont == NULL)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
AbortProcess ("NOFONT");
}
@@ -1318,7 +1318,7 @@ void InitDialog (HWND hwndDlg)
hFixedFont = CreateFontIndirectW (&lf);
if (hFixedFont == NULL)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
AbortProcess ("NOFONT");
}
@@ -2525,7 +2525,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
/* Get the attributes for the standard dialog class */
if ((GetClassInfo (hInst, WINDOWS_DIALOG_CLASS, &wc)) == 0)
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
AbortProcess ("INIT_REGISTER");
}
@@ -2543,7 +2543,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
hDlgClass = RegisterClass (&wc);
if (hDlgClass == 0)
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
AbortProcess ("INIT_REGISTER");
}
@@ -2555,7 +2555,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
hSplashClass = RegisterClass (&wc);
if (hSplashClass == 0)
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
AbortProcess ("INIT_REGISTER");
}
@@ -2567,7 +2567,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
if ((hRichEditDll = LoadLibrary(dllPath)) == NULL)
{
// This error is fatal e.g. because legal notices could not be displayed
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
AbortProcess ("INIT_RICHEDIT");
}
@@ -2580,7 +2580,7 @@ void InitApp (HINSTANCE hInstance, char *lpszCommandLine)
#ifndef SETUP
if (!EncryptionThreadPoolStart (ReadEncryptionThreadPoolFreeCpuCountLimit()))
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
if (hRichEditDll)
{
FreeLibrary (hRichEditDll);
@@ -3470,7 +3470,7 @@ BOOL DoDriverInstall (HWND hwndDlg)
error:
if (bOK == FALSE && GetLastError () != ERROR_SERVICE_ALREADY_RUNNING)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
MessageBoxW (hwndDlg, GetString ("DRIVER_INSTALL_FAILED"), lpszTitle, MB_ICONHAND);
}
else
@@ -4091,7 +4091,7 @@ std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg)
}
-void handleError (HWND hwndDlg, int code)
+void handleError (HWND hwndDlg, int code, const char* srcPos)
{
WCHAR szTmp[4096];
@@ -4100,57 +4100,57 @@ void handleError (HWND hwndDlg, int code)
switch (code & 0x0000FFFF)
{
case ERR_OS_ERROR:
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, srcPos);
break;
case ERR_OUTOFMEMORY:
- MessageBoxW (hwndDlg, GetString ("OUTOFMEMORY"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("OUTOFMEMORY"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_PASSWORD_WRONG:
- MessageBoxW (hwndDlg, GetWrongPasswordErrorMessage (hwndDlg).c_str(), lpszTitle, MB_ICONWARNING);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetWrongPasswordErrorMessage (hwndDlg).c_str(), srcPos).c_str(), lpszTitle, MB_ICONWARNING);
break;
case ERR_DRIVE_NOT_FOUND:
- MessageBoxW (hwndDlg, GetString ("NOT_FOUND"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("NOT_FOUND"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_FILES_OPEN:
- MessageBoxW (hwndDlg, GetString ("OPENFILES_DRIVER"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("OPENFILES_DRIVER"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_FILES_OPEN_LOCK:
- MessageBoxW (hwndDlg, GetString ("OPENFILES_LOCK"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("OPENFILES_LOCK"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_VOL_SIZE_WRONG:
- MessageBoxW (hwndDlg, GetString ("VOL_SIZE_WRONG"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("VOL_SIZE_WRONG"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_COMPRESSION_NOT_SUPPORTED:
- MessageBoxW (hwndDlg, GetString ("COMPRESSION_NOT_SUPPORTED"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("COMPRESSION_NOT_SUPPORTED"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_PASSWORD_CHANGE_VOL_TYPE:
- MessageBoxW (hwndDlg, GetString ("WRONG_VOL_TYPE"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("WRONG_VOL_TYPE"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_VOL_SEEKING:
- MessageBoxW (hwndDlg, GetString ("VOL_SEEKING"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("VOL_SEEKING"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_CIPHER_INIT_FAILURE:
- MessageBoxW (hwndDlg, GetString ("ERR_CIPHER_INIT_FAILURE"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ERR_CIPHER_INIT_FAILURE"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_CIPHER_INIT_WEAK_KEY:
- MessageBoxW (hwndDlg, GetString ("ERR_CIPHER_INIT_WEAK_KEY"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ERR_CIPHER_INIT_WEAK_KEY"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_VOL_ALREADY_MOUNTED:
- MessageBoxW (hwndDlg, GetString ("VOL_ALREADY_MOUNTED"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("VOL_ALREADY_MOUNTED"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_FILE_OPEN_FAILED:
- MessageBoxW (hwndDlg, GetString ("FILE_OPEN_FAILED"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("FILE_OPEN_FAILED"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_VOL_MOUNT_FAILED:
- MessageBoxW (hwndDlg, GetString ("VOL_MOUNT_FAILED"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("VOL_MOUNT_FAILED"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_NO_FREE_DRIVES:
- MessageBoxW (hwndDlg, GetString ("NO_FREE_DRIVES"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("NO_FREE_DRIVES"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_ACCESS_DENIED:
- MessageBoxW (hwndDlg, GetString ("ACCESS_DENIED"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ACCESS_DENIED"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_DRIVER_VERSION:
@@ -4158,7 +4158,7 @@ void handleError (HWND hwndDlg, int code)
break;
case ERR_NEW_VERSION_REQUIRED:
- MessageBoxW (hwndDlg, GetString ("NEW_VERSION_REQUIRED"), lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("NEW_VERSION_REQUIRED"), srcPos).c_str(), lpszTitle, ICON_HAND);
break;
case ERR_SELF_TESTS_FAILED:
@@ -4192,24 +4192,24 @@ void handleError (HWND hwndDlg, int code)
case ERR_UNSUPPORTED_TRUECRYPT_FORMAT:
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("UNSUPPORTED_TRUECRYPT_FORMAT"), (code >> 24), (code >> 16) & 0x000000FF);
- MessageBoxW (hwndDlg, szTmp, lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, ICON_HAND);
break;
#ifndef SETUP
case ERR_RAND_INIT_FAILED:
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("INIT_RAND"), SRC_POS, GetLastError ());
- MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONERROR);
+ MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, MB_ICONERROR);
break;
case ERR_CAPI_INIT_FAILED:
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CAPI_RAND"), SRC_POS, CryptoAPILastError);
- MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONERROR);
+ MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, MB_ICONERROR);
break;
#endif
default:
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("ERR_UNKNOWN"), code);
- MessageBoxW (hwndDlg, szTmp, lpszTitle, ICON_HAND);
+ MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, ICON_HAND);
}
}
@@ -5210,7 +5210,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
#ifndef VOLFORMAT
if (Randinit ())
{
- handleError (hwndDlg, (CryptoAPILastError == ERROR_SUCCESS)? ERR_RAND_INIT_FAILED : ERR_CAPI_INIT_FAILED);
+ handleError (hwndDlg, (CryptoAPILastError == ERROR_SUCCESS)? ERR_RAND_INIT_FAILED : ERR_CAPI_INIT_FAILED, SRC_POS);
EndDialog (hwndDlg, IDCLOSE);
}
#endif
@@ -5410,7 +5410,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
TCfree(keyfile);
NormalCursor();
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return 1;
}
@@ -5452,7 +5452,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
TCfree(keyfile);
NormalCursor();
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return 1;
}
}
@@ -5776,7 +5776,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
if ((tmpRetVal = EAInit (ci->ea, (unsigned char *) key, ci->ks)) != ERR_SUCCESS)
{
- handleError (hwndDlg, tmpRetVal);
+ handleError (hwndDlg, tmpRetVal, SRC_POS);
crypto_close (ci);
return 1;
}
@@ -6271,7 +6271,7 @@ int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced)
if (bResult == FALSE)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return 1;
}
@@ -6778,7 +6778,7 @@ retry:
}
if (!quiet && (!MultipleMountOperationInProgress || GetLastError() != ERROR_NOT_READY))
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return -1;
}
@@ -6816,18 +6816,18 @@ retry:
if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &dwResult, NULL) && openTestStruct.TCBootLoaderDetected)
WarningDirect ((GetWrongPasswordErrorMessage (hwndDlg) + L"\n\n" + GetString ("HIDDEN_VOL_PROT_PASSWORD_US_KEYB_LAYOUT")).c_str(), hwndDlg);
else
- handleError (hwndDlg, mount.nReturnCode);
+ handleError (hwndDlg, mount.nReturnCode, SRC_POS);
}
}
else
- handleError (hwndDlg, mount.nReturnCode);
+ handleError (hwndDlg, mount.nReturnCode, SRC_POS);
}
return 0;
}
if (!quiet)
- handleError (hwndDlg, mount.nReturnCode);
+ handleError (hwndDlg, mount.nReturnCode, SRC_POS);
return 0;
}
@@ -7234,7 +7234,7 @@ __int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percentFree
{
if (!silent)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
Error ("CANNOT_CALC_SPACE", MainDlg);
}
@@ -7252,7 +7252,7 @@ __int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percentFree
{
if (!silent)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
Error ("CANT_GET_VOLSIZE", MainDlg);
}
return -1;
@@ -7561,7 +7561,7 @@ BOOL SaveBufferToFile (const char *inputBuffer, const char *destinationFile, DWO
if (dst == INVALID_HANDLE_VALUE)
{
SetLastError (dwLastError);
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
return FALSE;
}
@@ -7579,7 +7579,7 @@ BOOL SaveBufferToFile (const char *inputBuffer, const char *destinationFile, DWO
// If CREATE_ALWAYS is used, ERROR_ALREADY_EXISTS is returned after successful overwrite
// of an existing file (it's not an error)
if (! (GetLastError() == ERROR_ALREADY_EXISTS && !bAppend) )
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
}
CloseHandle (dst);
@@ -9739,7 +9739,7 @@ BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wPara
if (GetWindowTextW (GetDlgItem (hwndDlg, IDC_TOKEN_PASSWORD), passwordWide, SecurityToken::MaxPasswordLength + 1) == 0)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
break;
}
@@ -10020,7 +10020,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
byte *keyfileData = (byte *) LoadFile (keyfilePath, &keyfileSize);
if (!keyfileData)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return 1;
}
@@ -10059,7 +10059,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
else
{
SetLastError (ERROR_HANDLE_EOF);
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
}
burn (keyfileData, keyfileSize);
@@ -10091,14 +10091,14 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
if (keyfileData.empty())
{
SetLastError (ERROR_HANDLE_EOF);
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return 1;
}
finally_do_arg (vector <byte> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); });
if (!SaveBufferToFile ((char *) &keyfileData.front(), keyfilePath, (DWORD) keyfileData.size(), FALSE, FALSE))
- throw SystemException ();
+ throw SystemException (SRC_POS);
}
Info ("KEYFILE_EXPORTED", hwndDlg);
@@ -10481,7 +10481,7 @@ BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath)
FILE *f = fopen (cmdBatch, "w");
if (!f)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return FALSE;
}
@@ -10493,7 +10493,7 @@ BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath)
f = fopen (diskpartScript, "w");
if (!f)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
DeleteFile (cmdBatch);
return FALSE;
}
@@ -10631,7 +10631,7 @@ BOOL LaunchWindowsIsoBurner (HWND hwnd, const char *isoPath)
if (r <= 32)
{
SetLastError (r);
- handleWin32Error (hwnd);
+ handleWin32Error (hwnd, SRC_POS);
return FALSE;
}
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index f6b285c4..1d0db30c 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -237,7 +237,7 @@ void AbortProcess ( char *stringId );
void AbortProcessSilent ( void );
void *err_malloc ( size_t size );
char *err_strdup ( char *lpszText );
-DWORD handleWin32Error ( HWND hwndDlg );
+DWORD handleWin32Error ( HWND hwndDlg, const char* srcPos );
BOOL IsDiskReadError (DWORD error);
BOOL IsDiskWriteError (DWORD error);
BOOL IsDiskError (DWORD error);
@@ -317,7 +317,7 @@ void ResetCipherTest ( HWND hwndDlg , int idTestCipher );
void ResetCurrentDirectory ();
BOOL BrowseFiles (HWND hwndDlg, char *stringId, char *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter);
BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, char *dirName);
-void handleError ( HWND hwndDlg , int code );
+void handleError ( HWND hwndDlg , int code, const char* srcPos );
BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const char *fileName);
void LocalizeDialog ( HWND hwnd, char *stringId );
void OpenVolumeExplorerWindow (int driveNo);
@@ -552,6 +552,10 @@ std::string FindLatestFileOrDirectory (const std::string &directory, const char
std::string GetUserFriendlyVersionString (int version);
std::string IntToString (int val);
std::wstring IntToWideString (int val);
+inline std::wstring AppendSrcPos (const wchar_t* msg, const char* srcPos)
+{
+ return std::wstring (msg) + L"\n\nSource: " + SingleStringToWide (srcPos);
+}
// Display a wait dialog while calling the provided callback with the given parameter
typedef void (CALLBACK* WaitThreadProc)(void* pArg, HWND hWaitDlg);
diff --git a/src/Common/Exception.h b/src/Common/Exception.h
index 0883df14..06545c65 100644
--- a/src/Common/Exception.h
+++ b/src/Common/Exception.h
@@ -11,6 +11,7 @@
#include "Platform/PlatformBase.h"
#include "Dlgcode.h"
+#include "Language.h"
#include <strsafe.h>
namespace VeraCrypt
@@ -22,30 +23,32 @@ namespace VeraCrypt
struct SystemException : public Exception
{
- SystemException () : ErrorCode (GetLastError()) { }
+ SystemException (const char *srcPos) : ErrorCode (GetLastError()), SrcPos (srcPos) { }
void Show (HWND parent) const
{
SetLastError (ErrorCode);
- handleWin32Error (parent);
+ handleWin32Error (parent, SrcPos);
}
DWORD ErrorCode;
+ const char *SrcPos;
};
struct ErrorException : public Exception
{
- ErrorException (char *langId) : ErrLangId (langId) { }
- ErrorException (const wstring &errMsg) : ErrLangId(NULL), ErrMsg (errMsg) { }
+ ErrorException (char *langId, const char *srcPos) : SrcPos (srcPos), ErrLangId (langId) { }
+ ErrorException (const wstring &errMsg, const char *srcPos) : SrcPos (srcPos), ErrLangId(NULL), ErrMsg (errMsg) { }
void Show (HWND parent) const
{
if (ErrMsg.empty())
- ::Error (ErrLangId? ErrLangId : "", parent);
+ ::ErrorDirect (AppendSrcPos (GetString (ErrLangId? ErrLangId : ""), SrcPos).c_str (), parent);
else
- ::ErrorDirect (ErrMsg.c_str(), parent);
+ ::ErrorDirect (AppendSrcPos (ErrMsg.c_str(), SrcPos).c_str (), parent);
}
+ const char *SrcPos;
char *ErrLangId;
wstring ErrMsg;
};
@@ -97,8 +100,10 @@ namespace VeraCrypt
struct TimeOut : public Exception
{
- TimeOut (const char *srcPos) { }
- void Show (HWND parent) const { ErrorDirect (L"Timeout", parent); }
+ TimeOut (const char *srcPos) : SrcPos (srcPos) { }
+ void Show (HWND parent) const { ErrorDirect (AppendSrcPos (L"Timeout", SrcPos).c_str (), parent); }
+
+ const char *SrcPos;
};
struct UserAbort : public Exception
@@ -108,7 +113,7 @@ namespace VeraCrypt
};
}
-#define throw_sys_if(condition) do { if (condition) throw SystemException(); } while (false)
+#define throw_sys_if(condition) do { if (condition) throw SystemException( SRC_POS ); } while (false)
#endif // TC_HEADER_Common_Exception
diff --git a/src/Common/Format.c b/src/Common/Format.c
index 3ebfef1e..14c91a33 100644
--- a/src/Common/Format.c
+++ b/src/Common/Format.c
@@ -31,6 +31,10 @@
#include <Strsafe.h>
+#ifndef SRC_POS
+#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
+#endif
+
int FormatWriteBufferSize = 1024 * 1024;
static uint32 FormatSectorSize = 0;
@@ -286,7 +290,7 @@ begin_format:
}
else
{
- handleWin32Error (volParams->hwndDlg);
+ handleWin32Error (volParams->hwndDlg, SRC_POS);
Error ("CANT_ACCESS_VOL", hwndDlg);
nStatus = ERR_DONT_REPORT;
goto error;
@@ -893,7 +897,7 @@ static void __cdecl FormatWriteThreadProc (void *arg)
{
if (WaitForSingleObject (WriteBufferFullEvent, INFINITE) == WAIT_FAILED)
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
break;
}
@@ -907,7 +911,7 @@ static void __cdecl FormatWriteThreadProc (void *arg)
if (!SetEvent (WriteBufferEmptyEvent))
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
break;
}
}
diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c
index cb36a146..dbda7d3c 100644
--- a/src/Common/Keyfiles.c
+++ b/src/Common/Keyfiles.c
@@ -252,7 +252,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
if (keyfileData.empty())
{
SetLastError (ERROR_HANDLE_EOF);
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
continue;
@@ -291,7 +291,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
// Determine whether it's a path or a file
if (stat (kf->FileName, &statStruct) != 0)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
continue;
@@ -305,7 +305,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
StringCbPrintfA (searchPath, sizeof (searchPath), "%s\\*.*", kf->FileName);
if ((searchHandle = _findfirst (searchPath, &fBuf)) == -1)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE_PATH", hwndDlg);
status = FALSE;
continue;
@@ -323,7 +323,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
// Determine whether it's a path or a file
if (stat (kfSub->FileName, &statStruct) != 0)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
continue;
@@ -347,7 +347,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
// Apply keyfile to the pool
if (!KeyFileProcess (keyPool, kfSub))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
}
@@ -366,7 +366,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile)
// Apply keyfile to the pool
else if (!KeyFileProcess (keyPool, kf))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("ERR_PROCESS_KEYFILE", hwndDlg);
status = FALSE;
}
diff --git a/src/Common/Language.h b/src/Common/Language.h
index d2dde96c..750a3972 100644
--- a/src/Common/Language.h
+++ b/src/Common/Language.h
@@ -6,6 +6,8 @@
packages.
*/
+#pragma once
+
#include <windows.h>
#ifdef __cplusplus
diff --git a/src/Common/Password.c b/src/Common/Password.c
index 3ae264d2..b3dd54bb 100644
--- a/src/Common/Password.c
+++ b/src/Common/Password.c
@@ -22,6 +22,10 @@
#include <io.h>
+#ifndef SRC_POS
+#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
+#endif
+
void VerifyPasswordAndUpdate (HWND hwndDlg, HWND hButton, HWND hPassword,
HWND hVerify, unsigned char *szPassword,
char *szVerify,
@@ -160,14 +164,14 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, int old_pkcs5, int
if ((wipePassCount <= 0) || (truecryptMode && (old_pkcs5 == SHA256)))
{
nStatus = ERR_PARAMETER_INCORRECT;
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
return nStatus;
}
if (!lpszVolume)
{
nStatus = ERR_OUTOFMEMORY;
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
return nStatus;
}
@@ -451,7 +455,7 @@ error:
return nStatus;
if (nStatus != 0)
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
return nStatus;
}
diff --git a/src/Common/Random.c b/src/Common/Random.c
index c1479340..1a0637ba 100644
--- a/src/Common/Random.c
+++ b/src/Common/Random.c
@@ -66,6 +66,10 @@ void RandAddInt64 (unsigned __int64 x)
#include <tlhelp32.h>
#include "Dlgcode.h"
+#ifndef SRC_POS
+#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
+#endif
+
HHOOK hMouse = NULL; /* Mouse hook for the random number generator */
HHOOK hKeyboard = NULL; /* Keyboard hook for the random number generator */
@@ -112,12 +116,12 @@ int Randinit ()
}
hKeyboard = SetWindowsHookEx (WH_KEYBOARD, (HOOKPROC)&KeyboardProc, NULL, GetCurrentThreadId ());
- if (hKeyboard == 0) handleWin32Error (0);
+ if (hKeyboard == 0) handleWin32Error (0, SRC_POS);
hMouse = SetWindowsHookEx (WH_MOUSE, (HOOKPROC)&MouseProc, NULL, GetCurrentThreadId ());
if (hMouse == 0)
{
- handleWin32Error (0);
+ handleWin32Error (0, SRC_POS);
goto error;
}
@@ -388,7 +392,7 @@ BOOL RandgetBytesFull ( void* hwndDlg, unsigned char *buf , int len, BOOL forceS
{
if (!SlowPoll ())
{
- handleError ((HWND) hwndDlg, ERR_CAPI_INIT_FAILED);
+ handleError ((HWND) hwndDlg, ERR_CAPI_INIT_FAILED, SRC_POS);
ret = FALSE;
}
else
@@ -397,7 +401,7 @@ BOOL RandgetBytesFull ( void* hwndDlg, unsigned char *buf , int len, BOOL forceS
if (!FastPoll ())
{
- handleError ((HWND) hwndDlg, ERR_CAPI_INIT_FAILED);
+ handleError ((HWND) hwndDlg, ERR_CAPI_INIT_FAILED, SRC_POS);
ret = FALSE;
}
diff --git a/src/ExpandVolume/DlgExpandVolume.cpp b/src/ExpandVolume/DlgExpandVolume.cpp
index 554f4f6f..15888f50 100644
--- a/src/ExpandVolume/DlgExpandVolume.cpp
+++ b/src/ExpandVolume/DlgExpandVolume.cpp
@@ -385,7 +385,7 @@ BOOL CALLBACK ExpandVolProgressDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, L
pProgressDlgParam->hwndDlg = hwndDlg;
if ( _beginthread (volTransformThreadFunction, 0, pProgressDlgParam) == -1L )
{
- handleError (hwndDlg, ERR_OS_ERROR);
+ handleError (hwndDlg, ERR_OS_ERROR, SRC_POS);
EndDialog (hwndDlg, lw);
}
WaitCursor();
@@ -572,7 +572,7 @@ void ExpandVolumeWizard (HWND hwndDlg, char *lpszVolume)
NormalCursor();
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
}
WaitCursor();
@@ -722,7 +722,7 @@ ret:
error:
if (nStatus != 0)
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
burn (&VolumePassword, sizeof (VolumePassword));
diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c
index 5b9509be..9233340c 100644
--- a/src/ExpandVolume/ExpandVolume.c
+++ b/src/ExpandVolume/ExpandVolume.c
@@ -56,6 +56,10 @@ Original legal notice of the TrueCrypt source files:
#include "ExpandVolume.h"
#include "Resource.h"
+#ifndef SRC_POS
+#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
+#endif
+
#define DEBUG_EXPAND_VOLUME
#ifdef DEBUG_EXPAND_VOLUME
@@ -987,7 +991,7 @@ void __cdecl volTransformThreadFunction (void *pExpandDlgParam)
pParam->VolumePkcs5, pParam->VolumePin, pParam->newSize, pParam->bInitFreeSpace );
if (nStatus!=ERR_SUCCESS && nStatus!=ERR_USER_ABORT)
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
bVolTransformThreadCancel = FALSE;
diff --git a/src/ExpandVolume/InitDataArea.c b/src/ExpandVolume/InitDataArea.c
index a3793e86..c1eb6bd2 100644
--- a/src/ExpandVolume/InitDataArea.c
+++ b/src/ExpandVolume/InitDataArea.c
@@ -59,6 +59,10 @@ Original legal notice of the TrueCrypt source:
#include "InitDataArea.h"
+#ifndef SRC_POS
+#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
+#endif
+
int FormatWriteBufferSize = 1024 * 1024;
static uint32 FormatSectorSize = 0;
@@ -226,7 +230,7 @@ static void __cdecl FormatWriteThreadProc (void *arg)
{
if (WaitForSingleObject (WriteBufferFullEvent, INFINITE) == WAIT_FAILED)
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
break;
}
@@ -240,7 +244,7 @@ static void __cdecl FormatWriteThreadProc (void *arg)
if (!SetEvent (WriteBufferEmptyEvent))
{
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
break;
}
}
diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp
index 81d782c1..020a6b22 100644
--- a/src/ExpandVolume/WinMain.cpp
+++ b/src/ExpandVolume/WinMain.cpp
@@ -983,9 +983,9 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
if (status != 0)
{
if (status == ERR_OS_ERROR)
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
else
- handleError (NULL, status);
+ handleError (NULL, status, SRC_POS);
AbortProcess ("NODRIVER");
}
diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c
index 24303036..80d6ab3e 100644
--- a/src/Format/InPlace.c
+++ b/src/Format/InPlace.c
@@ -79,7 +79,7 @@ static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const char *devicePath, in
NULL))
{
if (!silent)
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
return -1;
}
@@ -90,7 +90,7 @@ static __int64 NewFileSysSizeAfterShrink (HANDLE dev, const char *devicePath, in
{
SetLastError (ERROR_INTERNAL_ERROR);
if (!silent)
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
return -1;
}
@@ -189,7 +189,7 @@ BOOL CheckRequirementsForNonSysInPlaceEnc (HWND hwndDlg, const char *devicePath,
{
if (!silent)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL", hwndDlg);
}
return FALSE;
@@ -458,7 +458,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
&dwResult,
NULL))
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
nStatus = ERR_DONT_REPORT;
goto closing_seq;
@@ -496,7 +496,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
&dwResult,
NULL))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "CANNOT_RESIZE_FILESYS", TRUE);
nStatus = ERR_DONT_REPORT;
goto closing_seq;
@@ -523,11 +523,11 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
continue;
}
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
}
}
else
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "CANNOT_RESIZE_FILESYS", TRUE);
nStatus = ERR_DONT_REPORT;
@@ -1237,7 +1237,7 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile
if (driveLetter == -1
|| !UnmountVolume (hwndDlg, driveLetter, TRUE))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
AbortProcess ("CANT_DISMOUNT_VOLUME");
}
}
@@ -1797,7 +1797,7 @@ static HANDLE OpenPartitionVolume (HWND hwndDlg, const char *devName,
{
if (!bSilent)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
if (bShowAlternativeSteps)
ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
@@ -1823,7 +1823,7 @@ static HANDLE OpenPartitionVolume (HWND hwndDlg, const char *devName,
{
if (!bSilent)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
if (bShowAlternativeSteps)
ShowInPlaceEncErrMsgWAltSteps (hwndDlg, "INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT", TRUE);
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index bee1e028..523c069b 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -308,7 +308,7 @@ void CALLBACK ResumeInPlaceEncWaitThreadProc(void* pArg, HWND hwndDlg)
}
else
{
- handleError(hwndDlg, status);
+ handleError(hwndDlg, status, SRC_POS);
}
break;
@@ -524,7 +524,7 @@ static BOOL SaveSysEncSettings (HWND hwndDlg)
if (f == NULL)
{
Error ("CANNOT_SAVE_SYS_ENCRYPTION_SETTINGS", hwndDlg);
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return FALSE;
}
@@ -540,7 +540,7 @@ static BOOL SaveSysEncSettings (HWND hwndDlg)
|| XmlWriteFooter (f) < 0)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
fclose (f);
Error ("CANNOT_SAVE_SYS_ENCRYPTION_SETTINGS", hwndDlg);
return FALSE;
@@ -2662,7 +2662,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
wchar_t szMsg[8192];
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
if (bInPlaceEncNonSys)
{
@@ -3292,7 +3292,7 @@ BOOL QueryFreeSpace (HWND hwndDlg, HWND hwndTextBox, BOOL display)
if (!GetVolumePathName (szFileName, root, sizeof (root)))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return FALSE;
}
@@ -5226,7 +5226,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
nVolumeSize = GetDeviceSize (szDiskFile);
if (nVolumeSize == -1)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
return 1;
}
@@ -5846,7 +5846,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (!ComServerFormat ())
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
exit (1);
}
exit (0);
@@ -6993,7 +6993,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (nVolumeSize == -1)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
return 1;
}
@@ -7353,7 +7353,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
nVolumeSize = GetDeviceSize (szDiskFile);
if (nVolumeSize == -1)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
NormalCursor();
return 1;
}
@@ -7380,7 +7380,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (driveNo == -1
|| !UnmountVolume (hwndDlg, driveNo, TRUE))
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
AbortProcess ("CANT_DISMOUNT_VOLUME");
}
}
@@ -7413,7 +7413,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
volProp.driveNo = driveNo;
if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &volProp, sizeof (volProp), &volProp, sizeof (volProp), &dwResult, NULL) || dwResult == 0)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
UnmountVolume (hwndDlg, driveNo, TRUE);
AbortProcess ("CANT_GET_VOL_INFO");
}
@@ -7435,7 +7435,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (!UnmountVolume (hwndDlg, driveNo, TRUE))
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
AbortProcess ("CANT_DISMOUNT_VOLUME");
}
@@ -7449,7 +7449,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (!UnmountVolume (hwndDlg, driveNo, TRUE))
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
AbortProcess ("CANT_DISMOUNT_VOLUME");
}
@@ -7460,7 +7460,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
nVolumeSize = GetDeviceSize (szDiskFile);
if (nVolumeSize == -1)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
AbortProcessSilent ();
}
@@ -8745,7 +8745,7 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi
volProp.driveNo = *driveNo;
if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &volProp, sizeof (volProp), &volProp, sizeof (volProp), &dwResult, NULL) || dwResult == 0)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("CANT_ACCESS_OUTER_VOL", hwndDlg);
goto efsf_error;
}
@@ -8783,7 +8783,7 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi
if (SetFilePointerEx (hDevice, offset, &offsetNew, FILE_BEGIN) == 0)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
goto efs_error;
}
@@ -8791,7 +8791,7 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi
if (result == 0)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
MessageBoxW (hwndDlg, GetString ("CANT_ACCESS_OUTER_VOL"), lpszTitle, ICON_HAND);
goto efs_error;
}
@@ -8842,7 +8842,7 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi
&dwNumberOfFreeClusters,
&dwTotalNumberOfClusters))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("CANT_GET_OUTER_VOL_INFO", hwndDlg);
return -1;
};
@@ -8955,7 +8955,7 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int
&lBytesReturned,
NULL))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
MessageBoxW (hwndDlg, GetString ("CANT_GET_CLUSTER_BITMAP"), lpszTitle, ICON_HAND);
goto vcm_error;
@@ -9649,9 +9649,9 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
if (status != 0)
{
if (status == ERR_OS_ERROR)
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
else
- handleError (NULL, status);
+ handleError (NULL, status, SRC_POS);
AbortProcess ("NODRIVER");
}
@@ -9677,7 +9677,7 @@ static int GetFormatSectorSize ()
if (!GetDriveGeometry (szDiskFile, &geometry))
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
AbortProcessSilent();
}
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index 50842a35..eede24f3 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -39,7 +39,7 @@ namespace VeraCrypt
if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &prop, sizeof (prop), &prop, sizeof (prop), &bytesReturned, NULL))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return FALSE;
}
@@ -137,7 +137,7 @@ namespace VeraCrypt
BootEncryptionStatus bootEncStatus = BootEncryption (hwndDlg).GetStatus();
if (!bootEncStatus.DriveMounted)
- throw ErrorException ("SYS_FAVORITES_REQUIRE_PBA");
+ throw ErrorException ("SYS_FAVORITES_REQUIRE_PBA", SRC_POS);
ShowWindow (GetDlgItem(hwndDlg, IDC_FAVORITE_MOUNT_ON_LOGON), SW_HIDE);
ShowWindow (GetDlgItem(hwndDlg, IDC_FAVORITE_MOUNT_ON_ARRIVAL), SW_HIDE);
@@ -667,7 +667,7 @@ namespace VeraCrypt
f = fopen (GetConfigPath (systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES), "w,ccs=UTF-8");
if (f == NULL)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
return false;
}
diff --git a/src/Mount/Hotkeys.c b/src/Mount/Hotkeys.c
index 0848155e..7840a6c7 100644
--- a/src/Mount/Hotkeys.c
+++ b/src/Mount/Hotkeys.c
@@ -15,6 +15,10 @@
#include <Strsafe.h>
+#ifndef SRC_POS
+#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
+#endif
+
#define MAX_KEY_COMB_NAME_LEN 260
TCHOTKEY Hotkeys [NBR_HOTKEYS];
@@ -422,13 +426,13 @@ BOOL CALLBACK HotkeysDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
if (!bOwnActiveShortcut
&& !RegisterHotKey (hwndDlg, nSelectedHotkeyId, modifiers, currentVKeyCode))
{
- handleWin32Error(hwndDlg);
+ handleWin32Error(hwndDlg, SRC_POS);
return 1;
}
else
{
if (!bOwnActiveShortcut && !UnregisterHotKey (hwndDlg, nSelectedHotkeyId))
- handleWin32Error(hwndDlg);
+ handleWin32Error(hwndDlg, SRC_POS);
tmpHotkeys[nSelectedHotkeyId].vKeyCode = currentVKeyCode;
tmpHotkeys[nSelectedHotkeyId].vKeyModifiers = modifiers;
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 512989ef..37e486a9 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -1325,7 +1325,7 @@ static void LaunchVolCreationWizard (HWND hwndDlg, const char *arg)
if (!CreateProcess (NULL, (LPSTR) t, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
}
else
{
@@ -1352,7 +1352,7 @@ static void LaunchVolExpander (HWND hwndDlg)
Error ("VOL_EXPANDER_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do
else if (((int)ShellExecuteA (NULL, (!IsAdmin() && IsUacSupported()) ? "runas" : "open", t, NULL, NULL, SW_SHOW)) <= 32)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
}
}
}
@@ -1408,7 +1408,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
if (bResult == FALSE)
{
KillTimer (MainDlg, TIMER_ID_MAIN);
- handleWin32Error (hTree);
+ handleWin32Error (hTree, SRC_POS);
AbortProcessSilent();
}
@@ -3882,7 +3882,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
StringCbPrintfA (dstPath, sizeof(dstPath), "%s\\VeraCrypt\\VeraCrypt.exe", dstDir);
if (!TCCopyFile (srcPath, dstPath))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
goto stop;
}
@@ -3893,7 +3893,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
StringCbPrintfA (dstPath, sizeof(dstPath), "%s\\VeraCrypt\\VeraCrypt Format.exe", dstDir);
if (!TCCopyFile (srcPath, dstPath))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
goto stop;
}
}
@@ -3903,7 +3903,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
StringCbPrintfA (dstPath, sizeof(dstPath), "%s\\VeraCrypt\\veracrypt.sys", dstDir);
if (!TCCopyFile (srcPath, dstPath))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
goto stop;
}
@@ -3912,7 +3912,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
StringCbPrintfA (dstPath, sizeof(dstPath), "%s\\VeraCrypt\\veracrypt-x64.sys", dstDir);
if (!TCCopyFile (srcPath, dstPath))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
goto stop;
}
@@ -4179,7 +4179,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pin)
if (!VolumePathExists (szFileName))
{
if (!MultipleMountOperationInProgress)
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
status = FALSE;
goto ret;
@@ -4431,7 +4431,7 @@ retry:
if (bResult == FALSE)
{
NormalCursor();
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return FALSE;
}
@@ -4798,7 +4798,7 @@ static void ChangePassword (HWND hwndDlg)
if (!VolumePathExists (szFileName))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return;
}
@@ -5119,7 +5119,7 @@ static void DecryptNonSysDevice (HWND hwndDlg, BOOL bResolveAmbiguousSelection,
if (!DeviceIoControl (hDriver, TC_IOCTL_GET_VOLUME_PROPERTIES, &prop, sizeof (prop), &prop, sizeof (prop), &bytesReturned, NULL))
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
return;
}
@@ -5446,7 +5446,7 @@ static void WipeCache (HWND hwndDlg, BOOL silent)
return;
if (bResult == FALSE)
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
else
{
EnableDisableButtons (hwndDlg);
@@ -5716,7 +5716,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (!ComServerMain ())
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
exit (1);
}
exit (0);
@@ -5785,7 +5785,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (!VolumePathExists (szFileName))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
}
else
{
@@ -8190,9 +8190,9 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, char *lpszComm
if (status != 0)
{
if (status == ERR_OS_ERROR)
- handleWin32Error (NULL);
+ handleWin32Error (NULL, SRC_POS);
else
- handleError (NULL, status);
+ handleError (NULL, status, SRC_POS);
AbortProcess ("NODRIVER");
}
@@ -8560,7 +8560,7 @@ static void SaveDefaultKeyFilesParam (HWND hwnd)
f = fopen (GetConfigPath (TC_APPD_FILENAME_DEFAULT_KEYFILES), "w");
if (f == NULL)
{
- handleWin32Error (MainDlg);
+ handleWin32Error (MainDlg, SRC_POS);
return;
}
@@ -8729,7 +8729,7 @@ int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lps
if (!lpszVolume)
{
nStatus = ERR_OUTOFMEMORY;
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
return nStatus;
}
@@ -8754,7 +8754,7 @@ int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lps
if (!VolumePathExists (lpszVolume))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
goto ret;
}
@@ -8794,7 +8794,7 @@ int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lps
|| (type == TC_VOLUME_TYPE_HIDDEN && !askVol->CryptoInfo->hiddenVolume))
{
CloseVolume (askVol);
- handleError (hwndDlg, ERR_PASSWORD_WRONG);
+ handleError (hwndDlg, ERR_PASSWORD_WRONG, SRC_POS);
continue;
}
@@ -8823,7 +8823,7 @@ int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const char *lps
if (nStatus != ERR_PASSWORD_WRONG)
goto error;
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
}
}
noHidden:
@@ -8937,7 +8937,7 @@ error:
SetLastError (dwError);
if (nStatus != 0)
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
burn (&VolumePassword, sizeof (VolumePassword));
burn (&VolumePkcs5, sizeof (VolumePkcs5));
@@ -8977,7 +8977,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
if (!lpszVolume)
{
nStatus = ERR_OUTOFMEMORY;
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
return nStatus;
}
@@ -9008,7 +9008,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
if (!VolumePathExists (lpszVolume))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
return 0;
}
@@ -9065,7 +9065,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
if (nStatus != ERR_PASSWORD_WRONG)
goto error;
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
}
if (volume.CryptoInfo->LegacyVolume)
@@ -9273,7 +9273,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const char *lpszVolume)
if (nStatus != ERR_PASSWORD_WRONG)
goto error;
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
}
BOOL hiddenVol = restoredCryptoInfo->hiddenVolume;
@@ -9363,7 +9363,7 @@ error:
SetLastError (dwError);
if (nStatus != 0)
- handleError (hwndDlg, nStatus);
+ handleError (hwndDlg, nStatus, SRC_POS);
burn (&VolumePassword, sizeof (VolumePassword));
burn (&VolumePkcs5, sizeof (VolumePkcs5));
@@ -9486,7 +9486,7 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
DWORD bytesReturned;
if (!DeviceIoControl (hDriver, TC_IOCTL_REREAD_DRIVER_CONFIG, NULL, 0, NULL, 0, &bytesReturned, NULL))
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
EnableHwEncryption (!disableHW);
diff --git a/src/Setup/SelfExtract.c b/src/Setup/SelfExtract.c
index a4acde26..3ebaf5e6 100644
--- a/src/Setup/SelfExtract.c
+++ b/src/Setup/SelfExtract.c
@@ -20,6 +20,10 @@
#include "Resource.h"
#include <Strsafe.h>
+#ifndef SRC_POS
+#define SRC_POS (__FUNCTION__ ":" TC_TO_STRING(__LINE__))
+#endif
+
#define OutputPackageFile "VeraCrypt Setup " VERSION_STRING ".exe"
#define MAG_START_MARKER "TCINSTRT"
@@ -252,7 +256,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
if (!TCCopyFile (inputFile, outputFile))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
PkgError ("Cannot copy 'VeraCrypt Setup.exe' to the package");
goto err;
}
@@ -435,7 +439,7 @@ BOOL MakeSelfExtractingPackage (HWND hwndDlg, char *szDestDir)
if (tmpBuffer == NULL)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
if (remove (outputFile))
PkgError ("Cannot load the package to compute CRC.\nFailed also to delete package file");
else
@@ -720,7 +724,7 @@ void __cdecl ExtractAllFilesThread (void *hwndDlg)
{
wchar_t szTmp[TC_MAX_PATH];
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CANT_CREATE_FOLDER"), DestExtractPath);
MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONHAND);
bSuccess = FALSE;
diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c
index baf4faf7..a5a30189 100644
--- a/src/Setup/Setup.c
+++ b/src/Setup/Setup.c
@@ -726,7 +726,7 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
// Dump filter driver cannot be installed to SysWOW64 directory
if (driver64 && !EnableWow64FsRedirection (FALSE))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
bResult = FALSE;
goto err;
}
@@ -742,7 +742,7 @@ BOOL DoFilesInstall (HWND hwndDlg, char *szDestDir)
{
if (!EnableWow64FsRedirection (TRUE))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
bResult = FALSE;
goto err;
}
@@ -1002,7 +1002,7 @@ error:
if (bOK == FALSE)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("REG_INSTALL_FAILED", hwndDlg);
}
@@ -1060,7 +1060,7 @@ BOOL DoApplicationDataUninstall (HWND hwndDlg)
RemoveMessage (hwndDlg, path);
if (!StatRemoveDirectory (path))
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
bOK = FALSE;
}
@@ -1274,7 +1274,7 @@ error:
if (bOK == FALSE && GetLastError ()!= ERROR_SERVICE_DOES_NOT_EXIST)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
MessageBoxW (hwndDlg, GetString ("DRIVER_UINSTALL_FAILED"), lpszTitle, MB_ICONHAND);
}
else
@@ -1300,13 +1300,13 @@ BOOL DoDriverUnload (HWND hwndDlg)
{
if (status == ERR_OS_ERROR && GetLastError () != ERROR_FILE_NOT_FOUND)
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
AbortProcess ("NODRIVER");
}
if (status != ERR_OS_ERROR)
{
- handleError (NULL, status);
+ handleError (NULL, status, SRC_POS);
AbortProcess ("NODRIVER");
}
}
@@ -1401,7 +1401,7 @@ BOOL DoDriverUnload (HWND hwndDlg)
else
{
bOK = FALSE;
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
}
}
@@ -1544,7 +1544,7 @@ BOOL DoShortcutsUninstall (HWND hwndDlg, char *szDestDir)
// Start menu group
RemoveMessage ((HWND) hwndDlg, szLinkDir);
if (StatRemoveDirectory (szLinkDir) == FALSE)
- handleWin32Error ((HWND) hwndDlg);
+ handleWin32Error ((HWND) hwndDlg, SRC_POS);
// Desktop icon
@@ -1613,7 +1613,7 @@ BOOL DoShortcutsInstall (HWND hwndDlg, char *szDestDir, BOOL bProgGroup, BOOL bD
{
wchar_t szTmpW[TC_MAX_PATH];
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
StringCbPrintfW (szTmpW, sizeof(szTmpW), GetString ("CANT_CREATE_FOLDER"), szLinkDir);
MessageBoxW (hwndDlg, szTmpW, lpszTitle, MB_ICONHAND);
goto error;
@@ -1895,7 +1895,7 @@ void DoInstall (void *arg)
{
wchar_t szTmp[TC_MAX_PATH];
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CANT_CREATE_FOLDER"), InstallationPath);
MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONHAND);
Error ("INSTALL_FAILED", hwndDlg);
@@ -1938,7 +1938,7 @@ void DoInstall (void *arg)
{
if (!DisablePagingFile())
{
- handleWin32Error (hwndDlg);
+ handleWin32Error (hwndDlg, SRC_POS);
Error ("FAILED_TO_DISABLE_PAGING_FILES", hwndDlg);
}
else