From 43ad4f93eb2c64bb2c278cdbefdfe0250293868e Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 15 Nov 2024 00:41:07 +0100 Subject: Windows: Fix various compiler warnings --- src/Common/BootEncryption.cpp | 21 ++-- src/Common/Crypto.c | 1 + src/Common/Dlgcode.c | 234 +++++++++++++++++++++--------------------- src/Common/Format.c | 6 +- src/Common/Keyfiles.c | 4 +- src/Common/Language.c | 12 +-- src/Common/Pkcs5.c | 4 +- src/Common/Progress.c | 10 +- src/Common/SecurityToken.cpp | 4 +- src/Crypto/config.h | 2 +- src/ExpandVolume/WinMain.cpp | 13 ++- src/Format/InPlace.c | 6 +- src/Format/Tcformat.c | 75 +++++++------- src/Mount/Favorites.cpp | 10 +- src/Mount/Mount.c | 177 ++++++++++++++++---------------- src/Setup/Setup.c | 7 +- src/SetupDLL/Setup.c | 2 +- 17 files changed, 301 insertions(+), 287 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 @@ -1141,7 +1141,7 @@ namespace VeraCrypt // throw ParameterIncorrect (SRC_POS); // It is assumed that CheckRequirements() had been called // Find the first active partition on the system drive - foreach (const Partition &partition, config.Partitions) + for (const Partition& partition : config.Partitions) { if (partition.Info.BootIndicator) { @@ -1154,13 +1154,13 @@ namespace VeraCrypt Partition bootPartition = partition; Partition partitionBehindBoot; - 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; } } @@ -1351,11 +1351,11 @@ namespace VeraCrypt part.IsGPT = diskPartInfo.IsGPT; // 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":"; } @@ -2441,7 +2441,8 @@ namespace VeraCrypt if (!fieldValue.empty() && strlen (fieldValue.c_str())) { 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(std::tolower(c)); }); if (strstr (copieValue.c_str(), "postexec") && strstr (copieValue.c_str(), "file(")) { 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 @@ -16,6 +16,7 @@ #include "Xts.h" #include "Crc.h" #include "Common/Endian.h" +#include "Crypto/t1ha.h" #if !defined(_UEFI) #include #ifndef TC_WINDOWS_BOOT 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 @@ -14,6 +14,7 @@ #include "Tcdefs.h" #include +#include #include #include #include @@ -1083,9 +1084,6 @@ static BOOL GetWindowsVersion(LPOSVERSIONINFOW lpVersionInformation) bRet = TRUE; } - if (!bRet) - bRet = GetVersionExW (lpVersionInformation); - #ifdef SETUP_DLL // we get real version from Kernel32.dll version since MSI always sets current version to 6.0 // https://stackoverflow.com/questions/49335885/windows-10-not-detecting-on-installshield/49343826#49343826 @@ -3166,7 +3164,7 @@ BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_ StringCbCopyW (newCmdLine, sizeof(newCmdLine), L"/q UAC "); StringCbCatW (newCmdLine, sizeof (newCmdLine), args); - 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) { if (hwndDlg) handleWin32Error (hwndDlg, SRC_POS); @@ -3911,7 +3909,7 @@ void NotifyDriverOfPortableMode (void) 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 }; return GetVolumeInformationW (root, label, labelSize / 2, NULL, NULL, &fileSystemFlags, NULL, 0); } @@ -3941,11 +3939,12 @@ BOOL GetSysDevicePaths (HWND hwndDlg) } // Find extra boot partition - foreach (const HostDevice &drive, GetAvailableHostDevices (false, false)) + std::vector devices = GetAvailableHostDevices(false, false); + for (const HostDevice& drive : devices) { if (drive.ContainsSystem) { - foreach (const HostDevice &sysDrivePartition, drive.Partitions) + for (const HostDevice &sysDrivePartition : drive.Partitions) { if (sysDrivePartition.Bootable) { @@ -5389,7 +5388,7 @@ BOOL SelectMultipleFiles(HWND hwndDlg, const char *stringId, BOOL keepHistory, s return status; } -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) { IFileDialog *pfd = NULL; HRESULT hr; @@ -5414,9 +5413,9 @@ 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)); } IShellItem *psi; @@ -5754,7 +5753,7 @@ BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo) BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue) { 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; LSTATUS lStatus; DWORD cbLabelLen = (DWORD) ((wcslen (effectiveLabel) + 1) * sizeof (wchar_t)); @@ -8256,7 +8255,7 @@ void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap) { if (driveMap & (1 << i)) { - 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); @@ -8813,12 +8812,12 @@ retry: wstring drivePath = L"\\\\.\\X:"; HANDLE dev = INVALID_HANDLE_VALUE; VOLUME_DISK_EXTENTS extents = {0}; - DWORD dwResult = 0; + DWORD cbReturnedBytes = 0; drivePath[4] = root[0]; if ((dev = CreateFile (drivePath.c_str(),0, 0, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) { - 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)) { if (extents.NumberOfDiskExtents > 0) { @@ -8955,18 +8954,18 @@ retry: if (bDevice && mount.bProtectHiddenVolume) { - int driveNo; + int diskNo; - if (swscanf (volumePath, L"\\Device\\Harddisk%d\\Partition", &driveNo) == 1) + if (swscanf (volumePath, L"\\Device\\Harddisk%d\\Partition", &diskNo) == 1) { OPEN_TEST_STRUCT openTestStruct; memset (&openTestStruct, 0, sizeof (openTestStruct)); 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); else handleError (hwndDlg, mount.nReturnCode, SRC_POS); @@ -9005,7 +9004,7 @@ retry: if (mount.FilesystemDirty) { 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); if (AskWarnYesNoStringTopmost (msg, hwndDlg) == IDYES) @@ -9019,7 +9018,7 @@ retry: && !IsFileOnReadOnlyFilesystem (volumePath)) { 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); WarningDirect (msg, hwndDlg); @@ -9030,7 +9029,7 @@ retry: && bDevice) { 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); WarningDirect (msg, hwndDlg); @@ -9041,7 +9040,7 @@ retry: && wcsstr (volumePath, L"\\Device\\Harddisk") == volumePath) { 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); WarningDirect (msg, hwndDlg); @@ -9059,7 +9058,7 @@ retry: && bDevice) { 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); WarningDirect (msg, hwndDlg); @@ -9152,7 +9151,7 @@ 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); return FALSE; @@ -9506,7 +9505,7 @@ int GetDiskDeviceDriveLetter (PWSTR deviceName) for (i = 0; i < 26; i++) { - WCHAR drive[] = { (WCHAR) i + L'A', L':', 0 }; + WCHAR drive[] = { (WCHAR) (i + L'A'), L':', 0 }; StringCchCopyW (link, MAX_PATH, L"\\DosDevices\\"); StringCchCatW (link, MAX_PATH, drive); @@ -10704,12 +10703,12 @@ void OpenPageHelp (HWND hwndDlg, int nPage) } else { - 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); if (r == ERROR_FILE_NOT_FOUND) { // 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); if (r == ERROR_FILE_NOT_FOUND) { @@ -10936,14 +10935,11 @@ BOOL IsARM() 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; } + // Returns TRUE, if the currently running operating system is installed in a hidden volume. If it's not, or if // there's an error, returns FALSE. BOOL IsHiddenOSRunning (void) @@ -11018,100 +11014,106 @@ std::wstring GetWindowsEdition () { wstring osname = L"win"; - OSVERSIONINFOEXW osVer; + OSVERSIONINFOEXW osVer = { 0 }; osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW); - GetVersionExW ((LPOSVERSIONINFOW) &osVer); + if (GetWindowsVersion((LPOSVERSIONINFOW)&osVer)) + { - BOOL home = (osVer.wSuiteMask & VER_SUITE_PERSONAL); - BOOL server = (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER); + BOOL home = (osVer.wSuiteMask & VER_SUITE_PERSONAL); + BOOL server = (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER); - HKEY hkey; - wchar_t productName[300] = {0}; - DWORD productNameSize = sizeof (productName); - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) - { - if (RegQueryValueEx (hkey, L"ProductName", 0, 0, (LPBYTE) &productName, &productNameSize) != ERROR_SUCCESS || productNameSize < 1) - productName[0] = 0; + HKEY hkey; + wchar_t productName[300] = { 0 }; + DWORD productNameSize = sizeof(productName); + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) + { + if (RegQueryValueEx(hkey, L"ProductName", 0, 0, (LPBYTE)&productName, &productNameSize) != ERROR_SUCCESS || productNameSize < 1) + productName[0] = 0; - RegCloseKey (hkey); - } + RegCloseKey(hkey); + } - switch (nCurrentOS) - { - case WIN_2000: - osname += L"2000"; - break; + switch (nCurrentOS) + { + case WIN_2000: + osname += L"2000"; + break; - case WIN_XP: - case WIN_XP64: - osname += L"xp"; - osname += home ? L"-home" : L"-pro"; - break; + case WIN_XP: + case WIN_XP64: + osname += L"xp"; + osname += home ? L"-home" : L"-pro"; + break; - case WIN_SERVER_2003: - osname += L"2003"; - break; + case WIN_SERVER_2003: + osname += L"2003"; + break; - case WIN_VISTA: - osname += L"vista"; - break; + case WIN_VISTA: + osname += L"vista"; + break; - case WIN_SERVER_2008: - osname += L"2008"; - break; + case WIN_SERVER_2008: + osname += L"2008"; + break; - case WIN_7: - osname += L"7"; - break; + case WIN_7: + osname += L"7"; + break; - case WIN_SERVER_2008_R2: - osname += L"2008r2"; - break; + case WIN_SERVER_2008_R2: + osname += L"2008r2"; + break; - default: - wstringstream s; - s << CurrentOSMajor << L"." << CurrentOSMinor; - osname += s.str(); - break; - } + default: + wstringstream s; + s << CurrentOSMajor << L"." << CurrentOSMinor; + osname += s.str(); + break; + } - if (server) - osname += L"-server"; + if (server) + osname += L"-server"; - if (IsOSAtLeast (WIN_VISTA)) - { - if (home) - osname += L"-home"; - else if (wcsstr (productName, L"Standard") != 0) - osname += L"-standard"; - else if (wcsstr (productName, L"Professional") != 0) - osname += L"-pro"; - else if (wcsstr (productName, L"Business") != 0) - osname += L"-business"; - else if (wcsstr (productName, L"Enterprise") != 0) - osname += L"-enterprise"; - else if (wcsstr (productName, L"Datacenter") != 0) - osname += L"-datacenter"; - else if (wcsstr (productName, L"Ultimate") != 0) - osname += L"-ultimate"; - } + if (IsOSAtLeast(WIN_VISTA)) + { + if (home) + osname += L"-home"; + else if (wcsstr(productName, L"Standard") != 0) + osname += L"-standard"; + else if (wcsstr(productName, L"Professional") != 0) + osname += L"-pro"; + else if (wcsstr(productName, L"Business") != 0) + osname += L"-business"; + else if (wcsstr(productName, L"Enterprise") != 0) + osname += L"-enterprise"; + else if (wcsstr(productName, L"Datacenter") != 0) + osname += L"-datacenter"; + else if (wcsstr(productName, L"Ultimate") != 0) + osname += L"-ultimate"; + } - if (GetSystemMetrics (SM_STARTER)) - osname += L"-starter"; - else if (wcsstr (productName, L"Basic") != 0) - osname += L"-basic"; + if (GetSystemMetrics(SM_STARTER)) + osname += L"-starter"; + else if (wcsstr(productName, L"Basic") != 0) + osname += L"-basic"; - if (Is64BitOs()) - osname += IsARM()? L"-arm64" : L"-x64"; + if (Is64BitOs()) + osname += IsARM() ? L"-arm64" : L"-x64"; - if (CurrentOSServicePack > 0) + if (CurrentOSServicePack > 0) + { + wstringstream s; + s << L"-sp" << CurrentOSServicePack; + osname += s.str(); + } + + return osname; + } + else { - wstringstream s; - s << L"-sp" << CurrentOSServicePack; - osname += s.str(); + return L""; } - - return osname; } #ifdef SETUP @@ -11124,7 +11126,7 @@ void Applink (const char *dest) wchar_t page[TC_MAX_PATH] = {0}; wchar_t installDir[TC_MAX_PATH] = {0}; BOOL buildUrl = TRUE; - int r; + INT_PTR r; ArrowWaitCursor (); @@ -11328,7 +11330,7 @@ void Applink (const char *dest) } else { - r = (int) ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL); + r = (INT_PTR) ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL); if (((r == ERROR_FILE_NOT_FOUND) || (r == ERROR_PATH_NOT_FOUND)) && buildUrl) { @@ -13054,7 +13056,7 @@ BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path) 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 }; if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP", hwndDlg) == IDNO) return; @@ -13300,18 +13302,18 @@ BOOL IsWindowsIsoBurnerAvailable () BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath) { wchar_t path[MAX_PATH*2] = { 0 }; - int r; + INT_PTR r; if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_SYSTEM, NULL, 0, path))) StringCbCatW (path, MAX_PATH*2, L"\\" ISO_BURNER_TOOL); else StringCbCopyW (path, MAX_PATH*2, L"C:\\Windows\\System32\\" ISO_BURNER_TOOL); - 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); if (r <= 32) { - SetLastError (r); + SetLastError ((DWORD) r); handleWin32Error (hwnd, SRC_POS); return FALSE; @@ -15259,7 +15261,7 @@ void PasswordEditDropTarget::GotLeave(void) DWORD PasswordEditDropTarget::GotEnter(void) { TCHAR szClassName[64]; - DWORD dwStyles; + DWORD_PTR dwStyles; int maxLen; HWND hChild = WindowFromPoint (m_DropPoint); // check that we are on password edit control (we use maximum length to correctly identify password fields since they don't always have ES_PASSWORD style (if the the user checked show password) @@ -15285,7 +15287,7 @@ void PasswordEditDropTarget::GotDrop(CLIPFORMAT format) if(m_Data) { TCHAR szClassName[64]; - DWORD dwStyles; + DWORD_PTR dwStyles; int maxLen; HWND hChild = WindowFromPoint (m_DropPoint); if (hChild && GetClassName (hChild, szClassName, ARRAYSIZE (szClassName)) && (0 == _tcsicmp (szClassName, _T("EDIT"))) 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 @@ -511,9 +511,9 @@ begin_format: // The previous file system format failed and the user wants to try again with a different file system. // The volume header had been written successfully so we need to seek to the byte after the header. - 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)) { nStatus = ERR_OS_ERROR; goto error; 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 @@ -270,7 +270,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con unsigned __int32 writePos = 0; size_t totalRead = 0; - for (size_t i = 0; i < keyfileData.size(); i++) + for (i = 0; i < keyfileData.size(); i++) { crc = UPDC32 (keyfileData[i], crc); @@ -496,7 +496,7 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa // set the text colour in (HDC)wParam SetBkMode((HDC)wParam,TRANSPARENT); SetTextColor((HDC)wParam, RGB(255,0,0)); - return (BOOL)GetSysColorBrush(COLOR_MENU); + return (BOOL)(INT_PTR)GetSysColorBrush(COLOR_MENU); } } return 0; 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 @@ -342,7 +342,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B xml = (char *) res; while (xml = XmlFindElement (xml, xmlElements[i])) { - void *key; + void *pkey; void *text; XmlGetAttributeText (xml, "lang", attr, sizeof (attr)); @@ -351,8 +351,8 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B { if (XmlGetAttributeText (xml, "key", attr, sizeof (attr))) { - key = AddPoolData (attr, strlen (attr) + 1); - if (key == NULL) return FALSE; + pkey = AddPoolData (attr, strlen (attr) + 1); + if (pkey == NULL) return FALSE; XmlGetNodeText (xml, attr, sizeof (attr)); @@ -371,7 +371,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B case 'n': *out++ = 13; *out++ = 10; break; default: 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; } } @@ -386,7 +386,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B if (len == 0) { 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; } @@ -394,7 +394,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B text = AddPoolData ((void *) wattr, len * 2); if (text == NULL) return FALSE; - 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 @@ -1223,9 +1223,9 @@ int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL bBoot) default: TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID } -#if _MSC_VER < 1900 + return 0; -#endif + } int is_pkcs5_prf_supported (int pkcs5_prf_id, PRF_BOOT_TYPE bootType) 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 @@ -36,9 +36,9 @@ static wchar_t *seconds, *minutes, *hours, *days; // the speed of the "transform cursor"). void InitProgressBar (__int64 totalBytes, __int64 bytesDone, BOOL bReverse, BOOL bIOThroughput, BOOL bDisplayStatus, BOOL bShowPercent) { - 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); bProgressBarReverse = bReverse; bRWThroughput = bIOThroughput; @@ -66,7 +66,7 @@ BOOL UpdateProgressBarProc (__int64 byteOffset) { wchar_t text[100]; wchar_t speed[100]; - HWND hProgressBar = GetDlgItem (hCurPage, nPbar); + HWND hCurProgressBar = GetDlgItem (hCurPage, nPbar); int time = GetTickCount (); int elapsed = (time - startTime) / 1000; @@ -126,7 +126,7 @@ BOOL UpdateProgressBarProc (__int64 byteOffset) prevTime = time; - SendMessage (hProgressBar, PBM_SETPOS, + SendMessage (hCurProgressBar, PBM_SETPOS, (int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)), 0); 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 @@ -220,7 +220,7 @@ namespace VeraCrypt throw; } - foreach(const CK_OBJECT_HANDLE & dataHandle, GetObjects(slotId, CKO_DATA)) + for(const CK_OBJECT_HANDLE & dataHandle: GetObjects(slotId, CKO_DATA)) { SecurityTokenKeyfile keyfile; keyfile.Handle = dataHandle; @@ -348,7 +348,7 @@ namespace VeraCrypt while (true) { 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) throw Pkcs11Exception(status); diff --git a/src/Crypto/config.h b/src/Crypto/config.h index 774f7951..1c2aff72 100644 --- a/src/Crypto/config.h +++ b/src/Crypto/config.h @@ -51,7 +51,7 @@ #endif #ifndef CRYPTOPP_ALIGN_DATA - #if defined(_MSC_VER) + #if defined(_MSC_VER) && !defined(TC_WINDOWS_BOOT) #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x)) #elif defined(__GNUC__) #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x))) diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp index 9a822153..37cd11c8 100644 --- a/src/ExpandVolume/WinMain.cpp +++ b/src/ExpandVolume/WinMain.cpp @@ -131,7 +131,7 @@ MountOptions defaultMountOptions; KeyFile *FirstCmdKeyFile; HBITMAP hbmLogoBitmapRescaled = NULL; -wchar_t OrigKeyboardLayout [8+1] = L"00000409"; +wchar_t OrigKeyboardLayout [KL_NAMELENGTH] = L"00000409"; BOOL bKeyboardLayoutChanged = FALSE; /* TRUE if the keyboard layout was changed to the standard US keyboard layout (from any other layout). */ BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informed that it is not possible to type characters by pressing keys while the right Alt key is held down. */ @@ -552,9 +552,12 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp); SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); - StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout),L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF); + if (!GetKeyboardLayoutNameW(OrigKeyboardLayout)) + { + StringCbPrintfW(OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD) (DWORD_PTR) GetKeyboardLayout(NULL) & 0xFFFF); + } - DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + DWORD keybLayout = (DWORD) (DWORD_PTR) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -594,7 +597,7 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case TIMER_ID_KEYB_LAYOUT_GUARD: if (bPrebootPasswordDlgMode) { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + DWORD keybLayout = (DWORD) (DWORD_PTR) GetKeyboardLayout (NULL); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -607,7 +610,7 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp); SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + keybLayout = (DWORD) (DWORD_PTR) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c index 2a5dc6a3..60c6bbbd 100644 --- a/src/Format/InPlace.c +++ b/src/Format/InPlace.c @@ -997,10 +997,10 @@ inplace_enc_read: { if (!WipeBuffer (wipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, workChunkSize)) { - ULONG i; - for (i = 0; i < workChunkSize; ++i) + ULONG index; + for (index = 0; index < workChunkSize; ++index) { - wipeBuffer[i] = buf[i] + wipePass; + wipeBuffer[index] = buf[index] + wipePass; } EncryptDataUnits (wipeBuffer, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 658d3797..dd7ff18b 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -220,7 +220,7 @@ volatile HWND hVerifyPasswordInputField = NULL; /* Verify-password input field HBITMAP hbmWizardBitmapRescaled = NULL; -wchar_t OrigKeyboardLayout [8+1] = L"00000409"; +wchar_t OrigKeyboardLayout [KL_NAMELENGTH] = L"00000409"; BOOL bKeyboardLayoutChanged = FALSE; /* TRUE if the keyboard layout was changed to the standard US keyboard layout (from any other layout). */ BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informed that it is not possible to type characters by pressing keys while the right Alt key is held down. */ @@ -401,7 +401,7 @@ static BOOL ElevateWholeWizardProcess (wstring arguments) while (true) { - if ((int)ShellExecute (MainDlg, L"runas", modPath, (wstring(L"/q UAC ") + arguments).c_str(), NULL, SW_SHOWNORMAL) > 32) + if ((intptr_t)ShellExecute (MainDlg, L"runas", modPath, (wstring(L"/q UAC ") + arguments).c_str(), NULL, SW_SHOWNORMAL) > 32) { exit (0); } @@ -3187,21 +3187,21 @@ static void LoadPage (HWND hwndDlg, int nPageNo) __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDiskFree) { char *nResourceString; - __int64 nMultiplier; + __int64 nPrintMultiplier; wchar_t szTmp2[256]; if (lDiskFree->QuadPart < BYTES_PER_KB) - nMultiplier = 1; + nPrintMultiplier = 1; else if (lDiskFree->QuadPart < BYTES_PER_MB) - nMultiplier = BYTES_PER_KB; + nPrintMultiplier = BYTES_PER_KB; else if (lDiskFree->QuadPart < BYTES_PER_GB) - nMultiplier = BYTES_PER_MB; + nPrintMultiplier = BYTES_PER_MB; else if (lDiskFree->QuadPart < BYTES_PER_TB) - nMultiplier = BYTES_PER_GB; + nPrintMultiplier = BYTES_PER_GB; else - nMultiplier = BYTES_PER_TB; + nPrintMultiplier = BYTES_PER_TB; - if (nMultiplier == 1) + if (nPrintMultiplier == 1) { if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume nResourceString = "MAX_HIDVOL_SIZE_BYTES"; @@ -3210,7 +3210,7 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi else nResourceString = "DISK_FREE_BYTES"; } - else if (nMultiplier == BYTES_PER_KB) + else if (nPrintMultiplier == BYTES_PER_KB) { if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume nResourceString = "MAX_HIDVOL_SIZE_KB"; @@ -3219,7 +3219,7 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi else nResourceString = "DISK_FREE_KB"; } - else if (nMultiplier == BYTES_PER_MB) + else if (nPrintMultiplier == BYTES_PER_MB) { if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume nResourceString = "MAX_HIDVOL_SIZE_MB"; @@ -3228,7 +3228,7 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi else nResourceString = "DISK_FREE_MB"; } - else if (nMultiplier == BYTES_PER_GB) + else if (nPrintMultiplier == BYTES_PER_GB) { if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume nResourceString = "MAX_HIDVOL_SIZE_GB"; @@ -3249,20 +3249,20 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume { - StringCbPrintfW (szTmp2, sizeof szTmp2, GetString (nResourceString), ((double) lDiskFree->QuadPart) / nMultiplier); + StringCbPrintfW (szTmp2, sizeof szTmp2, GetString (nResourceString), ((double) lDiskFree->QuadPart) / nPrintMultiplier); SetWindowTextW (GetDlgItem (hwndTextBox, IDC_SIZEBOX), szTmp2); } else if (lpszDrive) - StringCbPrintfW (szTmp2, sizeof szTmp2, GetString (nResourceString), lpszDrive, ((double) lDiskFree->QuadPart) / nMultiplier); + StringCbPrintfW (szTmp2, sizeof szTmp2, GetString (nResourceString), lpszDrive, ((double) lDiskFree->QuadPart) / nPrintMultiplier); else szTmp2 [0] = 0; SetWindowTextW (hwndTextBox, szTmp2); if (lDiskFree->QuadPart % (__int64) BYTES_PER_MB != 0) - nMultiplier = BYTES_PER_KB; + nPrintMultiplier = BYTES_PER_KB; - return nMultiplier; + return nPrintMultiplier; } void DisplaySizingErrorText (HWND hwndTextBox) @@ -3662,7 +3662,7 @@ void HandleOldAssignedDriveLetter (void) && !bHiddenOS && driveLetter >= 0) { - wchar_t rootPath[] = { (wchar_t) driveLetter + L'A', L':', L'\\', 0 }; + wchar_t rootPath[] = { (wchar_t) (driveLetter + L'A'), L':', L'\\', 0 }; wchar_t szTmp[8192]; StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("AFTER_FORMAT_DRIVE_LETTER_WARN"), rootPath[0], rootPath[0], rootPath[0], rootPath[0]); @@ -4386,11 +4386,14 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa ToBootPwdField (hwndDlg, IDC_PASSWORD); ToBootPwdField (hwndDlg, IDC_VERIFY); - StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF); + if (!GetKeyboardLayoutNameW(OrigKeyboardLayout)) + { + StringCbPrintfW(OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD)(DWORD_PTR)GetKeyboardLayout(NULL) & 0xFFFF); + } - if ((DWORD) GetKeyboardLayout (NULL) != 0x00000409 && (DWORD) GetKeyboardLayout (NULL) != 0x04090409) + if ((DWORD)(DWORD_PTR)GetKeyboardLayout (NULL) != 0x00000409 && (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL) != 0x04090409) { - DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + DWORD keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -5319,7 +5322,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetBkMode((HDC)wParam,TRANSPARENT); SetTextColor((HDC)wParam, RGB(255,0,0)); // NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle. - return (BOOL)GetSysColorBrush(COLOR_MENU); + return (BOOL) (INT_PTR)GetSysColorBrush(COLOR_MENU); } } return 0; @@ -6698,7 +6701,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case TIMER_ID_KEYB_LAYOUT_GUARD: if (SysEncInEffect ()) { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + DWORD keybLayout = (DWORD)(DWORD_PTR) GetKeyboardLayout (NULL); /* Watch the keyboard layout */ @@ -6711,7 +6714,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetPassword (hCurPage, IDC_PASSWORD, szRawPassword); SetPassword (hCurPage, IDC_VERIFY, szVerify); - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -9700,7 +9703,7 @@ int DetermineMaxHiddenVolSize (HWND hwndDlg) // Tests whether the file system of the given volume is suitable to host a hidden volume, // retrieves the cluster size, and scans the volume cluster bitmap. In addition, checks // the TrueCrypt volume format version and the type of volume. -int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *pnbrFreeClusters) +int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *pRealClusterSize, __int64 *pnbrFreeClusters) { HANDLE hDevice; DWORD bytesReturned; @@ -9708,8 +9711,8 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi DWORD dwResult; int result; wchar_t szFileSystemNameBuffer[256]; - wchar_t tmpPath[7] = {L'\\',L'\\',L'.',L'\\',(wchar_t) *driveNo + L'A',L':',0}; - wchar_t szRootPathName[4] = {(wchar_t) *driveNo + L'A', L':', L'\\', 0}; + wchar_t tmpPath[7] = {L'\\',L'\\',L'.',L'\\',(wchar_t) (*driveNo + L'A'),L':',0}; + wchar_t szRootPathName[4] = {(wchar_t) (*driveNo + L'A'), L':', L'\\', 0}; BYTE readBuffer[TC_MAX_VOLUME_SECTOR_SIZE * 2]; LARGE_INTEGER offset, offsetNew; VOLUME_PROPERTIES_STRUCT volProp; @@ -9784,17 +9787,17 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi // FAT12/FAT16/FAT32 // Retrieve the cluster size - *realClusterSize = ((int) readBuffer[0xb] + ((int) readBuffer[0xc] << 8)) * (int) readBuffer[0xd]; + *pRealClusterSize = ((int) readBuffer[0xb] + ((int) readBuffer[0xc] << 8)) * (int) readBuffer[0xd]; // Get the map of the clusters that are free and in use on the outer volume. // The map will be scanned to determine the size of the uninterrupted block of free // space (provided there is any) whose end is aligned with the end of the volume. // The value will then be used to determine the maximum possible size of the hidden volume. - if (*realClusterSize > 0) + if (*pRealClusterSize > 0) { return ScanVolClusterBitmap (hwndDlg, driveNo, - hiddenVolHostSize / *realClusterSize, + hiddenVolHostSize / *pRealClusterSize, pnbrFreeClusters); } else @@ -9822,7 +9825,7 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi return -1; }; - *realClusterSize = dwBytesPerSector * dwSectorsPerCluster; + *pRealClusterSize = dwBytesPerSector * dwSectorsPerCluster; // Get the map of the clusters that are free and in use on the outer volume. // The map will be scanned to determine the size of the uninterrupted block of free @@ -9831,7 +9834,7 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi return ScanVolClusterBitmap (hwndDlg, driveNo, - hiddenVolHostSize / *realClusterSize, + hiddenVolHostSize / *pRealClusterSize, pnbrFreeClusters); } else @@ -9887,7 +9890,7 @@ int MountHiddenVolHost (HWND hwndDlg, wchar_t *volumePath, int *driveNo, Passwor area of free space (provided there is any) whose end is aligned with the end of the volume. The value will then be used to determine the maximum possible size of the hidden volume. */ -int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int64 *nbrFreeClusters) +int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int64 *pnbrFreeClusters) { PVOLUME_BITMAP_BUFFER lpOutBuffer; STARTING_LCN_INPUT_BUFFER lpInBuffer; @@ -9895,7 +9898,7 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int HANDLE hDevice; DWORD lBytesReturned; BYTE rmnd; - wchar_t tmpPath[7] = {L'\\',L'\\',L'.',L'\\', (wchar_t) *driveNo + L'A', L':', 0}; + wchar_t tmpPath[7] = {L'\\',L'\\',L'.',L'\\', (wchar_t) (*driveNo + L'A'), L':', 0}; DWORD bufLen; __int64 bitmapCnt; @@ -9941,11 +9944,11 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int if ((rmnd != 0) && ((lpOutBuffer->Buffer[lpOutBuffer->BitmapSize.QuadPart / 8] & ((1 << rmnd)-1) ) != 0)) { - *nbrFreeClusters = 0; + *pnbrFreeClusters = 0; } else { - *nbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart; + *pnbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart; bitmapCnt = lpOutBuffer->BitmapSize.QuadPart / 8; // Scan the bitmap from the end @@ -9955,7 +9958,7 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int { // There might be up to 7 extra free clusters in this byte of the bitmap. // These are ignored because there is always a cluster reserve added anyway. - *nbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart - ((bitmapCnt + 1) * 8); + *pnbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart - ((bitmapCnt + 1) * 8); break; } } diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp index de4d5a08..c829128f 100644 --- a/src/Mount/Favorites.cpp +++ b/src/Mount/Favorites.cpp @@ -452,13 +452,13 @@ namespace VeraCrypt case WM_CTLCOLORSTATIC: { HDC hdc = (HDC) wParam; - HWND hw = (HWND) lParam; - if (hw == GetDlgItem(hwndDlg, IDC_FAVORITE_VOLUME_ID)) + HWND hwnd = (HWND) lParam; + if (hwnd == GetDlgItem(hwndDlg, IDC_FAVORITE_VOLUME_ID)) { // This the favorite ID field. Make its background like normal edit HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW); ::SelectObject(hdc, hbr); - return (BOOL) hbr; + return (BOOL)(INT_PTR)hbr; } } break; @@ -731,7 +731,7 @@ namespace VeraCrypt FavoritesOnArrivalMountRequired.clear(); - foreach (const FavoriteVolume favorite, FavoriteVolumes) + for (const FavoriteVolume favorite: FavoriteVolumes) { if (favorite.MountOnArrival) { @@ -741,7 +741,7 @@ namespace VeraCrypt { bool present = false; - foreach (const FavoriteVolume favoriteConnected, FavoritesMountedOnArrivalStillConnected) + for (const FavoriteVolume favoriteConnected: FavoritesMountedOnArrivalStillConnected) { if (favorite.Path == favoriteConnected.Path) { diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 6ae6e417..09f43b88 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -175,7 +175,7 @@ MountOptions defaultMountOptions; KeyFile *FirstCmdKeyFile = NULL; HBITMAP hbmLogoBitmapRescaled = NULL; -wchar_t OrigKeyboardLayout [8+1] = L"00000409"; +wchar_t OrigKeyboardLayout [KL_NAMELENGTH] = L"00000409"; BOOL bKeyboardLayoutChanged = FALSE; /* TRUE if the keyboard layout was changed to the standard US keyboard layout (from any other layout). */ BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informed that it is not possible to type characters by pressing keys while the right Alt key is held down. */ @@ -1720,7 +1720,7 @@ static void LaunchVolExpander (HWND hwndDlg) if (!FileExists(t)) Error ("VOL_EXPANDER_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do - else if (((int)ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", t, NULL, NULL, SW_SHOW)) <= 32) + else if (((INT_PTR)ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", t, NULL, NULL, SW_SHOW)) <= 32) { handleWin32Error (hwndDlg, SRC_POS); } @@ -2045,12 +2045,12 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive) { if (!VolumeNotificationsList.bHidVolDamagePrevReported[i]) { - wchar_t szTmp[4096]; + wchar_t szMsgTmp[4096]; VolumeNotificationsList.bHidVolDamagePrevReported[i] = TRUE; - StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), i+L'A'); + StringCbPrintfW (szMsgTmp, sizeof(szMsgTmp), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), i+L'A'); SetForegroundWindow (GetParent(hTree)); - MessageBoxW (GetParent(hTree), szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); + MessageBoxW (GetParent(hTree), szMsgTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); } } else @@ -2439,9 +2439,9 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR ToBootPwdField (hwndDlg, IDC_VERIFY); ToBootPwdField (hwndDlg, IDC_OLD_PASSWORD); - if ((DWORD) GetKeyboardLayout (NULL) != 0x00000409 && (DWORD) GetKeyboardLayout (NULL) != 0x04090409) + if ((DWORD)(DWORD_PTR)GetKeyboardLayout (NULL) != 0x00000409 && (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL) != 0x04090409) { - DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + DWORD keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -2496,7 +2496,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR case TIMER_ID_KEYB_LAYOUT_GUARD: if (bSysEncPwdChangeDlgMode) { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + DWORD keybLayout = (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL); /* Watch the keyboard layout */ @@ -2516,7 +2516,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); SetWindowText (GetDlgItem (hwndDlg, IDC_VERIFY), L""); - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -2565,7 +2565,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetBkMode((HDC)wParam,TRANSPARENT); SetTextColor((HDC)wParam, RGB(255,0,0)); // NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle. - return (BOOL)GetSysColorBrush(COLOR_MENU); + return (BOOL)(INT_PTR)GetSysColorBrush(COLOR_MENU); } } return 0; @@ -2751,7 +2751,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR if (new_hash_algo_id != 0 && !bSystemIsGPT && !HashForSystemEncryption(new_hash_algo_id)) { - int new_hash_algo_id = DEFAULT_HASH_ALGORITHM_BOOT; + new_hash_algo_id = DEFAULT_HASH_ALGORITHM_BOOT; Info ("ALGO_NOT_SUPPORTED_FOR_SYS_ENCRYPTION", hwndDlg); SelectAlgo (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), &new_hash_algo_id); } @@ -3115,9 +3115,12 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp); SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); - StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout),L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF); + if (!GetKeyboardLayoutNameW(OrigKeyboardLayout)) + { + StringCbPrintfW(OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD)(DWORD_PTR)GetKeyboardLayout(NULL) & 0xFFFF); + } - DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + DWORD keybLayout = (DWORD) (DWORD_PTR) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -3173,7 +3176,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa case TIMER_ID_KEYB_LAYOUT_GUARD: if (bPrebootPasswordDlgMode) { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + DWORD keybLayout = (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -3186,7 +3189,7 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp); SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + keybLayout = (DWORD)(DWORD_PTR) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); if (keybLayout != 0x00000409 && keybLayout != 0x04090409) { @@ -3639,7 +3642,7 @@ BOOL CALLBACK PreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { - static MountOptions *mountOptions; + static MountOptions *pMountOptions; WORD lw = LOWORD (wParam); @@ -3649,31 +3652,31 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM { BOOL protect; - mountOptions = (MountOptions *) lParam; + pMountOptions = (MountOptions *) lParam; LocalizeDialog (hwndDlg, "IDD_MOUNT_OPTIONS"); SendDlgItemMessage (hwndDlg, IDC_MOUNT_READONLY, BM_SETCHECK, - mountOptions->ReadOnly ? BST_CHECKED : BST_UNCHECKED, 0); + pMountOptions->ReadOnly ? BST_CHECKED : BST_UNCHECKED, 0); SendDlgItemMessage (hwndDlg, IDC_MOUNT_REMOVABLE, BM_SETCHECK, - mountOptions->Removable ? BST_CHECKED : BST_UNCHECKED, 0); + pMountOptions->Removable ? BST_CHECKED : BST_UNCHECKED, 0); SendDlgItemMessage (hwndDlg, IDC_DISABLE_MOUNT_MANAGER, BM_SETCHECK, - mountOptions->DisableMountManager ? BST_CHECKED : BST_UNCHECKED, 0); + pMountOptions->DisableMountManager ? BST_CHECKED : BST_UNCHECKED, 0); SendDlgItemMessage (hwndDlg, IDC_PROTECT_HIDDEN_VOL, BM_SETCHECK, - mountOptions->ProtectHiddenVolume ? BST_CHECKED : BST_UNCHECKED, 0); + pMountOptions->ProtectHiddenVolume ? BST_CHECKED : BST_UNCHECKED, 0); - mountOptions->PartitionInInactiveSysEncScope = bPrebootPasswordDlgMode; + pMountOptions->PartitionInInactiveSysEncScope = bPrebootPasswordDlgMode; SendDlgItemMessage (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA, BM_SETCHECK, bPrebootPasswordDlgMode ? BST_CHECKED : BST_UNCHECKED, 0); SendDlgItemMessage (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK, BM_SETCHECK, - mountOptions->UseBackupHeader ? BST_CHECKED : BST_UNCHECKED, 0); + pMountOptions->UseBackupHeader ? BST_CHECKED : BST_UNCHECKED, 0); EnableWindow (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA), !bPrebootPasswordDlgMode); - SetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, mountOptions->Label); + SetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, pMountOptions->Label); SendDlgItemMessage (hwndDlg, IDC_VOLUME_LABEL, EM_LIMITTEXT, 32, 0); // 32 is the maximum possible length for a drive label in Windows protect = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER)); @@ -3692,7 +3695,7 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM nIndex = (int) SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i)); SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i); /* if a PRF was selected previously, select it */ - if (i == mountOptions->ProtectedHidVolPkcs5Prf) + if (i == pMountOptions->ProtectedHidVolPkcs5Prf) nSelectedIndex = nIndex; } @@ -3719,19 +3722,19 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ToNormalPwdField (hwndDlg, IDC_PASSWORD_PROT_HIDVOL); SendDlgItemMessage (hwndDlg, IDC_PIM, EM_LIMITTEXT, MAX_PIM, 0); - if (mountOptions->ProtectedHidVolPassword.Length > 0) + if (pMountOptions->ProtectedHidVolPassword.Length > 0) { wchar_t szTmp[MAX_PASSWORD + 1]; - if (0 == MultiByteToWideChar (CP_UTF8, 0, (LPSTR) mountOptions->ProtectedHidVolPassword.Text, -1, szTmp, MAX_PASSWORD + 1)) + if (0 == MultiByteToWideChar (CP_UTF8, 0, (LPSTR) pMountOptions->ProtectedHidVolPassword.Text, -1, szTmp, MAX_PASSWORD + 1)) szTmp [0] = 0; SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), szTmp); burn (szTmp, sizeof (szTmp)); } - SetPim (hwndDlg, IDC_PIM, mountOptions->ProtectedHidVolPim); + SetPim (hwndDlg, IDC_PIM, pMountOptions->ProtectedHidVolPim); /* make PIM field visible if a PIM value has been explicitely specified */ - if (mountOptions->ProtectedHidVolPim > 0) + if (pMountOptions->ProtectedHidVolPim > 0) { SetCheckBox (hwndDlg, IDC_PIM_ENABLE, TRUE); ShowWindow (GetDlgItem (hwndDlg, IDC_PIM_ENABLE), SW_HIDE); @@ -3835,28 +3838,28 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM { wchar_t tmp[MAX_PASSWORD+1]; - mountOptions->ReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)); - mountOptions->Removable = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_REMOVABLE)); - mountOptions->DisableMountManager = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER)); - mountOptions->ProtectHiddenVolume = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL)); - mountOptions->PartitionInInactiveSysEncScope = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA)); - mountOptions->UseBackupHeader = IsButtonChecked (GetDlgItem (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK)); + pMountOptions->ReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)); + pMountOptions->Removable = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_REMOVABLE)); + pMountOptions->DisableMountManager = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER)); + pMountOptions->ProtectHiddenVolume = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL)); + pMountOptions->PartitionInInactiveSysEncScope = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA)); + pMountOptions->UseBackupHeader = IsButtonChecked (GetDlgItem (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK)); - GetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, mountOptions->Label, sizeof (mountOptions->Label) /sizeof (wchar_t)); + GetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, pMountOptions->Label, sizeof (pMountOptions->Label) /sizeof (wchar_t)); - if (mountOptions->ProtectHiddenVolume) + if (pMountOptions->ProtectHiddenVolume) { int iMaxPasswordLength = bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD : MAX_PASSWORD; GetPassword (hwndDlg, IDC_PASSWORD_PROT_HIDVOL, - (LPSTR) mountOptions->ProtectedHidVolPassword.Text, iMaxPasswordLength + 1, + (LPSTR) pMountOptions->ProtectedHidVolPassword.Text, iMaxPasswordLength + 1, FALSE, FALSE); - mountOptions->ProtectedHidVolPassword.Length = (unsigned __int32) strlen ((char *) mountOptions->ProtectedHidVolPassword.Text); + pMountOptions->ProtectedHidVolPassword.Length = (unsigned __int32) strlen ((char *) pMountOptions->ProtectedHidVolPassword.Text); - mountOptions->ProtectedHidVolPkcs5Prf = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, + pMountOptions->ProtectedHidVolPkcs5Prf = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0); - mountOptions->ProtectedHidVolPim = GetPim (hwndDlg, IDC_PIM, 0); + pMountOptions->ProtectedHidVolPim = GetPim (hwndDlg, IDC_PIM, 0); } // Cleanup @@ -3864,7 +3867,7 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM tmp[MAX_PASSWORD] = 0; SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp); - if ((mountOptions->ProtectHiddenVolume && !bEnableBkgTask) + if ((pMountOptions->ProtectHiddenVolume && !bEnableBkgTask) && (AskWarnYesNo ("HIDVOL_PROT_BKG_TASK_WARNING", hwndDlg) == IDYES)) { bEnableBkgTask = TRUE; @@ -4479,7 +4482,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa // This the directory field. Make its background like normal edit HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW); ::SelectObject(hdc, hbr); - return (BOOL) hbr; + return (BOOL)(INT_PTR)hbr; } } return 0; @@ -4545,7 +4548,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa if (lw == IDC_CREATE) { - BOOL copyWizard, copyExpander, bExplore, bCacheInDriver, bIncludePimInCache, bAutoRun, bAutoMount, bMountReadOnly; + BOOL copyWizard, copyExpander, openExplorer, cacheInDriver, includePimInCache, bAutoRun, bAutoMount, bMountReadOnly; WCHAR dstDir[MAX_PATH + 1]; WCHAR srcPath[1024 + MAX_PATH + 1]; WCHAR dstPath[2*MAX_PATH + 1]; @@ -4563,9 +4566,9 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa copyWizard = IsButtonChecked (GetDlgItem (hwndDlg, IDC_COPY_WIZARD)); copyExpander = IsButtonChecked (GetDlgItem (hwndDlg, IDC_COPY_EXPANDER)); - bExplore = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAVEL_OPEN_EXPLORER)); - bCacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAV_CACHE_PASSWORDS)); - bIncludePimInCache = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PIM)); + openExplorer = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAVEL_OPEN_EXPLORER)); + cacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAV_CACHE_PASSWORDS)); + includePimInCache = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PIM)); bMountReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)); bAutoRun = !IsButtonChecked (GetDlgItem (hwndDlg, IDC_AUTORUN_DISABLE)); bAutoMount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_AUTORUN_MOUNT)); @@ -4978,8 +4981,8 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa StringCbPrintfW (autoMount, sizeof(autoMount), L"VeraCrypt\\VeraCrypt.exe /q background%s%s%s%s /m rm /v %s", drive > 0 ? driveLetter : L"", - bExplore ? L" /e" : L"", - bCacheInDriver ? (bIncludePimInCache? L" /c p" : L" /c y") : L"", + openExplorer ? L" /e" : L"", + cacheInDriver ? (includePimInCache? L" /c p" : L" /c y") : L"", bMountReadOnly ? L" /m ro" : L"", volName); @@ -5161,7 +5164,7 @@ static int AskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int // GUI actions -static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, int pkcs5) +static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szVolFileName, int pim, int pkcs5) { BOOL status = FALSE; wchar_t fileName[MAX_PATH]; @@ -5193,12 +5196,12 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, VolumePim = -1; } - if (szFileName == NULL) + if (szVolFileName == NULL) { GetVolumePath (hwndDlg, fileName, ARRAYSIZE (fileName)); } else - StringCchCopyW (fileName, ARRAYSIZE (fileName), szFileName); + StringCchCopyW (fileName, ARRAYSIZE (fileName), szVolFileName); if (wcslen(fileName) == 0) { @@ -5212,16 +5215,16 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, goto ret; } - szFileName = fileName; + szVolFileName = fileName; - if (IsMountedVolume (szFileName)) + if (IsMountedVolume (szVolFileName)) { Warning ("VOL_ALREADY_MOUNTED", hwndDlg); status = FALSE; goto ret; } - if (!VolumePathExists (szFileName)) + if (!VolumePathExists (szVolFileName)) { if (!MultipleMountOperationInProgress) handleWin32Error (hwndDlg, SRC_POS); @@ -5237,16 +5240,16 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, if (!bUseCmdVolumePassword) { // First try cached passwords and if they fail ask user for a new one - mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, EffectiveVolumePkcs5, EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); + mounted = MountVolume (hwndDlg, nDosDriveNo, szVolFileName, NULL, EffectiveVolumePkcs5, EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); // If keyfiles are enabled, test empty password first if (!mounted && KeyFilesEnable && FirstKeyFile && bEffectiveTryEmptyPasswordWhenKeyfileUsed) { Password emptyPassword = {0}; - KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szFileName); + KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szVolFileName); - mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, EffectiveVolumePkcs5, EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); + mounted = MountVolume (hwndDlg, nDosDriveNo, szVolFileName, &emptyPassword, EffectiveVolumePkcs5, EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); burn (&emptyPassword, sizeof (emptyPassword)); } @@ -5256,7 +5259,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, if (!mounted && bEffectiveCacheDuringMultipleMount && MultipleMountOperationInProgress && VolumePassword.Length != 0) { // if no PIM specified for favorite, we use also the PIM of the previous volume alongside its password. - mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, EffectiveVolumePkcs5, (EffectiveVolumePim < 0)? VolumePim : EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); + mounted = MountVolume (hwndDlg, nDosDriveNo, szVolFileName, &VolumePassword, EffectiveVolumePkcs5, (EffectiveVolumePim < 0)? VolumePim : EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); } NormalCursor (); @@ -5265,7 +5268,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, { // Check for problematic file extensions (exe, dll, sys) - if (CheckFileExtension(szFileName)) + if (CheckFileExtension(szVolFileName)) Warning ("EXE_FILE_EXTENSION_MOUNT_WARNING", hwndDlg); } @@ -5281,7 +5284,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, { int GuiPkcs5 = EffectiveVolumePkcs5; int GuiPim = EffectiveVolumePim; - StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szFileName); + StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szVolFileName); if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiPim, NULL, TRUE)) goto ret; @@ -5297,13 +5300,13 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, WaitCursor (); if (KeyFilesEnable) - KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, szFileName); + KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, szVolFileName); - mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, !Silent); + mounted = MountVolume (hwndDlg, nDosDriveNo, szVolFileName, &VolumePassword, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, !Silent); NormalCursor (); // Check for problematic file extensions (exe, dll, sys) - if (mounted > 0 && CheckFileExtension (szFileName)) + if (mounted > 0 && CheckFileExtension (szVolFileName)) Warning ("EXE_FILE_EXTENSION_MOUNT_WARNING", hwndDlg); if (!MultipleMountOperationInProgress) @@ -5591,7 +5594,7 @@ retry: { if (mountList.ulMountedDrives & (1 << i)) { - wchar_t root[] = { (wchar_t) i + L'A', L':', L'\\', 0 }; + wchar_t root[] = { (wchar_t) (i + L'A'), L':', L'\\', 0 }; SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); } } @@ -5683,11 +5686,11 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt) vector partitions = drive.Partitions; partitions.insert (partitions.begin(), drive); - foreach (const HostDevice &device, partitions) + for (const HostDevice &device: partitions) { - wchar_t szFileName[TC_MAX_PATH]; - StringCbCopyW (szFileName, sizeof (szFileName), device.Path.c_str()); - BOOL mounted = IsMountedVolume (szFileName); + wchar_t szPartPath[TC_MAX_PATH]; + StringCbCopyW (szPartPath, sizeof (szPartPath), device.Path.c_str()); + BOOL mounted = IsMountedVolume (szPartPath); // Skip other partitions of the disk if partition0 (whole disk) is mounted if (!device.IsPartition && mounted) @@ -5747,8 +5750,8 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt) } // First try user password then cached passwords - if ((mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, TRUE, FALSE)) > 0 - || ((VolumePassword.Length > 0) && ((mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, TRUE, FALSE)) > 0))) + if ((mounted = MountVolume (hwndDlg, nDosDriveNo, szPartPath, &VolumePassword, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, TRUE, FALSE)) > 0 + || ((VolumePassword.Length > 0) && ((mounted = MountVolume (hwndDlg, nDosDriveNo, szPartPath, NULL, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, TRUE, FALSE)) > 0))) { // A volume has been successfully mounted @@ -6019,7 +6022,10 @@ static void ChangeSysEncPassword (HWND hwndDlg, BOOL bOnlyChangeKDF) if (CreateSysEncMutex ()) // If no instance of the wizard is currently taking care of system encryption { - StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF); + if (!GetKeyboardLayoutNameW(OrigKeyboardLayout)) + { + StringCbPrintfW(OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD)(DWORD_PTR)GetKeyboardLayout(NULL) & 0xFFFF); + } bSysEncPwdChangeDlgMode = TRUE; @@ -7680,7 +7686,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa reentry = true; - foreach (FavoriteVolume favorite, FavoritesOnArrivalMountRequired) + for (FavoriteVolume favorite: FavoritesOnArrivalMountRequired) { if (favorite.UseVolumeID) { @@ -7730,7 +7736,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa continue; bool mountedAndNotDisconnected = false; - foreach (FavoriteVolume mountedFavorite, FavoritesMountedOnArrivalStillConnected) + for (FavoriteVolume mountedFavorite: FavoritesMountedOnArrivalStillConnected) { if (favorite.Path == mountedFavorite.Path) { @@ -7985,12 +7991,12 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { if ((LastKnownMountList.ulMountedDrives & (1 << m)) && IsNullTerminateString (LastKnownMountList.wszVolume[m], TC_MAX_PATH)) { - wchar_t *vol = (wchar_t *) LastKnownMountList.wszVolume[m]; + wchar_t *wszVol = (wchar_t *) LastKnownMountList.wszVolume[m]; - if (wcsstr (vol, L"\\??\\") == vol) + if (wcsstr (wszVol, L"\\??\\") == wszVol) vol += 4; - if (vol[1] == L':' && i == (vol[0] - (vol[0] <= L'Z' ? L'A' : L'a'))) + if (wszVol[1] == L':' && i == (wszVol[0] - (wszVol[0] <= L'Z' ? L'A' : L'a'))) { UnmountVolume (hwndDlg, m, TRUE); WarningBalloon ("HOST_DEVICE_REMOVAL_DISMOUNT_WARN_TITLE", "HOST_DEVICE_REMOVAL_DISMOUNT_WARN", hwndDlg); @@ -11104,7 +11110,7 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) { int nDosLinkCreated = -1, nStatus = ERR_OS_ERROR; wchar_t szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH]; - wchar_t szFileName[TC_MAX_PATH]; + wchar_t szHeaderFileName[TC_MAX_PATH]; wchar_t szDosDevice[TC_MAX_PATH]; void *dev = INVALID_HANDLE_VALUE; DWORD dwError; @@ -11270,14 +11276,14 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) } /* Select backup file */ - if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, FALSE)) + if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szHeaderFileName, bHistory, FALSE)) { nStatus = ERR_SUCCESS; goto ret; } /* Open the backup file */ - fBackup = CreateFile (szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); + fBackup = CreateFile (szHeaderFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (fBackup == INVALID_HANDLE_VALUE) { nStatus = ERR_OS_ERROR; @@ -11413,7 +11419,6 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) goto error; } - LARGE_INTEGER headerOffset; LARGE_INTEGER headerBackupOffset; bool legacyBackup; int headerOffsetBackupFile; @@ -11730,7 +11735,7 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM BOOL enableExtendedIOCTL = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_EXTENDED_IOCTL_SUPPORT); BOOL allowTrimCommand = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD); BOOL allowWindowsDefrag = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG); - BOOL bDisableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION); + BOOL disableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION); try { @@ -11800,9 +11805,9 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption); BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig(); - if(originalDisableMemoryProtection != bDisableMemoryProtection) + if(originalDisableMemoryProtection != disableMemoryProtection) rebootRequired = true; - SetMemoryProtectionConfig (!bDisableMemoryProtection); + SetMemoryProtectionConfig (!disableMemoryProtection); DWORD bytesReturned; if (!DeviceIoControl (hDriver, TC_IOCTL_REREAD_DRIVER_CONFIG, NULL, 0, NULL, 0, &bytesReturned, NULL)) @@ -12160,8 +12165,8 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA { case WM_INITDIALOG: { - BootEncryptionStatus BootEncStatus = BootEncObj->GetStatus(); - if (!BootEncStatus.DriveMounted) + BootEncryptionStatus bootEncStatus = BootEncObj->GetStatus(); + if (!bootEncStatus.DriveMounted) { Warning ("SYS_DRIVE_NOT_ENCRYPTED", hwndDlg); EndDialog (hwndDlg, IDCANCEL); diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index 43ea971b..f6c1fb62 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -1646,7 +1646,6 @@ BOOL DoDriverUnload (HWND hwndDlg) if (hDriver != INVALID_HANDLE_VALUE) { - MOUNT_LIST_STRUCT driver; LONG driverVersion = VERSION_NUM; int refCount; DWORD dwResult; @@ -1895,7 +1894,7 @@ error: return bOK; } -BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL bDesktopIcon) +BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL bUseDesktopIcon) { wchar_t szLinkDir[TC_MAX_PATH], szDir[TC_MAX_PATH]; wchar_t szTmp[TC_MAX_PATH], szTmp2[TC_MAX_PATH]; @@ -1903,7 +1902,7 @@ BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL HRESULT hOle; int x; - if (bProgGroup == FALSE && bDesktopIcon == FALSE) + if (bProgGroup == FALSE && bUseDesktopIcon == FALSE) return TRUE; hOle = OleInitialize (NULL); @@ -1982,7 +1981,7 @@ BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL StatDeleteFile (szTmp2, FALSE); } - if (bDesktopIcon) + if (bUseDesktopIcon) { StringCbCopyW (szDir, sizeof(szDir), szDestDir); x = wcslen (szDestDir); diff --git a/src/SetupDLL/Setup.c b/src/SetupDLL/Setup.c index d0300c7e..4cbb11aa 100644 --- a/src/SetupDLL/Setup.c +++ b/src/SetupDLL/Setup.c @@ -2654,7 +2654,7 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostInstall(MSIHANDLE hInstaller) } // remvove legacy files that are not needed anymore - for (int i = 0; i < sizeof (szLegacyFiles) / sizeof (szLegacyFiles[0]); i++) + for (i = 0; i < sizeof (szLegacyFiles) / sizeof (szLegacyFiles[0]); i++) { StatDeleteFile (szLegacyFiles [i], TRUE); } -- cgit v1.2.3