diff options
-rw-r--r-- | src/Common/BootEncryption.cpp | 21 | ||||
-rw-r--r-- | src/Common/Crypto.c | 1 | ||||
-rw-r--r-- | src/Common/Dlgcode.c | 88 | ||||
-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 | ||||
-rw-r--r-- | src/Crypto/config.h | 2 | ||||
-rw-r--r-- | src/ExpandVolume/WinMain.cpp | 13 | ||||
-rw-r--r-- | src/Format/InPlace.c | 6 | ||||
-rw-r--r-- | src/Format/Tcformat.c | 75 | ||||
-rw-r--r-- | src/Mount/Favorites.cpp | 10 | ||||
-rw-r--r-- | src/Mount/Mount.c | 177 | ||||
-rw-r--r-- | src/Setup/Setup.c | 7 | ||||
-rw-r--r-- | src/SetupDLL/Setup.c | 2 |
17 files changed, 228 insertions, 214 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) 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 @@ -53,3 +53,3 @@ #ifndef CRYPTOPP_ALIGN_DATA - #if defined(_MSC_VER) + #if defined(_MSC_VER) && !defined(TC_WINDOWS_BOOT) #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(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 @@ -133,3 +133,3 @@ 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). */ @@ -554,5 +554,8 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA - 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); @@ -596,3 +599,3 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + DWORD keybLayout = (DWORD) (DWORD_PTR) GetKeyboardLayout (NULL); @@ -609,3 +612,3 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + keybLayout = (DWORD) (DWORD_PTR) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); 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 @@ -999,6 +999,6 @@ inplace_enc_read: { - 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; } 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 @@ -222,3 +222,3 @@ 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). */ @@ -403,3 +403,3 @@ static BOOL ElevateWholeWizardProcess (wstring arguments) { - 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) { @@ -3189,3 +3189,3 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi char *nResourceString; - __int64 nMultiplier; + __int64 nPrintMultiplier; wchar_t szTmp2[256]; @@ -3193,13 +3193,13 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi 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) { @@ -3212,3 +3212,3 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi } - else if (nMultiplier == BYTES_PER_KB) + else if (nPrintMultiplier == BYTES_PER_KB) { @@ -3221,3 +3221,3 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi } - else if (nMultiplier == BYTES_PER_MB) + else if (nPrintMultiplier == BYTES_PER_MB) { @@ -3230,3 +3230,3 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi } - else if (nMultiplier == BYTES_PER_GB) + else if (nPrintMultiplier == BYTES_PER_GB) { @@ -3251,3 +3251,3 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi { - 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); @@ -3255,3 +3255,3 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi 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 @@ -3262,5 +3262,5 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi if (lDiskFree->QuadPart % (__int64) BYTES_PER_MB != 0) - nMultiplier = BYTES_PER_KB; + nPrintMultiplier = BYTES_PER_KB; - return nMultiplier; + return nPrintMultiplier; } @@ -3664,3 +3664,3 @@ void HandleOldAssignedDriveLetter (void) { - 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]; @@ -4388,7 +4388,10 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa - 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); @@ -5321,3 +5324,3 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa // 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); } @@ -6700,3 +6703,3 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + DWORD keybLayout = (DWORD)(DWORD_PTR) GetKeyboardLayout (NULL); @@ -6713,3 +6716,3 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); @@ -9702,3 +9705,3 @@ int DetermineMaxHiddenVolSize (HWND hwndDlg) // 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) { @@ -9710,4 +9713,4 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi 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]; @@ -9786,3 +9789,3 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi // 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]; @@ -9792,3 +9795,3 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi // The value will then be used to determine the maximum possible size of the hidden volume. - if (*realClusterSize > 0) + if (*pRealClusterSize > 0) { @@ -9796,3 +9799,3 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi driveNo, - hiddenVolHostSize / *realClusterSize, + hiddenVolHostSize / *pRealClusterSize, pnbrFreeClusters); @@ -9824,3 +9827,3 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi - *realClusterSize = dwBytesPerSector * dwSectorsPerCluster; + *pRealClusterSize = dwBytesPerSector * dwSectorsPerCluster; @@ -9833,3 +9836,3 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi driveNo, - hiddenVolHostSize / *realClusterSize, + hiddenVolHostSize / *pRealClusterSize, pnbrFreeClusters); @@ -9889,3 +9892,3 @@ int MountHiddenVolHost (HWND hwndDlg, wchar_t *volumePath, int *driveNo, Passwor of the hidden volume. */ -int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int64 *nbrFreeClusters) +int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int64 *pnbrFreeClusters) { @@ -9897,3 +9900,3 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int 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}; @@ -9943,3 +9946,3 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int { - *nbrFreeClusters = 0; + *pnbrFreeClusters = 0; } @@ -9947,3 +9950,3 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int { - *nbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart; + *pnbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart; bitmapCnt = lpOutBuffer->BitmapSize.QuadPart / 8; @@ -9957,3 +9960,3 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int // 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 @@ -454,4 +454,4 @@ namespace VeraCrypt 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)) { @@ -460,3 +460,3 @@ namespace VeraCrypt ::SelectObject(hdc, hbr); - return (BOOL) hbr; + return (BOOL)(INT_PTR)hbr; } @@ -733,3 +733,3 @@ namespace VeraCrypt - foreach (const FavoriteVolume favorite, FavoriteVolumes) + for (const FavoriteVolume favorite: FavoriteVolumes) { @@ -743,3 +743,3 @@ namespace VeraCrypt - foreach (const FavoriteVolume favoriteConnected, FavoritesMountedOnArrivalStillConnected) + for (const FavoriteVolume favoriteConnected: FavoritesMountedOnArrivalStillConnected) { 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 @@ -177,3 +177,3 @@ 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). */ @@ -1722,3 +1722,3 @@ static void LaunchVolExpander (HWND hwndDlg) Error ("VOL_EXPANDER_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do - else if (((int)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) { @@ -2047,8 +2047,8 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive) { - 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); } @@ -2441,5 +2441,5 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR - 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); @@ -2498,3 +2498,3 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + DWORD keybLayout = (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL); @@ -2518,3 +2518,3 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); @@ -2567,3 +2567,3 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR // 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); } @@ -2753,3 +2753,3 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR { - 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); @@ -3117,5 +3117,8 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa - 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); @@ -3175,3 +3178,3 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa { - DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); + DWORD keybLayout = (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL); @@ -3188,3 +3191,3 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa - keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); + keybLayout = (DWORD)(DWORD_PTR) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); @@ -3641,3 +3644,3 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM { - static MountOptions *mountOptions; + static MountOptions *pMountOptions; @@ -3651,3 +3654,3 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM - mountOptions = (MountOptions *) lParam; + pMountOptions = (MountOptions *) lParam; @@ -3656,12 +3659,12 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM 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; @@ -3671,3 +3674,3 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendDlgItemMessage (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK, BM_SETCHECK, - mountOptions->UseBackupHeader ? BST_CHECKED : BST_UNCHECKED, 0); + pMountOptions->UseBackupHeader ? BST_CHECKED : BST_UNCHECKED, 0); @@ -3675,3 +3678,3 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM - 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 @@ -3694,3 +3697,3 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM /* if a PRF was selected previously, select it */ - if (i == mountOptions->ProtectedHidVolPkcs5Prf) + if (i == pMountOptions->ProtectedHidVolPkcs5Prf) nSelectedIndex = nIndex; @@ -3721,6 +3724,6 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM - 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; @@ -3730,6 +3733,6 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM - 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) { @@ -3837,12 +3840,12 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM - 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) { @@ -3850,11 +3853,11 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM 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); } @@ -3866,3 +3869,3 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM - if ((mountOptions->ProtectHiddenVolume && !bEnableBkgTask) + if ((pMountOptions->ProtectHiddenVolume && !bEnableBkgTask) && (AskWarnYesNo ("HIDVOL_PROT_BKG_TASK_WARNING", hwndDlg) == IDYES)) @@ -4481,3 +4484,3 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa ::SelectObject(hdc, hbr); - return (BOOL) hbr; + return (BOOL)(INT_PTR)hbr; } @@ -4547,3 +4550,3 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa - BOOL copyWizard, copyExpander, bExplore, bCacheInDriver, bIncludePimInCache, bAutoRun, bAutoMount, bMountReadOnly; + BOOL copyWizard, copyExpander, openExplorer, cacheInDriver, includePimInCache, bAutoRun, bAutoMount, bMountReadOnly; WCHAR dstDir[MAX_PATH + 1]; @@ -4565,5 +4568,5 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa 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)); @@ -4980,4 +4983,4 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa 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"", @@ -5163,3 +5166,3 @@ static int AskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int -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) { @@ -5195,3 +5198,3 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, - if (szFileName == NULL) + if (szVolFileName == NULL) { @@ -5200,3 +5203,3 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, else - StringCchCopyW (fileName, ARRAYSIZE (fileName), szFileName); + StringCchCopyW (fileName, ARRAYSIZE (fileName), szVolFileName); @@ -5214,5 +5217,5 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, - szFileName = fileName; + szVolFileName = fileName; - if (IsMountedVolume (szFileName)) + if (IsMountedVolume (szVolFileName)) { @@ -5223,3 +5226,3 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, - if (!VolumePathExists (szFileName)) + if (!VolumePathExists (szVolFileName)) { @@ -5239,3 +5242,3 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, // 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); @@ -5246,5 +5249,5 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, - 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); @@ -5258,3 +5261,3 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, // 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); } @@ -5267,3 +5270,3 @@ 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); @@ -5283,3 +5286,3 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, int GuiPim = EffectiveVolumePim; - StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szFileName); + StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szVolFileName); @@ -5299,5 +5302,5 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, 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 (); @@ -5305,3 +5308,3 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, // 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); @@ -5593,3 +5596,3 @@ retry: { - 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); @@ -5685,7 +5688,7 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt) - 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); @@ -5749,4 +5752,4 @@ 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))) { @@ -6021,3 +6024,6 @@ static void ChangeSysEncPassword (HWND hwndDlg, BOOL bOnlyChangeKDF) { - 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); + } @@ -7682,3 +7688,3 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa - foreach (FavoriteVolume favorite, FavoritesOnArrivalMountRequired) + for (FavoriteVolume favorite: FavoritesOnArrivalMountRequired) { @@ -7732,3 +7738,3 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa bool mountedAndNotDisconnected = false; - foreach (FavoriteVolume mountedFavorite, FavoritesMountedOnArrivalStillConnected) + for (FavoriteVolume mountedFavorite: FavoritesMountedOnArrivalStillConnected) { @@ -7987,8 +7993,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { - 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'))) { @@ -11106,3 +11112,3 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) 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]; @@ -11272,3 +11278,3 @@ 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)) { @@ -11279,3 +11285,3 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) /* 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) @@ -11415,3 +11421,2 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) - LARGE_INTEGER headerOffset; LARGE_INTEGER headerBackupOffset; @@ -11732,3 +11737,3 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM BOOL allowWindowsDefrag = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG); - BOOL bDisableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION); + BOOL disableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION); @@ -11802,5 +11807,5 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig(); - if(originalDisableMemoryProtection != bDisableMemoryProtection) + if(originalDisableMemoryProtection != disableMemoryProtection) rebootRequired = true; - SetMemoryProtectionConfig (!bDisableMemoryProtection); + SetMemoryProtectionConfig (!disableMemoryProtection); @@ -12162,4 +12167,4 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA { - BootEncryptionStatus BootEncStatus = BootEncObj->GetStatus(); - if (!BootEncStatus.DriveMounted) + BootEncryptionStatus bootEncStatus = BootEncObj->GetStatus(); + if (!bootEncStatus.DriveMounted) { 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 @@ -1648,3 +1648,2 @@ BOOL DoDriverUnload (HWND hwndDlg) { - MOUNT_LIST_STRUCT driver; LONG driverVersion = VERSION_NUM; @@ -1897,3 +1896,3 @@ error: -BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL bDesktopIcon) +BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL bUseDesktopIcon) { @@ -1905,3 +1904,3 @@ BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL - if (bProgGroup == FALSE && bDesktopIcon == FALSE) + if (bProgGroup == FALSE && bUseDesktopIcon == FALSE) return TRUE; @@ -1984,3 +1983,3 @@ BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL - if (bDesktopIcon) + if (bUseDesktopIcon) { 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 @@ -2656,3 +2656,3 @@ 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++) { |