VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/BootEncryption.cpp21
-rw-r--r--src/Common/Crypto.c1
-rw-r--r--src/Common/Dlgcode.c88
-rw-r--r--src/Common/Format.c6
-rw-r--r--src/Common/Keyfiles.c4
-rw-r--r--src/Common/Language.c12
-rw-r--r--src/Common/Pkcs5.c4
-rw-r--r--src/Common/Progress.c10
-rw-r--r--src/Common/SecurityToken.cpp4
9 files changed, 77 insertions, 73 deletions
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index ed185fc0..b377ad7d 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -1143,3 +1143,3 @@ namespace VeraCrypt
// Find the first active partition on the system drive
- foreach (const Partition &partition, config.Partitions)
+ for (const Partition& partition : config.Partitions)
{
@@ -1156,9 +1156,9 @@ namespace VeraCrypt
- foreach (const Partition &partition, config.Partitions)
+ for (const Partition &otherPartition : config.Partitions)
{
- if (partition.Info.StartingOffset.QuadPart > bootPartition.Info.StartingOffset.QuadPart
- && partition.Info.StartingOffset.QuadPart < minOffsetFound)
+ if (otherPartition.Info.StartingOffset.QuadPart > bootPartition.Info.StartingOffset.QuadPart
+ && otherPartition.Info.StartingOffset.QuadPart < minOffsetFound)
{
- minOffsetFound = partition.Info.StartingOffset.QuadPart;
- partitionBehindBoot = partition;
+ minOffsetFound = otherPartition.Info.StartingOffset.QuadPart;
+ partitionBehindBoot = otherPartition;
}
@@ -1353,7 +1353,7 @@ namespace VeraCrypt
// Mount point
- int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) partPath.str().c_str());
+ int driveLetter = GetDiskDeviceDriveLetter ((wchar_t *) partPath.str().c_str());
- if (driveNumber >= 0)
+ if (driveLetter >= 0)
{
- part.MountPoint += (wchar_t) (driveNumber + L'A');
+ part.MountPoint += (wchar_t) (driveLetter + L'A');
part.MountPoint += L":";
@@ -2443,3 +2443,4 @@ namespace VeraCrypt
string copieValue = fieldValue;
- std::transform(copieValue.begin(), copieValue.end(), copieValue.begin(), ::tolower);
+ std::transform(copieValue.begin(), copieValue.end(), copieValue.begin(),
+ [](unsigned char c) { return static_cast<char>(std::tolower(c)); });
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c
index 5856df48..5a10e995 100644
--- a/src/Common/Crypto.c
+++ b/src/Common/Crypto.c
@@ -18,2 +18,3 @@
#include "Common/Endian.h"
+#include "Crypto/t1ha.h"
#if !defined(_UEFI)
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index ba0173ac..e56c6b46 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -16,2 +16,3 @@
#include <windowsx.h>
+#include <versionhelpers.h>
#include <dbghelp.h>
@@ -1085,5 +1086,2 @@ static BOOL GetWindowsVersion(LPOSVERSIONINFOW lpVersionInformation)
- if (!bRet)
- bRet = GetVersionExW (lpVersionInformation);
-
#ifdef SETUP_DLL
@@ -3168,3 +3166,3 @@ BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_
- if ((int)ShellExecuteW (hWnd, L"runas", szModPath, newCmdLine, NULL, SW_SHOWNORMAL) <= 32)
+ if ((INT_PTR)ShellExecuteW (hWnd, L"runas", szModPath, newCmdLine, NULL, SW_SHOWNORMAL) <= 32)
{
@@ -3913,3 +3911,3 @@ BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize)
DWORD fileSystemFlags;
- wchar_t root[] = { L'A' + (wchar_t) driveNo, L':', L'\\', 0 };
+ wchar_t root[] = { (wchar_t) (L'A' + driveNo), L':', L'\\', 0 };
@@ -3943,3 +3941,4 @@ BOOL GetSysDevicePaths (HWND hwndDlg)
// Find extra boot partition
- foreach (const HostDevice &drive, GetAvailableHostDevices (false, false))
+ std::vector <HostDevice> devices = GetAvailableHostDevices(false, false);
+ for (const HostDevice& drive : devices)
{
@@ -3947,3 +3946,3 @@ BOOL GetSysDevicePaths (HWND hwndDlg)
{
- foreach (const HostDevice &sysDrivePartition, drive.Partitions)
+ for (const HostDevice &sysDrivePartition : drive.Partitions)
{
@@ -5391,3 +5390,3 @@ BOOL SelectMultipleFiles(HWND hwndDlg, const char *stringId, BOOL keepHistory, s
-BOOL BrowseDirectories(HWND hwndDlg, char *lpszTitle, wchar_t *dirName, const wchar_t *initialDir)
+BOOL BrowseDirectories(HWND hwndDlg, char *lpszDlgTitle, wchar_t *dirName, const wchar_t *initialDir)
{
@@ -5416,5 +5415,5 @@ BOOL BrowseDirectories(HWND hwndDlg, char *lpszTitle, wchar_t *dirName, const wc
// Set the title.
- if (lpszTitle)
+ if (lpszDlgTitle)
{
- pfd->SetTitle(GetString(lpszTitle));
+ pfd->SetTitle(GetString(lpszDlgTitle));
}
@@ -5756,3 +5755,3 @@ BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValu
wchar_t wszRegPath[MAX_PATH];
- wchar_t driveStr[] = {L'A' + (wchar_t) driveNo, 0};
+ wchar_t driveStr[] = { (wchar_t) (L'A' + driveNo), 0};
HKEY hKey;
@@ -8258,3 +8257,3 @@ void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap)
{
- wchar_t root[] = { (wchar_t) i + L'A', L':', L'\\', 0 };
+ wchar_t root[] = { (wchar_t) (i + L'A'), L':', L'\\', 0 };
SHChangeNotify (eventId, SHCNF_PATH, root, NULL);
@@ -8815,3 +8814,3 @@ retry:
VOLUME_DISK_EXTENTS extents = {0};
- DWORD dwResult = 0;
+ DWORD cbReturnedBytes = 0;
drivePath[4] = root[0];
@@ -8820,3 +8819,3 @@ retry:
{
- if (DeviceIoControl (dev, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &extents, sizeof(extents), &dwResult, NULL))
+ if (DeviceIoControl (dev, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &extents, sizeof(extents), &cbReturnedBytes, NULL))
{
@@ -8957,5 +8956,5 @@ retry:
{
- int driveNo;
+ int diskNo;
- if (swscanf (volumePath, L"\\Device\\Harddisk%d\\Partition", &driveNo) == 1)
+ if (swscanf (volumePath, L"\\Device\\Harddisk%d\\Partition", &diskNo) == 1)
{
@@ -8965,6 +8964,6 @@ retry:
openTestStruct.bDetectTCBootLoader = TRUE;
- StringCchPrintfW ((wchar_t *) openTestStruct.wszFileName, array_capacity (openTestStruct.wszFileName), L"\\Device\\Harddisk%d\\Partition0", driveNo);
+ StringCchPrintfW ((wchar_t *) openTestStruct.wszFileName, array_capacity (openTestStruct.wszFileName), L"\\Device\\Harddisk%d\\Partition0", diskNo);
- DWORD dwResult;
- if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &dwResult, NULL) && openTestStruct.TCBootLoaderDetected)
+ DWORD cbBytesReturned;
+ if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &cbBytesReturned, NULL) && openTestStruct.TCBootLoaderDetected)
WarningDirect ((GetWrongPasswordErrorMessage (hwndDlg) + L"\n\n" + GetString ("HIDDEN_VOL_PROT_PASSWORD_US_KEYB_LAYOUT")).c_str(), hwndDlg);
@@ -9007,3 +9006,3 @@ retry:
wchar_t msg[1024];
- wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
+ wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_VOLUME_DIRTY"), mountPoint);
@@ -9021,3 +9020,3 @@ retry:
wchar_t msg[1024];
- wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
+ wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_CONTAINER_FORCED_READ_ONLY"), mountPoint);
@@ -9032,3 +9031,3 @@ retry:
wchar_t msg[1024];
- wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
+ wchar_t mountPoint[] = { (wchar_t)(L'A' + driveNo), L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY"), mountPoint);
@@ -9043,3 +9042,3 @@ retry:
wchar_t msg[1024];
- wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
+ wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY_WRITE_PROTECTION"), mountPoint);
@@ -9061,3 +9060,3 @@ retry:
wchar_t msg[1024];
- wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
+ wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("PARTIAL_SYSENC_MOUNT_READONLY"), mountPoint);
@@ -9154,3 +9153,3 @@ retry:
// Undo SHCNE_DRIVEREMOVED
- wchar_t root[] = { (wchar_t) nDosDriveNo + L'A', L':', L'\\', 0 };
+ wchar_t root[] = { (wchar_t) (nDosDriveNo + L'A'), L':', L'\\', 0 };
SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL);
@@ -9508,3 +9507,3 @@ int GetDiskDeviceDriveLetter (PWSTR deviceName)
{
- WCHAR drive[] = { (WCHAR) i + L'A', L':', 0 };
+ WCHAR drive[] = { (WCHAR) (i + L'A'), L':', 0 };
@@ -10706,3 +10705,3 @@ void OpenPageHelp (HWND hwndDlg, int nPage)
{
- int r = (int)ShellExecuteW (NULL, L"open", szHelpFile, NULL, NULL, SW_SHOWNORMAL);
+ INT_PTR r = (INT_PTR)ShellExecuteW (NULL, L"open", szHelpFile, NULL, NULL, SW_SHOWNORMAL);
@@ -10711,3 +10710,3 @@ void OpenPageHelp (HWND hwndDlg, int nPage)
// Try the secondary help file
- r = (int)ShellExecuteW (NULL, L"open", szHelpFile2, NULL, NULL, SW_SHOWNORMAL);
+ r = (INT_PTR)ShellExecuteW (NULL, L"open", szHelpFile2, NULL, NULL, SW_SHOWNORMAL);
@@ -10938,7 +10937,3 @@ BOOL IsServerOS ()
{
- OSVERSIONINFOEXW osVer;
- osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW);
- GetVersionExW ((LPOSVERSIONINFOW) &osVer);
-
- return (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER);
+ return IsWindowsServer()? TRUE : FALSE;
}
@@ -10946,2 +10941,3 @@ BOOL IsServerOS ()
+
// Returns TRUE, if the currently running operating system is installed in a hidden volume. If it's not, or if
@@ -11020,5 +11016,6 @@ std::wstring GetWindowsEdition ()
- OSVERSIONINFOEXW osVer;
+ OSVERSIONINFOEXW osVer = { 0 };
osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW);
- GetVersionExW ((LPOSVERSIONINFOW) &osVer);
+ if (GetWindowsVersion((LPOSVERSIONINFOW)&osVer))
+ {
@@ -11115,2 +11112,7 @@ std::wstring GetWindowsEdition ()
}
+ else
+ {
+ return L"";
+ }
+}
@@ -11126,3 +11128,3 @@ void Applink (const char *dest)
BOOL buildUrl = TRUE;
- int r;
+ INT_PTR r;
@@ -11330,3 +11332,3 @@ void Applink (const char *dest)
{
- r = (int) ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL);
+ r = (INT_PTR) ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL);
@@ -13056,3 +13058,3 @@ void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors)
wchar_t msg[1024], param[1024], cmdPath[MAX_PATH];
- wchar_t driveRoot[] = { L'A' + (wchar_t) driveNo, L':', 0 };
+ wchar_t driveRoot[] = { (wchar_t) (L'A' + driveNo), L':', 0 };
@@ -13302,3 +13304,3 @@ BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath)
wchar_t path[MAX_PATH*2] = { 0 };
- int r;
+ INT_PTR r;
@@ -13309,3 +13311,3 @@ BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath)
- r = (int) ShellExecute (hwnd, L"open", path, (wstring (L"\"") + isoPath + L"\"").c_str(), NULL, SW_SHOWNORMAL);
+ r = (INT_PTR) ShellExecute (hwnd, L"open", path, (wstring (L"\"") + isoPath + L"\"").c_str(), NULL, SW_SHOWNORMAL);
@@ -13313,3 +13315,3 @@ BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath)
{
- SetLastError (r);
+ SetLastError ((DWORD) r);
handleWin32Error (hwnd, SRC_POS);
@@ -15261,3 +15263,3 @@ DWORD PasswordEditDropTarget::GotEnter(void)
TCHAR szClassName[64];
- DWORD dwStyles;
+ DWORD_PTR dwStyles;
int maxLen;
@@ -15287,3 +15289,3 @@ void PasswordEditDropTarget::GotDrop(CLIPFORMAT format)
TCHAR szClassName[64];
- DWORD dwStyles;
+ DWORD_PTR dwStyles;
int maxLen;
diff --git a/src/Common/Format.c b/src/Common/Format.c
index 635a2b09..482a87cd 100644
--- a/src/Common/Format.c
+++ b/src/Common/Format.c
@@ -513,5 +513,5 @@ begin_format:
- LARGE_INTEGER offset;
- offset.QuadPart = TC_VOLUME_DATA_OFFSET;
- if (!SetFilePointerEx ((HANDLE) dev, offset, NULL, FILE_BEGIN))
+ LARGE_INTEGER volDataOffset;
+ volDataOffset.QuadPart = TC_VOLUME_DATA_OFFSET;
+ if (!SetFilePointerEx ((HANDLE) dev, volDataOffset, NULL, FILE_BEGIN))
{
diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c
index 6d9907cd..b21e371d 100644
--- a/src/Common/Keyfiles.c
+++ b/src/Common/Keyfiles.c
@@ -272,3 +272,3 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
- for (size_t i = 0; i < keyfileData.size(); i++)
+ for (i = 0; i < keyfileData.size(); i++)
{
@@ -498,3 +498,3 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
SetTextColor((HDC)wParam, RGB(255,0,0));
- return (BOOL)GetSysColorBrush(COLOR_MENU);
+ return (BOOL)(INT_PTR)GetSysColorBrush(COLOR_MENU);
}
diff --git a/src/Common/Language.c b/src/Common/Language.c
index a6bc9891..11c791d8 100644
--- a/src/Common/Language.c
+++ b/src/Common/Language.c
@@ -344,3 +344,3 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
{
- void *key;
+ void *pkey;
void *text;
@@ -353,4 +353,4 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
{
- key = AddPoolData (attr, strlen (attr) + 1);
- if (key == NULL) return FALSE;
+ pkey = AddPoolData (attr, strlen (attr) + 1);
+ if (pkey == NULL) return FALSE;
@@ -373,3 +373,3 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
if (!bForceSilent)
- MessageBoxA (0, key, "VeraCrypt: Unknown '\\' escape sequence in string", MB_ICONERROR);
+ MessageBoxA (0, pkey, "VeraCrypt: Unknown '\\' escape sequence in string", MB_ICONERROR);
return FALSE;
@@ -388,3 +388,3 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
if (!bForceSilent)
- MessageBoxA (0, key, "VeraCrypt: Error while decoding UTF-8 string", MB_ICONERROR);
+ MessageBoxA (0, pkey, "VeraCrypt: Error while decoding UTF-8 string", MB_ICONERROR);
return FALSE;
@@ -396,3 +396,3 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
- AddDictionaryEntry ((char *) key, 0, text);
+ AddDictionaryEntry ((char *)pkey, 0, text);
}
diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c
index 7b78767e..3e98ed40 100644
--- a/src/Common/Pkcs5.c
+++ b/src/Common/Pkcs5.c
@@ -1225,5 +1225,5 @@ int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL bBoot)
}
-#if _MSC_VER < 1900
+
return 0;
-#endif
+
}
diff --git a/src/Common/Progress.c b/src/Common/Progress.c
index 2619b173..24efcad5 100644
--- a/src/Common/Progress.c
+++ b/src/Common/Progress.c
@@ -38,5 +38,5 @@ void InitProgressBar (__int64 totalBytes, __int64 bytesDone, BOOL bReverse, BOOL
{
- HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
- SendMessage (hProgressBar, PBM_SETRANGE32, 0, 10000);
- SendMessage (hProgressBar, PBM_SETSTEP, 1, 0);
+ HWND hCurProgressBar = GetDlgItem (hCurPage, nPbar);
+ SendMessage (hCurProgressBar, PBM_SETRANGE32, 0, 10000);
+ SendMessage (hCurProgressBar, PBM_SETSTEP, 1, 0);
@@ -68,3 +68,3 @@ BOOL UpdateProgressBarProc (__int64 byteOffset)
wchar_t speed[100];
- HWND hProgressBar = GetDlgItem (hCurPage, nPbar);
+ HWND hCurProgressBar = GetDlgItem (hCurPage, nPbar);
int time = GetTickCount ();
@@ -128,3 +128,3 @@ BOOL UpdateProgressBarProc (__int64 byteOffset)
- SendMessage (hProgressBar, PBM_SETPOS,
+ SendMessage (hCurProgressBar, PBM_SETPOS,
(int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)),
diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp
index 2a8222e6..cd4926a0 100644
--- a/src/Common/SecurityToken.cpp
+++ b/src/Common/SecurityToken.cpp
@@ -222,3 +222,3 @@ namespace VeraCrypt
- foreach(const CK_OBJECT_HANDLE & dataHandle, GetObjects(slotId, CKO_DATA))
+ for(const CK_OBJECT_HANDLE & dataHandle: GetObjects(slotId, CKO_DATA))
{
@@ -350,3 +350,3 @@ namespace VeraCrypt
CK_OBJECT_HANDLE object;
- CK_RV status = Pkcs11Functions->C_FindObjects(Sessions[slotId].Handle, &object, 1, &objectCount);
+ status = Pkcs11Functions->C_FindObjects(Sessions[slotId].Handle, &object, 1, &objectCount);
if (status != CKR_OK)