diff options
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/BootEncryption.cpp | 21 | ||||
-rw-r--r-- | src/Common/Crypto.c | 1 | ||||
-rw-r--r-- | src/Common/Dlgcode.c | 234 | ||||
-rw-r--r-- | src/Common/Format.c | 6 | ||||
-rw-r--r-- | src/Common/Keyfiles.c | 4 | ||||
-rw-r--r-- | src/Common/Language.c | 12 | ||||
-rw-r--r-- | src/Common/Pkcs5.c | 4 | ||||
-rw-r--r-- | src/Common/Progress.c | 10 | ||||
-rw-r--r-- | src/Common/SecurityToken.cpp | 4 |
9 files changed, 150 insertions, 146 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<char>(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 <string.h> #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 <windowsx.h> +#include <versionhelpers.h> #include <dbghelp.h> #include <dbt.h> #include <Setupapi.h> @@ -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 <HostDevice> 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); |