1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 02:58:02 -06:00

Windows: Fix various compiler warnings

This commit is contained in:
Mounir IDRASSI
2024-11-15 00:41:07 +01:00
parent 117d8dd046
commit 43ad4f93eb
17 changed files with 315 additions and 301 deletions

View File

@@ -1141,7 +1141,7 @@ namespace VeraCrypt
// throw ParameterIncorrect (SRC_POS); // It is assumed that CheckRequirements() had been called // throw ParameterIncorrect (SRC_POS); // It is assumed that CheckRequirements() had been called
// Find the first active partition on the system drive // 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) if (partition.Info.BootIndicator)
{ {
@@ -1154,13 +1154,13 @@ namespace VeraCrypt
Partition bootPartition = partition; Partition bootPartition = partition;
Partition partitionBehindBoot; Partition partitionBehindBoot;
foreach (const Partition &partition, config.Partitions) for (const Partition &otherPartition : config.Partitions)
{ {
if (partition.Info.StartingOffset.QuadPart > bootPartition.Info.StartingOffset.QuadPart if (otherPartition.Info.StartingOffset.QuadPart > bootPartition.Info.StartingOffset.QuadPart
&& partition.Info.StartingOffset.QuadPart < minOffsetFound) && otherPartition.Info.StartingOffset.QuadPart < minOffsetFound)
{ {
minOffsetFound = partition.Info.StartingOffset.QuadPart; minOffsetFound = otherPartition.Info.StartingOffset.QuadPart;
partitionBehindBoot = partition; partitionBehindBoot = otherPartition;
} }
} }
@@ -1351,11 +1351,11 @@ namespace VeraCrypt
part.IsGPT = diskPartInfo.IsGPT; part.IsGPT = diskPartInfo.IsGPT;
// Mount point // 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":"; part.MountPoint += L":";
} }
@@ -2441,7 +2441,8 @@ namespace VeraCrypt
if (!fieldValue.empty() && strlen (fieldValue.c_str())) if (!fieldValue.empty() && strlen (fieldValue.c_str()))
{ {
string copieValue = fieldValue; 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(")) if (strstr (copieValue.c_str(), "postexec") && strstr (copieValue.c_str(), "file("))
{ {

View File

@@ -16,6 +16,7 @@
#include "Xts.h" #include "Xts.h"
#include "Crc.h" #include "Crc.h"
#include "Common/Endian.h" #include "Common/Endian.h"
#include "Crypto/t1ha.h"
#if !defined(_UEFI) #if !defined(_UEFI)
#include <string.h> #include <string.h>
#ifndef TC_WINDOWS_BOOT #ifndef TC_WINDOWS_BOOT

View File

@@ -14,6 +14,7 @@
#include "Tcdefs.h" #include "Tcdefs.h"
#include <windowsx.h> #include <windowsx.h>
#include <versionhelpers.h>
#include <dbghelp.h> #include <dbghelp.h>
#include <dbt.h> #include <dbt.h>
#include <Setupapi.h> #include <Setupapi.h>
@@ -1083,9 +1084,6 @@ static BOOL GetWindowsVersion(LPOSVERSIONINFOW lpVersionInformation)
bRet = TRUE; bRet = TRUE;
} }
if (!bRet)
bRet = GetVersionExW (lpVersionInformation);
#ifdef SETUP_DLL #ifdef SETUP_DLL
// we get real version from Kernel32.dll version since MSI always sets current version to 6.0 // 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 // 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 "); StringCbCopyW (newCmdLine, sizeof(newCmdLine), L"/q UAC ");
StringCbCatW (newCmdLine, sizeof (newCmdLine), args); 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) if (hwndDlg)
handleWin32Error (hwndDlg, SRC_POS); handleWin32Error (hwndDlg, SRC_POS);
@@ -3911,7 +3909,7 @@ void NotifyDriverOfPortableMode (void)
BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize) BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize)
{ {
DWORD fileSystemFlags; 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); return GetVolumeInformationW (root, label, labelSize / 2, NULL, NULL, &fileSystemFlags, NULL, 0);
} }
@@ -3941,11 +3939,12 @@ BOOL GetSysDevicePaths (HWND hwndDlg)
} }
// Find extra boot partition // 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) if (drive.ContainsSystem)
{ {
foreach (const HostDevice &sysDrivePartition, drive.Partitions) for (const HostDevice &sysDrivePartition : drive.Partitions)
{ {
if (sysDrivePartition.Bootable) if (sysDrivePartition.Bootable)
{ {
@@ -5389,7 +5388,7 @@ BOOL SelectMultipleFiles(HWND hwndDlg, const char *stringId, BOOL keepHistory, s
return status; 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; IFileDialog *pfd = NULL;
HRESULT hr; HRESULT hr;
@@ -5414,9 +5413,9 @@ BOOL BrowseDirectories(HWND hwndDlg, char *lpszTitle, wchar_t *dirName, const wc
} }
// Set the title. // Set the title.
if (lpszTitle) if (lpszDlgTitle)
{ {
pfd->SetTitle(GetString(lpszTitle)); pfd->SetTitle(GetString(lpszDlgTitle));
} }
IShellItem *psi; IShellItem *psi;
@@ -5754,7 +5753,7 @@ BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo)
BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue) BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue)
{ {
wchar_t wszRegPath[MAX_PATH]; 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; HKEY hKey;
LSTATUS lStatus; LSTATUS lStatus;
DWORD cbLabelLen = (DWORD) ((wcslen (effectiveLabel) + 1) * sizeof (wchar_t)); 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)) 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); SHChangeNotify (eventId, SHCNF_PATH, root, NULL);
@@ -8813,12 +8812,12 @@ retry:
wstring drivePath = L"\\\\.\\X:"; wstring drivePath = L"\\\\.\\X:";
HANDLE dev = INVALID_HANDLE_VALUE; HANDLE dev = INVALID_HANDLE_VALUE;
VOLUME_DISK_EXTENTS extents = {0}; VOLUME_DISK_EXTENTS extents = {0};
DWORD dwResult = 0; DWORD cbReturnedBytes = 0;
drivePath[4] = root[0]; drivePath[4] = root[0];
if ((dev = CreateFile (drivePath.c_str(),0, 0, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) 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) if (extents.NumberOfDiskExtents > 0)
{ {
@@ -8955,18 +8954,18 @@ retry:
if (bDevice && mount.bProtectHiddenVolume) 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; OPEN_TEST_STRUCT openTestStruct;
memset (&openTestStruct, 0, sizeof (openTestStruct)); memset (&openTestStruct, 0, sizeof (openTestStruct));
openTestStruct.bDetectTCBootLoader = TRUE; 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; DWORD cbBytesReturned;
if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &dwResult, NULL) && openTestStruct.TCBootLoaderDetected) 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); WarningDirect ((GetWrongPasswordErrorMessage (hwndDlg) + L"\n\n" + GetString ("HIDDEN_VOL_PROT_PASSWORD_US_KEYB_LAYOUT")).c_str(), hwndDlg);
else else
handleError (hwndDlg, mount.nReturnCode, SRC_POS); handleError (hwndDlg, mount.nReturnCode, SRC_POS);
@@ -9005,7 +9004,7 @@ retry:
if (mount.FilesystemDirty) if (mount.FilesystemDirty)
{ {
wchar_t msg[1024]; 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); StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_VOLUME_DIRTY"), mountPoint);
if (AskWarnYesNoStringTopmost (msg, hwndDlg) == IDYES) if (AskWarnYesNoStringTopmost (msg, hwndDlg) == IDYES)
@@ -9019,7 +9018,7 @@ retry:
&& !IsFileOnReadOnlyFilesystem (volumePath)) && !IsFileOnReadOnlyFilesystem (volumePath))
{ {
wchar_t msg[1024]; 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); StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_CONTAINER_FORCED_READ_ONLY"), mountPoint);
WarningDirect (msg, hwndDlg); WarningDirect (msg, hwndDlg);
@@ -9030,7 +9029,7 @@ retry:
&& bDevice) && bDevice)
{ {
wchar_t msg[1024]; 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); StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY"), mountPoint);
WarningDirect (msg, hwndDlg); WarningDirect (msg, hwndDlg);
@@ -9041,7 +9040,7 @@ retry:
&& wcsstr (volumePath, L"\\Device\\Harddisk") == volumePath) && wcsstr (volumePath, L"\\Device\\Harddisk") == volumePath)
{ {
wchar_t msg[1024]; 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); StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY_WRITE_PROTECTION"), mountPoint);
WarningDirect (msg, hwndDlg); WarningDirect (msg, hwndDlg);
@@ -9059,7 +9058,7 @@ retry:
&& bDevice) && bDevice)
{ {
wchar_t msg[1024]; 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); StringCbPrintfW (msg, sizeof(msg), GetString ("PARTIAL_SYSENC_MOUNT_READONLY"), mountPoint);
WarningDirect (msg, hwndDlg); WarningDirect (msg, hwndDlg);
@@ -9152,7 +9151,7 @@ retry:
} }
// Undo SHCNE_DRIVEREMOVED // 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); SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL);
return FALSE; return FALSE;
@@ -9506,7 +9505,7 @@ int GetDiskDeviceDriveLetter (PWSTR deviceName)
for (i = 0; i < 26; i++) 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\\"); StringCchCopyW (link, MAX_PATH, L"\\DosDevices\\");
StringCchCatW (link, MAX_PATH, drive); StringCchCatW (link, MAX_PATH, drive);
@@ -10704,12 +10703,12 @@ void OpenPageHelp (HWND hwndDlg, int nPage)
} }
else 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) if (r == ERROR_FILE_NOT_FOUND)
{ {
// Try the secondary help file // 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) if (r == ERROR_FILE_NOT_FOUND)
{ {
@@ -10936,14 +10935,11 @@ BOOL IsARM()
BOOL IsServerOS () BOOL IsServerOS ()
{ {
OSVERSIONINFOEXW osVer; return IsWindowsServer()? TRUE : FALSE;
osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW);
GetVersionExW ((LPOSVERSIONINFOW) &osVer);
return (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER);
} }
// Returns TRUE, if the currently running operating system is installed in a hidden volume. If it's not, or if // 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. // there's an error, returns FALSE.
BOOL IsHiddenOSRunning (void) BOOL IsHiddenOSRunning (void)
@@ -11018,22 +11014,23 @@ std::wstring GetWindowsEdition ()
{ {
wstring osname = L"win"; wstring osname = L"win";
OSVERSIONINFOEXW osVer; OSVERSIONINFOEXW osVer = { 0 };
osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW); osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW);
GetVersionExW ((LPOSVERSIONINFOW) &osVer); if (GetWindowsVersion((LPOSVERSIONINFOW)&osVer))
{
BOOL home = (osVer.wSuiteMask & VER_SUITE_PERSONAL); BOOL home = (osVer.wSuiteMask & VER_SUITE_PERSONAL);
BOOL server = (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER); BOOL server = (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER);
HKEY hkey; HKEY hkey;
wchar_t productName[300] = {0}; wchar_t productName[300] = { 0 };
DWORD productNameSize = sizeof (productName); DWORD productNameSize = sizeof(productName);
if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) 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) if (RegQueryValueEx(hkey, L"ProductName", 0, 0, (LPBYTE)&productName, &productNameSize) != ERROR_SUCCESS || productNameSize < 1)
productName[0] = 0; productName[0] = 0;
RegCloseKey (hkey); RegCloseKey(hkey);
} }
switch (nCurrentOS) switch (nCurrentOS)
@@ -11078,31 +11075,31 @@ std::wstring GetWindowsEdition ()
if (server) if (server)
osname += L"-server"; osname += L"-server";
if (IsOSAtLeast (WIN_VISTA)) if (IsOSAtLeast(WIN_VISTA))
{ {
if (home) if (home)
osname += L"-home"; osname += L"-home";
else if (wcsstr (productName, L"Standard") != 0) else if (wcsstr(productName, L"Standard") != 0)
osname += L"-standard"; osname += L"-standard";
else if (wcsstr (productName, L"Professional") != 0) else if (wcsstr(productName, L"Professional") != 0)
osname += L"-pro"; osname += L"-pro";
else if (wcsstr (productName, L"Business") != 0) else if (wcsstr(productName, L"Business") != 0)
osname += L"-business"; osname += L"-business";
else if (wcsstr (productName, L"Enterprise") != 0) else if (wcsstr(productName, L"Enterprise") != 0)
osname += L"-enterprise"; osname += L"-enterprise";
else if (wcsstr (productName, L"Datacenter") != 0) else if (wcsstr(productName, L"Datacenter") != 0)
osname += L"-datacenter"; osname += L"-datacenter";
else if (wcsstr (productName, L"Ultimate") != 0) else if (wcsstr(productName, L"Ultimate") != 0)
osname += L"-ultimate"; osname += L"-ultimate";
} }
if (GetSystemMetrics (SM_STARTER)) if (GetSystemMetrics(SM_STARTER))
osname += L"-starter"; osname += L"-starter";
else if (wcsstr (productName, L"Basic") != 0) else if (wcsstr(productName, L"Basic") != 0)
osname += L"-basic"; osname += L"-basic";
if (Is64BitOs()) if (Is64BitOs())
osname += IsARM()? L"-arm64" : L"-x64"; osname += IsARM() ? L"-arm64" : L"-x64";
if (CurrentOSServicePack > 0) if (CurrentOSServicePack > 0)
{ {
@@ -11112,6 +11109,11 @@ std::wstring GetWindowsEdition ()
} }
return osname; return osname;
}
else
{
return L"";
}
} }
#ifdef SETUP #ifdef SETUP
@@ -11124,7 +11126,7 @@ void Applink (const char *dest)
wchar_t page[TC_MAX_PATH] = {0}; wchar_t page[TC_MAX_PATH] = {0};
wchar_t installDir[TC_MAX_PATH] = {0}; wchar_t installDir[TC_MAX_PATH] = {0};
BOOL buildUrl = TRUE; BOOL buildUrl = TRUE;
int r; INT_PTR r;
ArrowWaitCursor (); ArrowWaitCursor ();
@@ -11328,7 +11330,7 @@ void Applink (const char *dest)
} }
else 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) 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) void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors)
{ {
wchar_t msg[1024], param[1024], cmdPath[MAX_PATH]; 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) if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP", hwndDlg) == IDNO)
return; return;
@@ -13300,18 +13302,18 @@ BOOL IsWindowsIsoBurnerAvailable ()
BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath) BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath)
{ {
wchar_t path[MAX_PATH*2] = { 0 }; wchar_t path[MAX_PATH*2] = { 0 };
int r; INT_PTR r;
if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_SYSTEM, NULL, 0, path))) if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_SYSTEM, NULL, 0, path)))
StringCbCatW (path, MAX_PATH*2, L"\\" ISO_BURNER_TOOL); StringCbCatW (path, MAX_PATH*2, L"\\" ISO_BURNER_TOOL);
else else
StringCbCopyW (path, MAX_PATH*2, L"C:\\Windows\\System32\\" ISO_BURNER_TOOL); 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) if (r <= 32)
{ {
SetLastError (r); SetLastError ((DWORD) r);
handleWin32Error (hwnd, SRC_POS); handleWin32Error (hwnd, SRC_POS);
return FALSE; return FALSE;
@@ -15259,7 +15261,7 @@ void PasswordEditDropTarget::GotLeave(void)
DWORD PasswordEditDropTarget::GotEnter(void) DWORD PasswordEditDropTarget::GotEnter(void)
{ {
TCHAR szClassName[64]; TCHAR szClassName[64];
DWORD dwStyles; DWORD_PTR dwStyles;
int maxLen; int maxLen;
HWND hChild = WindowFromPoint (m_DropPoint); 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) // 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) if(m_Data)
{ {
TCHAR szClassName[64]; TCHAR szClassName[64];
DWORD dwStyles; DWORD_PTR dwStyles;
int maxLen; int maxLen;
HWND hChild = WindowFromPoint (m_DropPoint); HWND hChild = WindowFromPoint (m_DropPoint);
if (hChild && GetClassName (hChild, szClassName, ARRAYSIZE (szClassName)) && (0 == _tcsicmp (szClassName, _T("EDIT"))) if (hChild && GetClassName (hChild, szClassName, ARRAYSIZE (szClassName)) && (0 == _tcsicmp (szClassName, _T("EDIT")))

View File

@@ -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 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. // The volume header had been written successfully so we need to seek to the byte after the header.
LARGE_INTEGER offset; LARGE_INTEGER volDataOffset;
offset.QuadPart = TC_VOLUME_DATA_OFFSET; volDataOffset.QuadPart = TC_VOLUME_DATA_OFFSET;
if (!SetFilePointerEx ((HANDLE) dev, offset, NULL, FILE_BEGIN)) if (!SetFilePointerEx ((HANDLE) dev, volDataOffset, NULL, FILE_BEGIN))
{ {
nStatus = ERR_OS_ERROR; nStatus = ERR_OS_ERROR;
goto error; goto error;

View File

@@ -270,7 +270,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
unsigned __int32 writePos = 0; unsigned __int32 writePos = 0;
size_t totalRead = 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); 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 // set the text colour in (HDC)wParam
SetBkMode((HDC)wParam,TRANSPARENT); SetBkMode((HDC)wParam,TRANSPARENT);
SetTextColor((HDC)wParam, RGB(255,0,0)); SetTextColor((HDC)wParam, RGB(255,0,0));
return (BOOL)GetSysColorBrush(COLOR_MENU); return (BOOL)(INT_PTR)GetSysColorBrush(COLOR_MENU);
} }
} }
return 0; return 0;

View File

@@ -342,7 +342,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
xml = (char *) res; xml = (char *) res;
while (xml = XmlFindElement (xml, xmlElements[i])) while (xml = XmlFindElement (xml, xmlElements[i]))
{ {
void *key; void *pkey;
void *text; void *text;
XmlGetAttributeText (xml, "lang", attr, sizeof (attr)); 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))) if (XmlGetAttributeText (xml, "key", attr, sizeof (attr)))
{ {
key = AddPoolData (attr, strlen (attr) + 1); pkey = AddPoolData (attr, strlen (attr) + 1);
if (key == NULL) return FALSE; if (pkey == NULL) return FALSE;
XmlGetNodeText (xml, attr, sizeof (attr)); XmlGetNodeText (xml, attr, sizeof (attr));
@@ -371,7 +371,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
case 'n': *out++ = 13; *out++ = 10; break; case 'n': *out++ = 13; *out++ = 10; break;
default: default:
if (!bForceSilent) 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; return FALSE;
} }
} }
@@ -386,7 +386,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
if (len == 0) if (len == 0)
{ {
if (!bForceSilent) 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; return FALSE;
} }
@@ -394,7 +394,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
text = AddPoolData ((void *) wattr, len * 2); text = AddPoolData ((void *) wattr, len * 2);
if (text == NULL) return FALSE; if (text == NULL) return FALSE;
AddDictionaryEntry ((char *) key, 0, text); AddDictionaryEntry ((char *)pkey, 0, text);
} }
} }

View File

@@ -1223,9 +1223,9 @@ int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL bBoot)
default: default:
TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID
} }
#if _MSC_VER < 1900
return 0; return 0;
#endif
} }
int is_pkcs5_prf_supported (int pkcs5_prf_id, PRF_BOOT_TYPE bootType) int is_pkcs5_prf_supported (int pkcs5_prf_id, PRF_BOOT_TYPE bootType)

View File

@@ -36,9 +36,9 @@ static wchar_t *seconds, *minutes, *hours, *days;
// the speed of the "transform cursor"). // the speed of the "transform cursor").
void InitProgressBar (__int64 totalBytes, __int64 bytesDone, BOOL bReverse, BOOL bIOThroughput, BOOL bDisplayStatus, BOOL bShowPercent) void InitProgressBar (__int64 totalBytes, __int64 bytesDone, BOOL bReverse, BOOL bIOThroughput, BOOL bDisplayStatus, BOOL bShowPercent)
{ {
HWND hProgressBar = GetDlgItem (hCurPage, nPbar); HWND hCurProgressBar = GetDlgItem (hCurPage, nPbar);
SendMessage (hProgressBar, PBM_SETRANGE32, 0, 10000); SendMessage (hCurProgressBar, PBM_SETRANGE32, 0, 10000);
SendMessage (hProgressBar, PBM_SETSTEP, 1, 0); SendMessage (hCurProgressBar, PBM_SETSTEP, 1, 0);
bProgressBarReverse = bReverse; bProgressBarReverse = bReverse;
bRWThroughput = bIOThroughput; bRWThroughput = bIOThroughput;
@@ -66,7 +66,7 @@ BOOL UpdateProgressBarProc (__int64 byteOffset)
{ {
wchar_t text[100]; wchar_t text[100];
wchar_t speed[100]; wchar_t speed[100];
HWND hProgressBar = GetDlgItem (hCurPage, nPbar); HWND hCurProgressBar = GetDlgItem (hCurPage, nPbar);
int time = GetTickCount (); int time = GetTickCount ();
int elapsed = (time - startTime) / 1000; int elapsed = (time - startTime) / 1000;
@@ -126,7 +126,7 @@ BOOL UpdateProgressBarProc (__int64 byteOffset)
prevTime = time; prevTime = time;
SendMessage (hProgressBar, PBM_SETPOS, SendMessage (hCurProgressBar, PBM_SETPOS,
(int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)), (int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)),
0); 0);

View File

@@ -220,7 +220,7 @@ namespace VeraCrypt
throw; throw;
} }
foreach(const CK_OBJECT_HANDLE & dataHandle, GetObjects(slotId, CKO_DATA)) for(const CK_OBJECT_HANDLE & dataHandle: GetObjects(slotId, CKO_DATA))
{ {
SecurityTokenKeyfile keyfile; SecurityTokenKeyfile keyfile;
keyfile.Handle = dataHandle; keyfile.Handle = dataHandle;
@@ -348,7 +348,7 @@ namespace VeraCrypt
while (true) while (true)
{ {
CK_OBJECT_HANDLE object; 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) if (status != CKR_OK)
throw Pkcs11Exception(status); throw Pkcs11Exception(status);

View File

@@ -51,7 +51,7 @@
#endif #endif
#ifndef CRYPTOPP_ALIGN_DATA #ifndef CRYPTOPP_ALIGN_DATA
#if defined(_MSC_VER) #if defined(_MSC_VER) && !defined(TC_WINDOWS_BOOT)
#define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x)) #define CRYPTOPP_ALIGN_DATA(x) __declspec(align(x))
#elif defined(__GNUC__) #elif defined(__GNUC__)
#define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x))) #define CRYPTOPP_ALIGN_DATA(x) __attribute__((aligned(x)))

View File

@@ -131,7 +131,7 @@ MountOptions defaultMountOptions;
KeyFile *FirstCmdKeyFile; KeyFile *FirstCmdKeyFile;
HBITMAP hbmLogoBitmapRescaled = 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 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. */ 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), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); 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) 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: case TIMER_ID_KEYB_LAYOUT_GUARD:
if (bPrebootPasswordDlgMode) if (bPrebootPasswordDlgMode)
{ {
DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); DWORD keybLayout = (DWORD) (DWORD_PTR) GetKeyboardLayout (NULL);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409) 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), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); 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) if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{ {

View File

@@ -997,10 +997,10 @@ inplace_enc_read:
{ {
if (!WipeBuffer (wipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, workChunkSize)) if (!WipeBuffer (wipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, workChunkSize))
{ {
ULONG i; ULONG index;
for (i = 0; i < workChunkSize; ++i) 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); EncryptDataUnits (wipeBuffer, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo);

View File

@@ -220,7 +220,7 @@ volatile HWND hVerifyPasswordInputField = NULL; /* Verify-password input field
HBITMAP hbmWizardBitmapRescaled = NULL; 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 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. */ 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) 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); exit (0);
} }
@@ -3187,21 +3187,21 @@ static void LoadPage (HWND hwndDlg, int nPageNo)
__int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDiskFree) __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDiskFree)
{ {
char *nResourceString; char *nResourceString;
__int64 nMultiplier; __int64 nPrintMultiplier;
wchar_t szTmp2[256]; wchar_t szTmp2[256];
if (lDiskFree->QuadPart < BYTES_PER_KB) if (lDiskFree->QuadPart < BYTES_PER_KB)
nMultiplier = 1; nPrintMultiplier = 1;
else if (lDiskFree->QuadPart < BYTES_PER_MB) else if (lDiskFree->QuadPart < BYTES_PER_MB)
nMultiplier = BYTES_PER_KB; nPrintMultiplier = BYTES_PER_KB;
else if (lDiskFree->QuadPart < BYTES_PER_GB) else if (lDiskFree->QuadPart < BYTES_PER_GB)
nMultiplier = BYTES_PER_MB; nPrintMultiplier = BYTES_PER_MB;
else if (lDiskFree->QuadPart < BYTES_PER_TB) else if (lDiskFree->QuadPart < BYTES_PER_TB)
nMultiplier = BYTES_PER_GB; nPrintMultiplier = BYTES_PER_GB;
else else
nMultiplier = BYTES_PER_TB; nPrintMultiplier = BYTES_PER_TB;
if (nMultiplier == 1) if (nPrintMultiplier == 1)
{ {
if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
nResourceString = "MAX_HIDVOL_SIZE_BYTES"; nResourceString = "MAX_HIDVOL_SIZE_BYTES";
@@ -3210,7 +3210,7 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi
else else
nResourceString = "DISK_FREE_BYTES"; 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 if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
nResourceString = "MAX_HIDVOL_SIZE_KB"; nResourceString = "MAX_HIDVOL_SIZE_KB";
@@ -3219,7 +3219,7 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi
else else
nResourceString = "DISK_FREE_KB"; 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 if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
nResourceString = "MAX_HIDVOL_SIZE_MB"; nResourceString = "MAX_HIDVOL_SIZE_MB";
@@ -3228,7 +3228,7 @@ __int64 PrintFreeSpace (HWND hwndTextBox, wchar_t *lpszDrive, PLARGE_INTEGER lDi
else else
nResourceString = "DISK_FREE_MB"; 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 if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume
nResourceString = "MAX_HIDVOL_SIZE_GB"; 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 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); SetWindowTextW (GetDlgItem (hwndTextBox, IDC_SIZEBOX), szTmp2);
} }
else if (lpszDrive) 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 else
szTmp2 [0] = 0; szTmp2 [0] = 0;
SetWindowTextW (hwndTextBox, szTmp2); SetWindowTextW (hwndTextBox, szTmp2);
if (lDiskFree->QuadPart % (__int64) BYTES_PER_MB != 0) if (lDiskFree->QuadPart % (__int64) BYTES_PER_MB != 0)
nMultiplier = BYTES_PER_KB; nPrintMultiplier = BYTES_PER_KB;
return nMultiplier; return nPrintMultiplier;
} }
void DisplaySizingErrorText (HWND hwndTextBox) void DisplaySizingErrorText (HWND hwndTextBox)
@@ -3662,7 +3662,7 @@ void HandleOldAssignedDriveLetter (void)
&& !bHiddenOS && !bHiddenOS
&& driveLetter >= 0) && 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]; wchar_t szTmp[8192];
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("AFTER_FORMAT_DRIVE_LETTER_WARN"), rootPath[0], rootPath[0], rootPath[0], rootPath[0]); 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_PASSWORD);
ToBootPwdField (hwndDlg, IDC_VERIFY); ToBootPwdField (hwndDlg, IDC_VERIFY);
StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF); if (!GetKeyboardLayoutNameW(OrigKeyboardLayout))
if ((DWORD) GetKeyboardLayout (NULL) != 0x00000409 && (DWORD) GetKeyboardLayout (NULL) != 0x04090409)
{ {
DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE); StringCbPrintfW(OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD)(DWORD_PTR)GetKeyboardLayout(NULL) & 0xFFFF);
}
if ((DWORD)(DWORD_PTR)GetKeyboardLayout (NULL) != 0x00000409 && (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL) != 0x04090409)
{
DWORD keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409) if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{ {
@@ -5319,7 +5322,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
SetBkMode((HDC)wParam,TRANSPARENT); SetBkMode((HDC)wParam,TRANSPARENT);
SetTextColor((HDC)wParam, RGB(255,0,0)); SetTextColor((HDC)wParam, RGB(255,0,0));
// NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle. // 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; return 0;
@@ -6698,7 +6701,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
case TIMER_ID_KEYB_LAYOUT_GUARD: case TIMER_ID_KEYB_LAYOUT_GUARD:
if (SysEncInEffect ()) if (SysEncInEffect ())
{ {
DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); DWORD keybLayout = (DWORD)(DWORD_PTR) GetKeyboardLayout (NULL);
/* Watch the keyboard layout */ /* 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_PASSWORD, szRawPassword);
SetPassword (hCurPage, IDC_VERIFY, szVerify); 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) 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, // 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 // retrieves the cluster size, and scans the volume cluster bitmap. In addition, checks
// the TrueCrypt volume format version and the type of volume. // 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; HANDLE hDevice;
DWORD bytesReturned; DWORD bytesReturned;
@@ -9708,8 +9711,8 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi
DWORD dwResult; DWORD dwResult;
int result; int result;
wchar_t szFileSystemNameBuffer[256]; wchar_t szFileSystemNameBuffer[256];
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};
wchar_t szRootPathName[4] = {(wchar_t) *driveNo + L'A', L':', L'\\', 0}; wchar_t szRootPathName[4] = {(wchar_t) (*driveNo + L'A'), L':', L'\\', 0};
BYTE readBuffer[TC_MAX_VOLUME_SECTOR_SIZE * 2]; BYTE readBuffer[TC_MAX_VOLUME_SECTOR_SIZE * 2];
LARGE_INTEGER offset, offsetNew; LARGE_INTEGER offset, offsetNew;
VOLUME_PROPERTIES_STRUCT volProp; VOLUME_PROPERTIES_STRUCT volProp;
@@ -9784,17 +9787,17 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi
// FAT12/FAT16/FAT32 // FAT12/FAT16/FAT32
// Retrieve the cluster size // 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. // 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 // 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. // 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. // 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, return ScanVolClusterBitmap (hwndDlg,
driveNo, driveNo,
hiddenVolHostSize / *realClusterSize, hiddenVolHostSize / *pRealClusterSize,
pnbrFreeClusters); pnbrFreeClusters);
} }
else else
@@ -9822,7 +9825,7 @@ int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSi
return -1; return -1;
}; };
*realClusterSize = dwBytesPerSector * dwSectorsPerCluster; *pRealClusterSize = dwBytesPerSector * dwSectorsPerCluster;
// Get the map of the clusters that are free and in use on the outer volume. // 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 // 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, return ScanVolClusterBitmap (hwndDlg,
driveNo, driveNo,
hiddenVolHostSize / *realClusterSize, hiddenVolHostSize / *pRealClusterSize,
pnbrFreeClusters); pnbrFreeClusters);
} }
else 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 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 volume. The value will then be used to determine the maximum possible size
of the hidden volume. */ 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; PVOLUME_BITMAP_BUFFER lpOutBuffer;
STARTING_LCN_INPUT_BUFFER lpInBuffer; STARTING_LCN_INPUT_BUFFER lpInBuffer;
@@ -9895,7 +9898,7 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int
HANDLE hDevice; HANDLE hDevice;
DWORD lBytesReturned; DWORD lBytesReturned;
BYTE rmnd; 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; DWORD bufLen;
__int64 bitmapCnt; __int64 bitmapCnt;
@@ -9941,11 +9944,11 @@ int ScanVolClusterBitmap (HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int
if ((rmnd != 0) if ((rmnd != 0)
&& ((lpOutBuffer->Buffer[lpOutBuffer->BitmapSize.QuadPart / 8] & ((1 << rmnd)-1) ) != 0)) && ((lpOutBuffer->Buffer[lpOutBuffer->BitmapSize.QuadPart / 8] & ((1 << rmnd)-1) ) != 0))
{ {
*nbrFreeClusters = 0; *pnbrFreeClusters = 0;
} }
else else
{ {
*nbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart; *pnbrFreeClusters = lpOutBuffer->BitmapSize.QuadPart;
bitmapCnt = lpOutBuffer->BitmapSize.QuadPart / 8; bitmapCnt = lpOutBuffer->BitmapSize.QuadPart / 8;
// Scan the bitmap from the end // 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. // 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. // 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; break;
} }
} }

View File

@@ -452,13 +452,13 @@ namespace VeraCrypt
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
{ {
HDC hdc = (HDC) wParam; HDC hdc = (HDC) wParam;
HWND hw = (HWND) lParam; HWND hwnd = (HWND) lParam;
if (hw == GetDlgItem(hwndDlg, IDC_FAVORITE_VOLUME_ID)) if (hwnd == GetDlgItem(hwndDlg, IDC_FAVORITE_VOLUME_ID))
{ {
// This the favorite ID field. Make its background like normal edit // This the favorite ID field. Make its background like normal edit
HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW); HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW);
::SelectObject(hdc, hbr); ::SelectObject(hdc, hbr);
return (BOOL) hbr; return (BOOL)(INT_PTR)hbr;
} }
} }
break; break;
@@ -731,7 +731,7 @@ namespace VeraCrypt
FavoritesOnArrivalMountRequired.clear(); FavoritesOnArrivalMountRequired.clear();
foreach (const FavoriteVolume favorite, FavoriteVolumes) for (const FavoriteVolume favorite: FavoriteVolumes)
{ {
if (favorite.MountOnArrival) if (favorite.MountOnArrival)
{ {
@@ -741,7 +741,7 @@ namespace VeraCrypt
{ {
bool present = false; bool present = false;
foreach (const FavoriteVolume favoriteConnected, FavoritesMountedOnArrivalStillConnected) for (const FavoriteVolume favoriteConnected: FavoritesMountedOnArrivalStillConnected)
{ {
if (favorite.Path == favoriteConnected.Path) if (favorite.Path == favoriteConnected.Path)
{ {

View File

@@ -175,7 +175,7 @@ MountOptions defaultMountOptions;
KeyFile *FirstCmdKeyFile = NULL; KeyFile *FirstCmdKeyFile = NULL;
HBITMAP hbmLogoBitmapRescaled = 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 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. */ 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)) if (!FileExists(t))
Error ("VOL_EXPANDER_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do 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); handleWin32Error (hwndDlg, SRC_POS);
} }
@@ -2045,12 +2045,12 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
{ {
if (!VolumeNotificationsList.bHidVolDamagePrevReported[i]) if (!VolumeNotificationsList.bHidVolDamagePrevReported[i])
{ {
wchar_t szTmp[4096]; wchar_t szMsgTmp[4096];
VolumeNotificationsList.bHidVolDamagePrevReported[i] = TRUE; 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)); 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 else
@@ -2439,9 +2439,9 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
ToBootPwdField (hwndDlg, IDC_VERIFY); ToBootPwdField (hwndDlg, IDC_VERIFY);
ToBootPwdField (hwndDlg, IDC_OLD_PASSWORD); 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) 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: case TIMER_ID_KEYB_LAYOUT_GUARD:
if (bSysEncPwdChangeDlgMode) if (bSysEncPwdChangeDlgMode)
{ {
DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); DWORD keybLayout = (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL);
/* Watch the keyboard layout */ /* 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_PASSWORD), L"");
SetWindowText (GetDlgItem (hwndDlg, IDC_VERIFY), 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) if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{ {
@@ -2565,7 +2565,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
SetBkMode((HDC)wParam,TRANSPARENT); SetBkMode((HDC)wParam,TRANSPARENT);
SetTextColor((HDC)wParam, RGB(255,0,0)); SetTextColor((HDC)wParam, RGB(255,0,0));
// NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle. // 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; 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)) 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); Info ("ALGO_NOT_SUPPORTED_FOR_SYS_ENCRYPTION", hwndDlg);
SelectAlgo (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), &new_hash_algo_id); 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), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); 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) 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: case TIMER_ID_KEYB_LAYOUT_GUARD:
if (bPrebootPasswordDlgMode) if (bPrebootPasswordDlgMode)
{ {
DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL); DWORD keybLayout = (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409) 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), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L""); 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) 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) BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
static MountOptions *mountOptions; static MountOptions *pMountOptions;
WORD lw = LOWORD (wParam); WORD lw = LOWORD (wParam);
@@ -3649,31 +3652,31 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
{ {
BOOL protect; BOOL protect;
mountOptions = (MountOptions *) lParam; pMountOptions = (MountOptions *) lParam;
LocalizeDialog (hwndDlg, "IDD_MOUNT_OPTIONS"); LocalizeDialog (hwndDlg, "IDD_MOUNT_OPTIONS");
SendDlgItemMessage (hwndDlg, IDC_MOUNT_READONLY, BM_SETCHECK, 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, 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, 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, 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, SendDlgItemMessage (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA, BM_SETCHECK,
bPrebootPasswordDlgMode ? BST_CHECKED : BST_UNCHECKED, 0); bPrebootPasswordDlgMode ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK, BM_SETCHECK, 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); 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 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)); 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)); nIndex = (int) SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i); SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
/* if a PRF was selected previously, select it */ /* if a PRF was selected previously, select it */
if (i == mountOptions->ProtectedHidVolPkcs5Prf) if (i == pMountOptions->ProtectedHidVolPkcs5Prf)
nSelectedIndex = nIndex; nSelectedIndex = nIndex;
} }
@@ -3719,19 +3722,19 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
ToNormalPwdField (hwndDlg, IDC_PASSWORD_PROT_HIDVOL); ToNormalPwdField (hwndDlg, IDC_PASSWORD_PROT_HIDVOL);
SendDlgItemMessage (hwndDlg, IDC_PIM, EM_LIMITTEXT, MAX_PIM, 0); 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]; 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; szTmp [0] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), szTmp); SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), szTmp);
burn (szTmp, sizeof (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 */ /* 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); SetCheckBox (hwndDlg, IDC_PIM_ENABLE, TRUE);
ShowWindow (GetDlgItem (hwndDlg, IDC_PIM_ENABLE), SW_HIDE); 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]; wchar_t tmp[MAX_PASSWORD+1];
mountOptions->ReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)); pMountOptions->ReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY));
mountOptions->Removable = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_REMOVABLE)); pMountOptions->Removable = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_REMOVABLE));
mountOptions->DisableMountManager = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER)); pMountOptions->DisableMountManager = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER));
mountOptions->ProtectHiddenVolume = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL)); pMountOptions->ProtectHiddenVolume = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL));
mountOptions->PartitionInInactiveSysEncScope = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA)); pMountOptions->PartitionInInactiveSysEncScope = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA));
mountOptions->UseBackupHeader = IsButtonChecked (GetDlgItem (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK)); 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; int iMaxPasswordLength = bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD : MAX_PASSWORD;
GetPassword (hwndDlg, IDC_PASSWORD_PROT_HIDVOL, GetPassword (hwndDlg, IDC_PASSWORD_PROT_HIDVOL,
(LPSTR) mountOptions->ProtectedHidVolPassword.Text, iMaxPasswordLength + 1, (LPSTR) pMountOptions->ProtectedHidVolPassword.Text, iMaxPasswordLength + 1,
FALSE, FALSE); 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); 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 // Cleanup
@@ -3864,7 +3867,7 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
tmp[MAX_PASSWORD] = 0; tmp[MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp); SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
if ((mountOptions->ProtectHiddenVolume && !bEnableBkgTask) if ((pMountOptions->ProtectHiddenVolume && !bEnableBkgTask)
&& (AskWarnYesNo ("HIDVOL_PROT_BKG_TASK_WARNING", hwndDlg) == IDYES)) && (AskWarnYesNo ("HIDVOL_PROT_BKG_TASK_WARNING", hwndDlg) == IDYES))
{ {
bEnableBkgTask = TRUE; 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 // This the directory field. Make its background like normal edit
HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW); HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW);
::SelectObject(hdc, hbr); ::SelectObject(hdc, hbr);
return (BOOL) hbr; return (BOOL)(INT_PTR)hbr;
} }
} }
return 0; return 0;
@@ -4545,7 +4548,7 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
if (lw == IDC_CREATE) 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 dstDir[MAX_PATH + 1];
WCHAR srcPath[1024 + MAX_PATH + 1]; WCHAR srcPath[1024 + MAX_PATH + 1];
WCHAR dstPath[2*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)); copyWizard = IsButtonChecked (GetDlgItem (hwndDlg, IDC_COPY_WIZARD));
copyExpander = IsButtonChecked (GetDlgItem (hwndDlg, IDC_COPY_EXPANDER)); copyExpander = IsButtonChecked (GetDlgItem (hwndDlg, IDC_COPY_EXPANDER));
bExplore = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAVEL_OPEN_EXPLORER)); openExplorer = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAVEL_OPEN_EXPLORER));
bCacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAV_CACHE_PASSWORDS)); cacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAV_CACHE_PASSWORDS));
bIncludePimInCache = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PIM)); includePimInCache = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PIM));
bMountReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)); bMountReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY));
bAutoRun = !IsButtonChecked (GetDlgItem (hwndDlg, IDC_AUTORUN_DISABLE)); bAutoRun = !IsButtonChecked (GetDlgItem (hwndDlg, IDC_AUTORUN_DISABLE));
bAutoMount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_AUTORUN_MOUNT)); 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", StringCbPrintfW (autoMount, sizeof(autoMount), L"VeraCrypt\\VeraCrypt.exe /q background%s%s%s%s /m rm /v %s",
drive > 0 ? driveLetter : L"", drive > 0 ? driveLetter : L"",
bExplore ? L" /e" : L"", openExplorer ? L" /e" : L"",
bCacheInDriver ? (bIncludePimInCache? L" /c p" : L" /c y") : L"", cacheInDriver ? (includePimInCache? L" /c p" : L" /c y") : L"",
bMountReadOnly ? L" /m ro" : L"", bMountReadOnly ? L" /m ro" : L"",
volName); volName);
@@ -5161,7 +5164,7 @@ static int AskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int
// GUI actions // 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; BOOL status = FALSE;
wchar_t fileName[MAX_PATH]; wchar_t fileName[MAX_PATH];
@@ -5193,12 +5196,12 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim,
VolumePim = -1; VolumePim = -1;
} }
if (szFileName == NULL) if (szVolFileName == NULL)
{ {
GetVolumePath (hwndDlg, fileName, ARRAYSIZE (fileName)); GetVolumePath (hwndDlg, fileName, ARRAYSIZE (fileName));
} }
else else
StringCchCopyW (fileName, ARRAYSIZE (fileName), szFileName); StringCchCopyW (fileName, ARRAYSIZE (fileName), szVolFileName);
if (wcslen(fileName) == 0) if (wcslen(fileName) == 0)
{ {
@@ -5212,16 +5215,16 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim,
goto ret; goto ret;
} }
szFileName = fileName; szVolFileName = fileName;
if (IsMountedVolume (szFileName)) if (IsMountedVolume (szVolFileName))
{ {
Warning ("VOL_ALREADY_MOUNTED", hwndDlg); Warning ("VOL_ALREADY_MOUNTED", hwndDlg);
status = FALSE; status = FALSE;
goto ret; goto ret;
} }
if (!VolumePathExists (szFileName)) if (!VolumePathExists (szVolFileName))
{ {
if (!MultipleMountOperationInProgress) if (!MultipleMountOperationInProgress)
handleWin32Error (hwndDlg, SRC_POS); handleWin32Error (hwndDlg, SRC_POS);
@@ -5237,16 +5240,16 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim,
if (!bUseCmdVolumePassword) if (!bUseCmdVolumePassword)
{ {
// First try cached passwords and if they fail ask user for a new one // 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 keyfiles are enabled, test empty password first
if (!mounted && KeyFilesEnable && FirstKeyFile && bEffectiveTryEmptyPasswordWhenKeyfileUsed) if (!mounted && KeyFilesEnable && FirstKeyFile && bEffectiveTryEmptyPasswordWhenKeyfileUsed)
{ {
Password emptyPassword = {0}; 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)); 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 (!mounted && bEffectiveCacheDuringMultipleMount && MultipleMountOperationInProgress && VolumePassword.Length != 0)
{ {
// if no PIM specified for favorite, we use also the PIM of the previous volume alongside its password. // 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 (); 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) // Check for problematic file extensions (exe, dll, sys)
if (CheckFileExtension(szFileName)) if (CheckFileExtension(szVolFileName))
Warning ("EXE_FILE_EXTENSION_MOUNT_WARNING", hwndDlg); 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 GuiPkcs5 = EffectiveVolumePkcs5;
int GuiPim = EffectiveVolumePim; int GuiPim = EffectiveVolumePim;
StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szFileName); StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szVolFileName);
if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiPim, NULL, TRUE)) if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiPim, NULL, TRUE))
goto ret; goto ret;
@@ -5297,13 +5300,13 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim,
WaitCursor (); WaitCursor ();
if (KeyFilesEnable) 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 (); NormalCursor ();
// Check for problematic file extensions (exe, dll, sys) // 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); Warning ("EXE_FILE_EXTENSION_MOUNT_WARNING", hwndDlg);
if (!MultipleMountOperationInProgress) if (!MultipleMountOperationInProgress)
@@ -5591,7 +5594,7 @@ retry:
{ {
if (mountList.ulMountedDrives & (1 << i)) 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); SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL);
} }
} }
@@ -5683,11 +5686,11 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
vector <HostDevice> partitions = drive.Partitions; vector <HostDevice> partitions = drive.Partitions;
partitions.insert (partitions.begin(), drive); partitions.insert (partitions.begin(), drive);
foreach (const HostDevice &device, partitions) for (const HostDevice &device: partitions)
{ {
wchar_t szFileName[TC_MAX_PATH]; wchar_t szPartPath[TC_MAX_PATH];
StringCbCopyW (szFileName, sizeof (szFileName), device.Path.c_str()); StringCbCopyW (szPartPath, sizeof (szPartPath), device.Path.c_str());
BOOL mounted = IsMountedVolume (szFileName); BOOL mounted = IsMountedVolume (szPartPath);
// Skip other partitions of the disk if partition0 (whole disk) is mounted // Skip other partitions of the disk if partition0 (whole disk) is mounted
if (!device.IsPartition && mounted) if (!device.IsPartition && mounted)
@@ -5747,8 +5750,8 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
} }
// First try user password then cached passwords // First try user password then cached passwords
if ((mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, 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, szFileName, NULL, 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 // 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 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; bSysEncPwdChangeDlgMode = TRUE;
@@ -7680,7 +7686,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
reentry = true; reentry = true;
foreach (FavoriteVolume favorite, FavoritesOnArrivalMountRequired) for (FavoriteVolume favorite: FavoritesOnArrivalMountRequired)
{ {
if (favorite.UseVolumeID) if (favorite.UseVolumeID)
{ {
@@ -7730,7 +7736,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
continue; continue;
bool mountedAndNotDisconnected = false; bool mountedAndNotDisconnected = false;
foreach (FavoriteVolume mountedFavorite, FavoritesMountedOnArrivalStillConnected) for (FavoriteVolume mountedFavorite: FavoritesMountedOnArrivalStillConnected)
{ {
if (favorite.Path == mountedFavorite.Path) 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)) 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; 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); UnmountVolume (hwndDlg, m, TRUE);
WarningBalloon ("HOST_DEVICE_REMOVAL_DISMOUNT_WARN_TITLE", "HOST_DEVICE_REMOVAL_DISMOUNT_WARN", hwndDlg); 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; int nDosLinkCreated = -1, nStatus = ERR_OS_ERROR;
wchar_t szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH]; 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]; wchar_t szDosDevice[TC_MAX_PATH];
void *dev = INVALID_HANDLE_VALUE; void *dev = INVALID_HANDLE_VALUE;
DWORD dwError; DWORD dwError;
@@ -11270,14 +11276,14 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume)
} }
/* Select backup file */ /* Select backup file */
if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, FALSE)) if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szHeaderFileName, bHistory, FALSE))
{ {
nStatus = ERR_SUCCESS; nStatus = ERR_SUCCESS;
goto ret; goto ret;
} }
/* Open the backup file */ /* 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) if (fBackup == INVALID_HANDLE_VALUE)
{ {
nStatus = ERR_OS_ERROR; nStatus = ERR_OS_ERROR;
@@ -11413,7 +11419,6 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume)
goto error; goto error;
} }
LARGE_INTEGER headerOffset;
LARGE_INTEGER headerBackupOffset; LARGE_INTEGER headerBackupOffset;
bool legacyBackup; bool legacyBackup;
int headerOffsetBackupFile; 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 enableExtendedIOCTL = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_EXTENDED_IOCTL_SUPPORT);
BOOL allowTrimCommand = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD); BOOL allowTrimCommand = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD);
BOOL allowWindowsDefrag = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG); 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 try
{ {
@@ -11800,9 +11805,9 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption); SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption);
BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig(); BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig();
if(originalDisableMemoryProtection != bDisableMemoryProtection) if(originalDisableMemoryProtection != disableMemoryProtection)
rebootRequired = true; rebootRequired = true;
SetMemoryProtectionConfig (!bDisableMemoryProtection); SetMemoryProtectionConfig (!disableMemoryProtection);
DWORD bytesReturned; DWORD bytesReturned;
if (!DeviceIoControl (hDriver, TC_IOCTL_REREAD_DRIVER_CONFIG, NULL, 0, NULL, 0, &bytesReturned, NULL)) 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: case WM_INITDIALOG:
{ {
BootEncryptionStatus BootEncStatus = BootEncObj->GetStatus(); BootEncryptionStatus bootEncStatus = BootEncObj->GetStatus();
if (!BootEncStatus.DriveMounted) if (!bootEncStatus.DriveMounted)
{ {
Warning ("SYS_DRIVE_NOT_ENCRYPTED", hwndDlg); Warning ("SYS_DRIVE_NOT_ENCRYPTED", hwndDlg);
EndDialog (hwndDlg, IDCANCEL); EndDialog (hwndDlg, IDCANCEL);

View File

@@ -1646,7 +1646,6 @@ BOOL DoDriverUnload (HWND hwndDlg)
if (hDriver != INVALID_HANDLE_VALUE) if (hDriver != INVALID_HANDLE_VALUE)
{ {
MOUNT_LIST_STRUCT driver;
LONG driverVersion = VERSION_NUM; LONG driverVersion = VERSION_NUM;
int refCount; int refCount;
DWORD dwResult; DWORD dwResult;
@@ -1895,7 +1894,7 @@ error:
return bOK; 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 szLinkDir[TC_MAX_PATH], szDir[TC_MAX_PATH];
wchar_t szTmp[TC_MAX_PATH], szTmp2[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; HRESULT hOle;
int x; int x;
if (bProgGroup == FALSE && bDesktopIcon == FALSE) if (bProgGroup == FALSE && bUseDesktopIcon == FALSE)
return TRUE; return TRUE;
hOle = OleInitialize (NULL); hOle = OleInitialize (NULL);
@@ -1982,7 +1981,7 @@ BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL
StatDeleteFile (szTmp2, FALSE); StatDeleteFile (szTmp2, FALSE);
} }
if (bDesktopIcon) if (bUseDesktopIcon)
{ {
StringCbCopyW (szDir, sizeof(szDir), szDestDir); StringCbCopyW (szDir, sizeof(szDir), szDestDir);
x = wcslen (szDestDir); x = wcslen (szDestDir);

View File

@@ -2654,7 +2654,7 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostInstall(MSIHANDLE hInstaller)
} }
// remvove legacy files that are not needed anymore // 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); StatDeleteFile (szLegacyFiles [i], TRUE);
} }