VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2024-11-15 00:41:07 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2024-11-15 00:41:07 +0100
commit43ad4f93eb2c64bb2c278cdbefdfe0250293868e (patch)
tree838b3dd1d2ff69c3e7d162d0347d08435c745cb5 /src/Mount
parent117d8dd046fcfc8e85c8aadf96556eb9f445695c (diff)
downloadVeraCrypt-43ad4f93eb2c64bb2c278cdbefdfe0250293868e.tar.gz
VeraCrypt-43ad4f93eb2c64bb2c278cdbefdfe0250293868e.zip
Windows: Fix various compiler warnings
Diffstat (limited to 'src/Mount')
-rw-r--r--src/Mount/Favorites.cpp10
-rw-r--r--src/Mount/Mount.c177
2 files changed, 96 insertions, 91 deletions
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
@@ -425,67 +425,67 @@ namespace VeraCrypt
static bool reentry = false;
if (reentry)
break;
reentry = true;
if (SelectedItem != -1)
{
SetFavoriteVolume (hwndDlg, Favorites[SelectedItem], SystemFavoritesMode);
FillListControlSubItems (FavoriteListControl, SelectedItem, Favorites[SelectedItem]);
}
SelectedItem = ListView_GetNextItem (GetDlgItem (hwndDlg, IDC_FAVORITE_VOLUMES_LIST), -1, LVIS_SELECTED);
if (SelectedItem != -1)
SetControls (hwndDlg, Favorites[SelectedItem], SystemFavoritesMode);
else
SetControls (hwndDlg, FavoriteVolume(), SystemFavoritesMode, false);
reentry = false;
return 1;
}
break;
case WM_CLOSE:
EndDialog (hwndDlg, IDCLOSE);
return 1;
case WM_CTLCOLORSTATIC:
{
HDC hdc = (HDC) wParam;
- HWND hw = (HWND) lParam;
- if (hw == GetDlgItem(hwndDlg, IDC_FAVORITE_VOLUME_ID))
+ HWND hwnd = (HWND) lParam;
+ if (hwnd == GetDlgItem(hwndDlg, IDC_FAVORITE_VOLUME_ID))
{
// This the favorite ID field. Make its background like normal edit
HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW);
::SelectObject(hdc, hbr);
- return (BOOL) hbr;
+ return (BOOL)(INT_PTR)hbr;
}
}
break;
}
return 0;
}
static void FillFavoriteVolumesMenu ()
{
while (DeleteMenu (FavoriteVolumesMenu, 7, MF_BYPOSITION)) { }
if (FavoriteVolumes.empty())
return;
AppendMenu (FavoriteVolumesMenu, MF_SEPARATOR, 0, L"");
int i = 0;
foreach (const FavoriteVolume &favorite, FavoriteVolumes)
{
UINT flags = MF_STRING;
if (favorite.DisconnectedDevice)
flags |= MF_GRAYED;
wstring menuText = favorite.Path;
if (favorite.DisconnectedDevice)
menuText = favorite.Label.empty() ? wstring (L"(") + GetString ("FAVORITE_DISCONNECTED_DEV") + L")" : L"";
@@ -704,71 +704,71 @@ namespace VeraCrypt
)
{
favorite.Pkcs5 = -1;
}
if (!systemFavorites && favorite.UseVolumeID)
bVolumeIdInUse = true;
favorites.push_back (favorite);
xml++;
}
if (!systemFavorites)
{
if (bVolumeIdInUse && !DisablePeriodicDeviceListUpdate)
NeedPeriodicDeviceListUpdate = TRUE;
else
NeedPeriodicDeviceListUpdate = FALSE;
}
free (favoritesXml);
}
static void OnFavoriteVolumesUpdated ()
{
FillFavoriteVolumesMenu();
FavoritesOnArrivalMountRequired.clear();
- foreach (const FavoriteVolume favorite, FavoriteVolumes)
+ for (const FavoriteVolume favorite: FavoriteVolumes)
{
if (favorite.MountOnArrival)
{
FavoritesOnArrivalMountRequired.push_back (favorite);
if (IsMountedVolume (favorite.Path.c_str()))
{
bool present = false;
- foreach (const FavoriteVolume favoriteConnected, FavoritesMountedOnArrivalStillConnected)
+ for (const FavoriteVolume favoriteConnected: FavoritesMountedOnArrivalStillConnected)
{
if (favorite.Path == favoriteConnected.Path)
{
present = true;
break;
}
}
if (!present)
FavoritesMountedOnArrivalStillConnected.push_back (favorite);
}
}
}
}
BOOL OrganizeFavoriteVolumes (HWND hwndDlg, bool systemFavorites, const FavoriteVolume &newFavorite)
{
FavoriteVolumesDlgProcArguments args;
args.SystemFavorites = systemFavorites;
if (!newFavorite.Path.empty())
{
args.AddFavoriteVolume = true;
args.NewFavoriteVolume = newFavorite;
}
else
args.AddFavoriteVolume = false;
return DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_FAVORITE_VOLUMES), hwndDlg, (DLGPROC) FavoriteVolumesDlgProc, (LPARAM) &args) == IDOK;
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
@@ -148,61 +148,61 @@ BOOL CloseSecurityTokenSessionsAfterMount = FALSE;
BOOL Quit = FALSE; /* Exit after processing command line */
BOOL ComServerMode = FALSE;
BOOL ServiceMode = FALSE;
BOOL UsePreferences = TRUE;
BOOL bSystemIsGPT = FALSE;
wchar_t szDefaultRescueDiskName[TC_MAX_PATH+1];
wchar_t szRescueDiskExtension[4];
int HiddenSysLeakProtectionNotificationStatus = TC_HIDDEN_OS_READ_ONLY_NOTIF_MODE_NONE;
int MaxVolumeIdleTime = -120;
int nCurrentShowType = 0; /* current display mode, mount, unmount etc */
int nSelectedDriveIndex = -1; /* Item number of selected drive */
int cmdUnmountDrive = -2; /* Volume drive letter to unmount (-1 = all) */
Password VolumePassword; /* Password used for mounting volumes */
Password CmdVolumePassword; /* Password passed from command line */
int VolumePkcs5 = 0;
int CmdVolumePkcs5 = 0;
int VolumePim = -1;
int CmdVolumePim = -1;
int DefaultVolumePkcs5 = 0;
BOOL CmdVolumePasswordValid = FALSE;
MountOptions CmdMountOptions;
BOOL CmdMountOptionsValid = FALSE;
MountOptions mountOptions;
MountOptions defaultMountOptions;
KeyFile *FirstCmdKeyFile = NULL;
HBITMAP hbmLogoBitmapRescaled = NULL;
-wchar_t OrigKeyboardLayout [8+1] = L"00000409";
+wchar_t OrigKeyboardLayout [KL_NAMELENGTH] = L"00000409";
BOOL bKeyboardLayoutChanged = FALSE; /* TRUE if the keyboard layout was changed to the standard US keyboard layout (from any other layout). */
BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informed that it is not possible to type characters by pressing keys while the right Alt key is held down. */
static KeyFilesDlgParam hidVolProtKeyFilesParam = {0};
static MOUNT_LIST_STRUCT LastKnownMountList = {0};
VOLUME_NOTIFICATIONS_LIST VolumeNotificationsList;
static DWORD LastKnownLogicalDrives;
static volatile LONG FavoriteMountOnGoing = 0;
static HANDLE TaskBarIconMutex = NULL;
static BOOL MainWindowHidden = FALSE;
static int pwdChangeDlgMode = PCDM_CHANGE_PASSWORD;
static int bSysEncPwdChangeDlgMode = FALSE;
static int bPrebootPasswordDlgMode = FALSE;
static int NoCmdLineArgs;
static BOOL CmdLineVolumeSpecified;
static int LastDriveListVolumeColumnWidth;
static BOOL ExitMailSlotSpecified = FALSE;
static TCHAR ExitMailSlotName[MAX_PATH];
// WTS handling
static HMODULE hWtsLib = NULL;
static WTSREGISTERSESSIONNOTIFICATION fnWtsRegisterSessionNotification = NULL;
static WTSUNREGISTERSESSIONNOTIFICATION fnWtsUnRegisterSessionNotification = NULL;
// Used to opt-in to receive notification about power events.
// This is mandatory to support Windows 10 Modern Standby and Windows 8.1 Connected Standby power model.
// https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/prepare-software-for-modern-standby
// https://docs.microsoft.com/en-us/windows/win32/w8cookbook/desktop-activity-moderator?redirectedfrom=MSDN
@@ -1693,61 +1693,61 @@ static void LaunchVolExpander (HWND hwndDlg)
{
wchar_t t[TC_MAX_PATH + TC_MAX_PATH] = {L'"',0};
wchar_t *tmp;
GetModuleFileName (NULL, t+1, ARRAYSIZE(t)-1);
tmp = wcsrchr (t, L'\\');
if (tmp)
{
wchar_t expanderExeName[64];
wchar_t* suffix = NULL;
StringCbCopyW (expanderExeName, sizeof (expanderExeName), L"\\VeraCryptExpander");
// check if there is a suffix in VeraCrypt file name
// in order to use the same for "VeraCrypt Format"
suffix = wcsrchr (tmp + 1, L'-');
if (suffix)
{
StringCbCatW (expanderExeName, sizeof (expanderExeName), suffix);
StringCbCatW (expanderExeName, sizeof (expanderExeName), L"\"");
}
else
StringCbCatW (expanderExeName, sizeof (expanderExeName), L".exe\"");
*tmp = 0;
StringCbCatW (t, sizeof(t), expanderExeName);
if (!FileExists(t))
Error ("VOL_EXPANDER_NOT_FOUND", hwndDlg); // Display a user-friendly error message and advise what to do
- else if (((int)ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", t, NULL, NULL, SW_SHOW)) <= 32)
+ else if (((INT_PTR)ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", t, NULL, NULL, SW_SHOW)) <= 32)
{
handleWin32Error (hwndDlg, SRC_POS);
}
}
}
// Fills drive list
// drive>0 = update only the corresponding drive subitems
void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
{
// Remember the top-most visible item
int lastTopMostVisibleItem = (!Silent && hTree)? ListView_GetTopIndex (hTree) : 0;
wchar_t *szDriveLetters[]=
{L"A:", L"B:", L"C:", L"D:",
L"E:", L"F:", L"G:", L"H:", L"I:", L"J:", L"K:",
L"L:", L"M:", L"N:", L"O:", L"P:", L"Q:", L"R:",
L"S:", L"T:", L"U:", L"V:", L"W:", L"X:", L"Y:",
L"Z:"};
DWORD dwResult;
BOOL bResult;
DWORD dwUsedDrives;
MOUNT_LIST_STRUCT driver;
VOLUME_PROPERTIES_STRUCT propSysEnc;
wchar_t sysDriveLetter = 0;
BOOL bSysEnc = FALSE;
BOOL bWholeSysDriveEncryption = FALSE;
@@ -2018,66 +2018,66 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive)
ws = GetString (IsHiddenOSRunning() ? "HIDDEN" : "SYSTEM_VOLUME_TYPE_ADJECTIVE");
VolumeNotificationsList.bHidVolDamagePrevReported[i] = FALSE;
ListSubItemSet (hTree, listItem.iItem, 4, ws);
}
else
{
switch (driver.volumeType[i])
{
case PROP_VOL_TYPE_NORMAL:
ws = GetString ("NORMAL");
break;
case PROP_VOL_TYPE_HIDDEN:
ws = GetString ("HIDDEN");
break;
case PROP_VOL_TYPE_OUTER:
ws = GetString ("OUTER"); // Normal/outer volume (hidden volume protected)
break;
case PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED:
ws = GetString ("OUTER_VOL_WRITE_PREVENTED"); // Normal/outer volume (hidden volume protected AND write denied)
break;
default:
ws = L"?";
}
ListSubItemSet (hTree, listItem.iItem, 4, ws);
if (driver.volumeType[i] == PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED) // Normal/outer volume (hidden volume protected AND write denied)
{
if (!VolumeNotificationsList.bHidVolDamagePrevReported[i])
{
- wchar_t szTmp[4096];
+ wchar_t szMsgTmp[4096];
VolumeNotificationsList.bHidVolDamagePrevReported[i] = TRUE;
- StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), i+L'A');
+ StringCbPrintfW (szMsgTmp, sizeof(szMsgTmp), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), i+L'A');
SetForegroundWindow (GetParent(hTree));
- MessageBoxW (GetParent(hTree), szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
+ MessageBoxW (GetParent(hTree), szMsgTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
}
}
else
{
VolumeNotificationsList.bHidVolDamagePrevReported[i] = FALSE;
}
}
}
else
{
VolumeNotificationsList.bHidVolDamagePrevReported[i] = FALSE;
if (!(dwUsedDrives & 1 << i))
{
if(drive > 0 && drive != HIWORD (GetSelectedLong (hTree)))
{
item++;
continue;
}
memset(&listItem,0,sizeof(listItem));
listItem.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
listItem.iImage = 0;
listItem.iItem = item++;
listItem.pszText = szDriveLetters[i];
listItem.lParam = MAKELONG (TC_MLIST_ITEM_FREE, i + 'A');
if(drive == 0)
ListView_InsertItem (hTree, &listItem);
@@ -2412,187 +2412,187 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
SetCheckBox (hwndDlg, IDC_ENABLE_KEYFILES, TRUE);
EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES), TRUE);
EnableWindow (GetDlgItem (hwndDlg, IDC_ENABLE_KEYFILES), TRUE);
EnableWindow (GetDlgItem (hwndDlg, IDC_PASSWORD), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_VERIFY), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_PIM), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_PIM), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_PIM_HELP), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_NEW_PIM_ENABLE), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_ENABLE_NEW_KEYFILES), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_NEW_KEYFILES), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_NEW_PASSWORD), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_CONFIRM_PASSWORD), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_NEW_PKCS5_PRF), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), FALSE);
break;
case PCDM_CHANGE_PASSWORD:
default:
// NOP
break;
};
if (bSysEncPwdChangeDlgMode)
{
ToBootPwdField (hwndDlg, IDC_PASSWORD);
ToBootPwdField (hwndDlg, IDC_VERIFY);
ToBootPwdField (hwndDlg, IDC_OLD_PASSWORD);
- if ((DWORD) GetKeyboardLayout (NULL) != 0x00000409 && (DWORD) GetKeyboardLayout (NULL) != 0x04090409)
+ if ((DWORD)(DWORD_PTR)GetKeyboardLayout (NULL) != 0x00000409 && (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL) != 0x04090409)
{
- DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
+ DWORD keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
EndDialog (hwndDlg, IDCANCEL);
return 0;
}
bKeyboardLayoutChanged = TRUE;
}
/* for system encryption, we can't change the PRF */
EnableWindow (GetDlgItem (hwndDlg, IDT_PKCS5_PRF), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDT_NEW_PKCS5_PRF), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_PKCS5_OLD_PRF_ID), FALSE);
if (SetTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD, TIMER_INTERVAL_KEYB_LAYOUT_GUARD, NULL) == 0)
{
Error ("CANNOT_SET_TIMER", hwndDlg);
EndDialog (hwndDlg, IDCANCEL);
return 0;
}
newKeyFilesParam.EnableKeyFiles = FALSE;
KeyFilesEnable = FALSE;
SetCheckBox (hwndDlg, IDC_ENABLE_KEYFILES, FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_ENABLE_KEYFILES), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_ENABLE_NEW_KEYFILES), FALSE);
}
CheckCapsLock (hwndDlg, FALSE);
if (!bSecureDesktopOngoing)
{
PasswordEditDropTarget* pTarget = new PasswordEditDropTarget ();
if (pTarget->Register (hwndDlg))
{
SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) pTarget);
}
else
delete pTarget;
}
return 0;
}
case WM_TIMER:
switch (wParam)
{
case TIMER_ID_KEYB_LAYOUT_GUARD:
if (bSysEncPwdChangeDlgMode)
{
- DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL);
+ DWORD keybLayout = (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL);
/* Watch the keyboard layout */
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
// Keyboard layout is not standard US
// Attempt to wipe passwords stored in the input field buffers
wchar_t tmp[MAX_PASSWORD+1];
wmemset (tmp, L'X', MAX_PASSWORD);
tmp [MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_VERIFY), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), L"");
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
SetWindowText (GetDlgItem (hwndDlg, IDC_VERIFY), L"");
- keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
+ keybLayout = (DWORD)(DWORD_PTR)LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
EndDialog (hwndDlg, IDCANCEL);
return 1;
}
bKeyboardLayoutChanged = TRUE;
wchar_t szTmp [4096];
StringCbCopyW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_CHANGE_PREVENTED"));
StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION"));
MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
}
/* Watch the right Alt key (which is used to enter various characters on non-US keyboards) */
if (bKeyboardLayoutChanged && !bKeybLayoutAltKeyWarningShown)
{
if (GetAsyncKeyState (VK_RMENU) < 0)
{
bKeybLayoutAltKeyWarningShown = TRUE;
wchar_t szTmp [4096];
StringCbCopyW (szTmp, sizeof(szTmp), GetString ("ALT_KEY_CHARS_NOT_FOR_SYS_ENCRYPTION"));
StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION"));
MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONINFORMATION | MB_SETFOREGROUND | MB_TOPMOST);
}
}
}
return 1;
}
return 0;
case WM_CTLCOLORSTATIC:
{
if (PimValueChangedWarning && ((HWND)lParam == GetDlgItem(hwndDlg, IDC_PIM_HELP)) )
{
// we're about to draw the static
// set the text colour in (HDC)lParam
SetBkMode((HDC)wParam,TRANSPARENT);
SetTextColor((HDC)wParam, RGB(255,0,0));
// NOTE: per documentation as pointed out by selbie, GetSolidBrush would leak a GDI handle.
- return (BOOL)GetSysColorBrush(COLOR_MENU);
+ return (BOOL)(INT_PTR)GetSysColorBrush(COLOR_MENU);
}
}
return 0;
case WM_COMMAND:
if (lw == IDCANCEL)
{
// Attempt to wipe passwords stored in the input field buffers
wchar_t tmp[MAX_PASSWORD+1];
wmemset (tmp, L'X', MAX_PASSWORD);
tmp[MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_OLD_PASSWORD), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_VERIFY), tmp);
RestoreDefaultKeyFilesParam ();
EndDialog (hwndDlg, IDCANCEL);
return 1;
}
if (hw == EN_CHANGE)
{
PasswordChangeEnable (hwndDlg, IDOK,
IDC_OLD_PASSWORD,
KeyFilesEnable && FirstKeyFile != NULL,
IDC_PASSWORD, IDC_VERIFY,
newKeyFilesParam.EnableKeyFiles && newKeyFilesParam.FirstKeyFile != NULL);
if ((lw == IDC_OLD_PIM) && IsWindowEnabled (GetDlgItem (hwndDlg, IDC_PIM)))
{
@@ -2724,61 +2724,61 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
newKeyFilesParam.EnableKeyFiles && newKeyFilesParam.FirstKeyFile != NULL);
return 1;
}
if (lw == IDC_ENABLE_NEW_KEYFILES)
{
newKeyFilesParam.EnableKeyFiles = GetCheckBox (hwndDlg, IDC_ENABLE_NEW_KEYFILES);
PasswordChangeEnable (hwndDlg, IDOK,
IDC_OLD_PASSWORD,
KeyFilesEnable && FirstKeyFile != NULL,
IDC_PASSWORD, IDC_VERIFY,
newKeyFilesParam.EnableKeyFiles && newKeyFilesParam.FirstKeyFile != NULL);
return 1;
}
if (hw == CBN_SELCHANGE)
{
switch (lw)
{
case IDC_PKCS5_PRF_ID:
if (bSysEncPwdChangeDlgMode)
{
int new_hash_algo_id = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA,
SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
if (new_hash_algo_id != 0 && !bSystemIsGPT && !HashForSystemEncryption(new_hash_algo_id))
{
- int new_hash_algo_id = DEFAULT_HASH_ALGORITHM_BOOT;
+ new_hash_algo_id = DEFAULT_HASH_ALGORITHM_BOOT;
Info ("ALGO_NOT_SUPPORTED_FOR_SYS_ENCRYPTION", hwndDlg);
SelectAlgo (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), &new_hash_algo_id);
}
}
break;
}
return 1;
}
if (lw == IDC_SHOW_PASSWORD_CHPWD_ORI)
{
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_ORI, IDC_OLD_PASSWORD, IDC_OLD_PIM);
return 1;
}
if (lw == IDC_SHOW_PASSWORD_CHPWD_NEW)
{
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW, IDC_PASSWORD, IDC_VERIFY);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD_CHPWD_NEW, IDC_PIM, 0);
return 1;
}
if (lw == IDOK)
{
HWND hParent = GetParent (hwndDlg);
Password oldPassword;
Password newPassword;
WipeAlgorithmId headerWiperMode = (WipeAlgorithmId) SendMessage (
GetDlgItem (hwndDlg, IDC_WIPE_MODE),
@@ -3088,132 +3088,135 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
/* Repopulate the PRF algorithms list with algorithms that support system encryption */
HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
int i, defaultPrfIndex = 0, nIndex = (int) SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
{
if (bSystemIsGPT || HashForSystemEncryption(i))
{
nIndex = (int) SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
if (*pkcs5 && (*pkcs5 == i))
defaultPrfIndex = nIndex;
}
}
/* make autodetection the default unless a specific PRF was specified in the command line */
SendMessage (hComboBox, CB_SETCURSEL, defaultPrfIndex, 0);
ToBootPwdField (hwndDlg, IDC_PASSWORD);
// Attempt to wipe the password stored in the input field buffer
wchar_t tmp[MAX_PASSWORD+1];
wmemset (tmp, L'X', MAX_PASSWORD);
tmp [MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
- StringCbPrintfW (OrigKeyboardLayout, sizeof(OrigKeyboardLayout),L"%08X", (DWORD) GetKeyboardLayout (NULL) & 0xFFFF);
+ if (!GetKeyboardLayoutNameW(OrigKeyboardLayout))
+ {
+ StringCbPrintfW(OrigKeyboardLayout, sizeof(OrigKeyboardLayout), L"%08X", (DWORD)(DWORD_PTR)GetKeyboardLayout(NULL) & 0xFFFF);
+ }
- DWORD keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
+ DWORD keybLayout = (DWORD) (DWORD_PTR) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
/* don't be too agressive on enforcing an English keyboard layout. E.g. on WindowsPE this call fails and
* then the user can only mount a system encrypted device using the command line by passing the password as a parameter
* (which might not be obvious for not so advanced users).
*
* Now, we informed the user that English keyboard is required, if it is not available the volume can just not be mounted.
* There should be no other drawback (as e.g., on the change password dialog, when you might change to a password which won't
* work on the pre-start environment.
*/
}
else if (SetTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD, TIMER_INTERVAL_KEYB_LAYOUT_GUARD, NULL) == 0)
{
Error ("CANNOT_SET_TIMER", hwndDlg);
EndDialog (hwndDlg, IDCANCEL);
return 1;
}
if (GetCheckBox (hwndDlg, IDC_SHOW_PASSWORD))
{
// simulate hiding password
SetCheckBox (hwndDlg, IDC_SHOW_PASSWORD, FALSE);
HandleShowPasswordFieldAction (hwndDlg, IDC_SHOW_PASSWORD, IDC_PASSWORD, IDC_PIM);
}
SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE), FALSE);
EnableWindow (GetDlgItem (hwndDlg, IDC_KEY_FILES), FALSE);
SetPim (hwndDlg, IDC_PIM, *pim);
bPrebootPasswordDlgMode = TRUE;
}
return 1;
case WM_TIMER:
switch (wParam)
{
case TIMER_ID_CHECK_FOREGROUND:
if (hwndDlg != ::GetForegroundWindow ())
{
// we are not foreground after 500ms of creating the dialog
// try to force it for be foreground
BringToForeground (hwndDlg);
SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD));
}
// one shot timer: stop it
KillTimer (hwndDlg, TIMER_ID_CHECK_FOREGROUND);
return 0;
case TIMER_ID_KEYB_LAYOUT_GUARD:
if (bPrebootPasswordDlgMode)
{
- DWORD keybLayout = (DWORD) GetKeyboardLayout (NULL);
+ DWORD keybLayout = (DWORD)(DWORD_PTR)GetKeyboardLayout (NULL);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
// Keyboard layout is not standard US
// Attempt to wipe the password stored in the input field buffer
wchar_t tmp[MAX_PASSWORD+1];
wmemset (tmp, L'X', MAX_PASSWORD);
tmp [MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), tmp);
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD), L"");
- keybLayout = (DWORD) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
+ keybLayout = (DWORD)(DWORD_PTR) LoadKeyboardLayout (L"00000409", KLF_ACTIVATE);
if (keybLayout != 0x00000409 && keybLayout != 0x04090409)
{
KillTimer (hwndDlg, TIMER_ID_KEYB_LAYOUT_GUARD);
Error ("CANT_CHANGE_KEYB_LAYOUT_FOR_SYS_ENCRYPTION", hwndDlg);
EndDialog (hwndDlg, IDCANCEL);
return 1;
}
wchar_t szTmp [4096];
StringCbCopyW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_CHANGE_PREVENTED"));
StringCbCatW (szTmp, sizeof(szTmp), L"\n\n");
StringCbCatW (szTmp, sizeof(szTmp), GetString ("KEYB_LAYOUT_SYS_ENC_EXPLANATION"));
MessageBoxW (MainDlg, szTmp, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST);
}
}
return 1;
}
return 0;
case WM_COMMAND:
if (lw == IDC_MOUNT_OPTIONS)
{
/* Use default PRF specified by the user if any */
if (mountOptions.ProtectedHidVolPkcs5Prf == 0)
mountOptions.ProtectedHidVolPkcs5Prf = *pkcs5;
if (mountOptions.ProtectedHidVolPim == 0)
mountOptions.ProtectedHidVolPim = *pim;
DialogBoxParamW (hInst,
@@ -3612,153 +3615,153 @@ BOOL CALLBACK PreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
AppendMenuW (popup, MF_STRING, IDM_TOKEN_PREFERENCES, GetString ("IDM_TOKEN_PREFERENCES"));
RECT rect;
GetWindowRect (GetDlgItem (hwndDlg, IDC_MORE_SETTINGS), &rect);
int menuItem = TrackPopupMenu (popup, TPM_RETURNCMD | TPM_LEFTBUTTON, rect.left + 2, rect.top + 2, 0, hwndDlg, NULL);
DestroyMenu (popup);
SendMessage (MainDlg, WM_COMMAND, menuItem, (LPARAM) hwndDlg);
return 1;
}
else
return 0;
}
if (HIWORD (wParam) == BN_CLICKED)
{
PreferencesDlgEnableButtons (hwndDlg);
return 1;
}
return 0;
}
return 0;
}
BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- static MountOptions *mountOptions;
+ static MountOptions *pMountOptions;
WORD lw = LOWORD (wParam);
switch (msg)
{
case WM_INITDIALOG:
{
BOOL protect;
- mountOptions = (MountOptions *) lParam;
+ pMountOptions = (MountOptions *) lParam;
LocalizeDialog (hwndDlg, "IDD_MOUNT_OPTIONS");
SendDlgItemMessage (hwndDlg, IDC_MOUNT_READONLY, BM_SETCHECK,
- mountOptions->ReadOnly ? BST_CHECKED : BST_UNCHECKED, 0);
+ pMountOptions->ReadOnly ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage (hwndDlg, IDC_MOUNT_REMOVABLE, BM_SETCHECK,
- mountOptions->Removable ? BST_CHECKED : BST_UNCHECKED, 0);
+ pMountOptions->Removable ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage (hwndDlg, IDC_DISABLE_MOUNT_MANAGER, BM_SETCHECK,
- mountOptions->DisableMountManager ? BST_CHECKED : BST_UNCHECKED, 0);
+ pMountOptions->DisableMountManager ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage (hwndDlg, IDC_PROTECT_HIDDEN_VOL, BM_SETCHECK,
- mountOptions->ProtectHiddenVolume ? BST_CHECKED : BST_UNCHECKED, 0);
+ pMountOptions->ProtectHiddenVolume ? BST_CHECKED : BST_UNCHECKED, 0);
- mountOptions->PartitionInInactiveSysEncScope = bPrebootPasswordDlgMode;
+ pMountOptions->PartitionInInactiveSysEncScope = bPrebootPasswordDlgMode;
SendDlgItemMessage (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA, BM_SETCHECK,
bPrebootPasswordDlgMode ? BST_CHECKED : BST_UNCHECKED, 0);
SendDlgItemMessage (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK, BM_SETCHECK,
- mountOptions->UseBackupHeader ? BST_CHECKED : BST_UNCHECKED, 0);
+ pMountOptions->UseBackupHeader ? BST_CHECKED : BST_UNCHECKED, 0);
EnableWindow (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA), !bPrebootPasswordDlgMode);
- SetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, mountOptions->Label);
+ SetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, pMountOptions->Label);
SendDlgItemMessage (hwndDlg, IDC_VOLUME_LABEL, EM_LIMITTEXT, 32, 0); // 32 is the maximum possible length for a drive label in Windows
protect = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER));
EnableWindow (GetDlgItem (hwndDlg, IDC_VOLUME_LABEL), !protect);
EnableWindow (GetDlgItem (hwndDlg, IDT_VOLUME_LABEL), !protect);
/* Add PRF algorithm list for hidden volume password */
HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
int i, nSelectedIndex = 0, nIndex = (int) SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
{
nIndex = (int) SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
/* if a PRF was selected previously, select it */
- if (i == mountOptions->ProtectedHidVolPkcs5Prf)
+ if (i == pMountOptions->ProtectedHidVolPkcs5Prf)
nSelectedIndex = nIndex;
}
SendMessage (hComboBox, CB_SETCURSEL, nSelectedIndex, 0);
protect = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL));
EnableWindow (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL), !IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)));
EnableWindow (GetDlgItem (hwndDlg, IDT_HIDDEN_VOL_PROTECTION), !IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)));
EnableWindow (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), protect);
EnableWindow (GetDlgItem (hwndDlg, IDC_SHOW_PASSWORD_MO), protect);
EnableWindow (GetDlgItem (hwndDlg, IDT_HIDDEN_PROT_PASSWD), protect);
EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_HIDVOL_PROT), protect);
EnableWindow (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE_HIDVOL_PROT), protect);
EnableWindow (GetDlgItem (hwndDlg, IDT_PKCS5_PRF), protect);
EnableWindow (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), protect);
EnableWindow (GetDlgItem (hwndDlg, IDT_PIM), protect);
EnableWindow (GetDlgItem (hwndDlg, IDC_PIM), protect);
EnableWindow (GetDlgItem (hwndDlg, IDC_PIM_HELP), protect);
EnableWindow (GetDlgItem (hwndDlg, IDC_PIM_ENABLE), protect);
SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE_HIDVOL_PROT, hidVolProtKeyFilesParam.EnableKeyFiles);
ToNormalPwdField (hwndDlg, IDC_PASSWORD_PROT_HIDVOL);
SendDlgItemMessage (hwndDlg, IDC_PIM, EM_LIMITTEXT, MAX_PIM, 0);
- if (mountOptions->ProtectedHidVolPassword.Length > 0)
+ if (pMountOptions->ProtectedHidVolPassword.Length > 0)
{
wchar_t szTmp[MAX_PASSWORD + 1];
- if (0 == MultiByteToWideChar (CP_UTF8, 0, (LPSTR) mountOptions->ProtectedHidVolPassword.Text, -1, szTmp, MAX_PASSWORD + 1))
+ if (0 == MultiByteToWideChar (CP_UTF8, 0, (LPSTR) pMountOptions->ProtectedHidVolPassword.Text, -1, szTmp, MAX_PASSWORD + 1))
szTmp [0] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), szTmp);
burn (szTmp, sizeof (szTmp));
}
- SetPim (hwndDlg, IDC_PIM, mountOptions->ProtectedHidVolPim);
+ SetPim (hwndDlg, IDC_PIM, pMountOptions->ProtectedHidVolPim);
/* make PIM field visible if a PIM value has been explicitely specified */
- if (mountOptions->ProtectedHidVolPim > 0)
+ if (pMountOptions->ProtectedHidVolPim > 0)
{
SetCheckBox (hwndDlg, IDC_PIM_ENABLE, TRUE);
ShowWindow (GetDlgItem (hwndDlg, IDC_PIM_ENABLE), SW_HIDE);
ShowWindow (GetDlgItem( hwndDlg, IDT_PIM), SW_SHOW);
ShowWindow (GetDlgItem( hwndDlg, IDC_PIM), SW_SHOW);
ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_HELP), SW_SHOW);
}
ToHyperlink (hwndDlg, IDC_LINK_HIDVOL_PROTECTION_INFO);
if (!bSecureDesktopOngoing)
{
PasswordEditDropTarget* pTarget = new PasswordEditDropTarget ();
if (pTarget->Register (hwndDlg))
{
SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) pTarget);
}
else
delete pTarget;
}
}
return 0;
case WM_CONTEXTMENU:
{
RECT buttonRect;
GetWindowRect (GetDlgItem (hwndDlg, IDC_KEYFILES_HIDVOL_PROT), &buttonRect);
if (IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL))
@@ -3808,90 +3811,90 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
ShowWindow (GetDlgItem( hwndDlg, IDT_PIM), SW_SHOW);
ShowWindow (GetDlgItem( hwndDlg, IDC_PIM), SW_SHOW);
ShowWindow (GetDlgItem( hwndDlg, IDC_PIM_HELP), SW_SHOW);
SetFocus (GetDlgItem (hwndDlg, IDC_PIM));
return 1;
}
if (lw == IDC_LINK_HIDVOL_PROTECTION_INFO)
{
Applink ("hiddenvolprotection");
}
if (lw == IDCANCEL)
{
wchar_t tmp[MAX_PASSWORD+1];
// Cleanup
wmemset (tmp, L'X', MAX_PASSWORD);
tmp[MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
EndDialog (hwndDlg, lw);
return 1;
}
if (lw == IDOK)
{
wchar_t tmp[MAX_PASSWORD+1];
- mountOptions->ReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY));
- mountOptions->Removable = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_REMOVABLE));
- mountOptions->DisableMountManager = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER));
- mountOptions->ProtectHiddenVolume = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL));
- mountOptions->PartitionInInactiveSysEncScope = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA));
- mountOptions->UseBackupHeader = IsButtonChecked (GetDlgItem (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK));
+ pMountOptions->ReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY));
+ pMountOptions->Removable = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_REMOVABLE));
+ pMountOptions->DisableMountManager = IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER));
+ pMountOptions->ProtectHiddenVolume = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL));
+ pMountOptions->PartitionInInactiveSysEncScope = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_SYSENC_PART_WITHOUT_PBA));
+ pMountOptions->UseBackupHeader = IsButtonChecked (GetDlgItem (hwndDlg, IDC_USE_EMBEDDED_HEADER_BAK));
- GetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, mountOptions->Label, sizeof (mountOptions->Label) /sizeof (wchar_t));
+ GetDlgItemTextW (hwndDlg, IDC_VOLUME_LABEL, pMountOptions->Label, sizeof (pMountOptions->Label) /sizeof (wchar_t));
- if (mountOptions->ProtectHiddenVolume)
+ if (pMountOptions->ProtectHiddenVolume)
{
int iMaxPasswordLength = bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD : MAX_PASSWORD;
GetPassword (hwndDlg, IDC_PASSWORD_PROT_HIDVOL,
- (LPSTR) mountOptions->ProtectedHidVolPassword.Text, iMaxPasswordLength + 1,
+ (LPSTR) pMountOptions->ProtectedHidVolPassword.Text, iMaxPasswordLength + 1,
FALSE, FALSE);
- mountOptions->ProtectedHidVolPassword.Length = (unsigned __int32) strlen ((char *) mountOptions->ProtectedHidVolPassword.Text);
+ pMountOptions->ProtectedHidVolPassword.Length = (unsigned __int32) strlen ((char *) pMountOptions->ProtectedHidVolPassword.Text);
- mountOptions->ProtectedHidVolPkcs5Prf = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA,
+ pMountOptions->ProtectedHidVolPkcs5Prf = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA,
SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
- mountOptions->ProtectedHidVolPim = GetPim (hwndDlg, IDC_PIM, 0);
+ pMountOptions->ProtectedHidVolPim = GetPim (hwndDlg, IDC_PIM, 0);
}
// Cleanup
wmemset (tmp, L'X', MAX_PASSWORD);
tmp[MAX_PASSWORD] = 0;
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), tmp);
- if ((mountOptions->ProtectHiddenVolume && !bEnableBkgTask)
+ if ((pMountOptions->ProtectHiddenVolume && !bEnableBkgTask)
&& (AskWarnYesNo ("HIDVOL_PROT_BKG_TASK_WARNING", hwndDlg) == IDYES))
{
bEnableBkgTask = TRUE;
TaskBarIconAdd (MainDlg);
}
EndDialog (hwndDlg, lw);
return 1;
}
if (lw == IDC_MOUNT_READONLY || lw == IDC_PROTECT_HIDDEN_VOL || lw == IDC_DISABLE_MOUNT_MANAGER)
{
BOOL protect;
if (lw == IDC_MOUNT_READONLY)
{
SendDlgItemMessage (hwndDlg, IDC_PROTECT_HIDDEN_VOL, BM_SETCHECK, BST_UNCHECKED, 0);
EnableWindow (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL), !IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)));
EnableWindow (GetDlgItem (hwndDlg, IDT_HIDDEN_VOL_PROTECTION), !IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY)));
}
if (lw == IDC_DISABLE_MOUNT_MANAGER)
{
EnableWindow (GetDlgItem (hwndDlg, IDC_VOLUME_LABEL), !IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER)));
EnableWindow (GetDlgItem (hwndDlg, IDT_VOLUME_LABEL), !IsButtonChecked (GetDlgItem (hwndDlg, IDC_DISABLE_MOUNT_MANAGER)));
}
protect = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PROTECT_HIDDEN_VOL));
EnableWindow (GetDlgItem (hwndDlg, IDC_PASSWORD_PROT_HIDVOL), protect);
@@ -4452,61 +4455,61 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
BST_CHECKED, 0);
SendDlgItemMessage (hwndDlg, IDC_DRIVELIST, CB_RESETCONTENT, 0, 0);
index = (int) SendDlgItemMessageW (hwndDlg, IDC_DRIVELIST, CB_ADDSTRING, 0, (LPARAM) GetString ("FIRST_AVAILABLE"));
SendDlgItemMessage (hwndDlg, IDC_DRIVELIST, CB_SETITEMDATA, index, (LPARAM) 0);
for (i = L'A'; i <= L'Z'; i++)
{
if (i == L'C')
continue;
drive[0] = i;
index = (int) SendDlgItemMessageW (hwndDlg, IDC_DRIVELIST, CB_ADDSTRING, 0, (LPARAM) drive);
SendDlgItemMessageW (hwndDlg, IDC_DRIVELIST, CB_SETITEMDATA, index, (LPARAM) i);
}
SendDlgItemMessageW (hwndDlg, IDC_DRIVELIST, CB_SETCURSEL, 0, 0);
return 0;
}
case WM_CTLCOLORSTATIC:
{
HDC hdc = (HDC) wParam;
HWND hw = (HWND) lParam;
if (hw == GetDlgItem(hwndDlg, IDC_DIRECTORY))
{
// This the directory field. Make its background like normal edit
HBRUSH hbr = GetSysColorBrush (COLOR_WINDOW);
::SelectObject(hdc, hbr);
- return (BOOL) hbr;
+ return (BOOL)(INT_PTR)hbr;
}
}
return 0;
case WM_COMMAND:
if (HIWORD (wParam) == BN_CLICKED
&& (lw == IDC_AUTORUN_DISABLE || lw == IDC_AUTORUN_MOUNT || lw == IDC_AUTORUN_START ))
{
BOOL enabled = IsButtonChecked (GetDlgItem (hwndDlg, IDC_AUTORUN_MOUNT));
EnableWindow (GetDlgItem (hwndDlg, IDC_BROWSE_FILES), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDC_VOLUME_NAME), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDC_TRAVEL_OPEN_EXPLORER), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDC_TRAV_CACHE_PASSWORDS), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PIM), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDC_DRIVELIST), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDT_TRAVELER_MOUNT), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDT_MOUNT_LETTER), enabled);
EnableWindow (GetDlgItem (hwndDlg, IDT_MOUNT_SETTINGS), enabled);
if (!bAutoRunWarningDisplayed
&& (lw == IDC_AUTORUN_MOUNT || lw == IDC_AUTORUN_START))
{
bAutoRunWarningDisplayed = TRUE;
Warning ("AUTORUN_MAY_NOT_ALWAYS_WORK", hwndDlg);
}
return 1;
@@ -4518,81 +4521,81 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
wchar_t volName[MAX_PATH] = { 0 };
GetDlgItemText (hwndDlg, IDC_DIRECTORY, dstDir, ARRAYSIZE (dstDir));
if (BrowseFilesInDir (hwndDlg, "OPEN_TITLE", dstDir, volName, bHistory, FALSE, NULL))
SetDlgItemText (hwndDlg, IDC_VOLUME_NAME, wcschr (volName, L'\\') + 1);
return 1;
}
if (lw == IDC_BROWSE_DIRS)
{
wchar_t dstPath[MAX_PATH * 2];
GetDlgItemText (hwndDlg, IDC_DIRECTORY, dstPath, ARRAYSIZE (dstPath));
if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", dstPath, dstPath))
SetDlgItemText (hwndDlg, IDC_DIRECTORY, dstPath);
return 1;
}
if (lw == IDCANCEL || lw == IDCLOSE)
{
EndDialog (hwndDlg, lw);
return 1;
}
if (lw == IDC_CREATE)
{
- BOOL copyWizard, copyExpander, bExplore, bCacheInDriver, bIncludePimInCache, bAutoRun, bAutoMount, bMountReadOnly;
+ BOOL copyWizard, copyExpander, openExplorer, cacheInDriver, includePimInCache, bAutoRun, bAutoMount, bMountReadOnly;
WCHAR dstDir[MAX_PATH + 1];
WCHAR srcPath[1024 + MAX_PATH + 1];
WCHAR dstPath[2*MAX_PATH + 1];
WCHAR appDir[1024];
WCHAR volName[MAX_PATH + 2];
int drive;
WCHAR* ptr;
GetDlgItemTextW (hwndDlg, IDC_DIRECTORY, dstDir, array_capacity (dstDir));
volName[0] = 0;
GetDlgItemTextW (hwndDlg, IDC_VOLUME_NAME, volName + 1, (array_capacity (volName)) - 1);
drive = (int) SendDlgItemMessage (hwndDlg, IDC_DRIVELIST, CB_GETCURSEL, 0, 0);
drive = (int) SendDlgItemMessage (hwndDlg, IDC_DRIVELIST, CB_GETITEMDATA, drive, 0);
copyWizard = IsButtonChecked (GetDlgItem (hwndDlg, IDC_COPY_WIZARD));
copyExpander = IsButtonChecked (GetDlgItem (hwndDlg, IDC_COPY_EXPANDER));
- bExplore = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAVEL_OPEN_EXPLORER));
- bCacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAV_CACHE_PASSWORDS));
- bIncludePimInCache = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PIM));
+ openExplorer = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAVEL_OPEN_EXPLORER));
+ cacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_TRAV_CACHE_PASSWORDS));
+ includePimInCache = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PIM));
bMountReadOnly = IsButtonChecked (GetDlgItem (hwndDlg, IDC_MOUNT_READONLY));
bAutoRun = !IsButtonChecked (GetDlgItem (hwndDlg, IDC_AUTORUN_DISABLE));
bAutoMount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_AUTORUN_MOUNT));
if (dstDir[0] == 0)
{
SetFocus (GetDlgItem (hwndDlg, IDC_DIRECTORY));
MessageBoxW (hwndDlg, GetString ("NO_PATH_SELECTED"), lpszTitle, MB_ICONEXCLAMATION);
return 1;
}
if (bAutoMount && volName[1] == 0)
{
SetFocus (GetDlgItem (hwndDlg, IDC_VOLUME_NAME));
MessageBoxW (hwndDlg, GetString ("NO_FILE_SELECTED"), lpszTitle, MB_ICONEXCLAMATION);
return 1;
}
if (volName[1] != 0)
{
volName[0] = L'"';
StringCbCatW (volName, sizeof(volName), L"\"");
}
GetModuleFileNameW (NULL, appDir, array_capacity (appDir));
if (ptr = wcsrchr (appDir, L'\\'))
ptr[0] = 0;
WaitCursor ();
@@ -4951,62 +4954,62 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
goto stop;
}
StringCbPrintfW (srcPath, sizeof(srcPath), L"%s\\Languages\\Language.%hs.xml", appDir, GetPreferredLangId ());
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\VeraCrypt\\Languages\\Language.%hs.xml", dstDir, GetPreferredLangId ());
if (!TCCopyFile (srcPath, dstPath))
{
handleWin32Error (hwndDlg, SRC_POS);
goto stop;
}
}
// AutoRun
StringCbPrintfW (dstPath, sizeof(dstPath), L"%s\\autorun.inf", dstDir);
DeleteFileW (dstPath);
if (bAutoRun)
{
FILE *af;
wchar_t autoMount[2*MAX_PATH + 2];
wchar_t driveLetter[] = { L' ', L'/', L'l', L' ', (wchar_t) drive, 0 };
af = _wfopen (dstPath, L"w,ccs=UNICODE");
if (af == NULL)
{
MessageBoxW (hwndDlg, GetString ("CANT_CREATE_AUTORUN"), lpszTitle, MB_ICONERROR);
goto stop;
}
StringCbPrintfW (autoMount, sizeof(autoMount), L"VeraCrypt\\VeraCrypt.exe /q background%s%s%s%s /m rm /v %s",
drive > 0 ? driveLetter : L"",
- bExplore ? L" /e" : L"",
- bCacheInDriver ? (bIncludePimInCache? L" /c p" : L" /c y") : L"",
+ openExplorer ? L" /e" : L"",
+ cacheInDriver ? (includePimInCache? L" /c p" : L" /c y") : L"",
bMountReadOnly ? L" /m ro" : L"",
volName);
fwprintf (af, L"[autorun]\nlabel=%s\nicon=VeraCrypt\\VeraCrypt.exe\n", GetString ("TC_TRAVELER_DISK"));
fwprintf (af, L"action=%s\n", bAutoMount ? GetString ("MOUNT_TC_VOLUME") : GetString ("IDC_PREF_LOGON_START"));
fwprintf (af, L"open=%s\n", bAutoMount ? autoMount : L"VeraCrypt\\VeraCrypt.exe");
fwprintf (af, L"shell\\start=%s\nshell\\start\\command=VeraCrypt\\VeraCrypt.exe\n", GetString ("IDC_PREF_LOGON_START"));
fwprintf (af, L"shell\\dismount=%s\nshell\\dismount\\command=VeraCrypt\\VeraCrypt.exe /q /d\n", GetString ("DISMOUNT_ALL_TC_VOLUMES"));
CheckFileStreamWriteErrors (hwndDlg, af, dstPath);
fclose (af);
}
MessageBoxW (hwndDlg, GetString ("TRAVELER_DISK_CREATED"), lpszTitle, MB_ICONINFORMATION);
stop:
FreeAllFileBuffers ();
NormalCursor ();
return 1;
}
return 0;
}
return 0;
}
void BuildTree (HWND hwndDlg, HWND hTree)
{
HIMAGELIST hList;
HBITMAP hBitmap, hBitmapMask;
LVCOLUMNW lvCol;
@@ -5134,203 +5137,203 @@ LPARAM GetItemLong (HWND hTree, int itemNo)
static int AskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int *pim, char *titleStringId, BOOL enableMountOptions)
{
INT_PTR result;
PasswordDlgParam dlgParam;
PasswordDialogTitleStringId = titleStringId;
PasswordDialogDisableMountOptions = !enableMountOptions;
dlgParam.password = password;
dlgParam.pkcs5 = pkcs5;
dlgParam.pim = pim;
result = SecureDesktopDialogBoxParam (hInst,
MAKEINTRESOURCEW (IDD_PASSWORD_DLG), hwndDlg,
(DLGPROC) PasswordDlgProc, (LPARAM) &dlgParam);
if (result != IDOK)
{
password->Length = 0;
*pkcs5 = 0;
*pim = -1;
burn (&mountOptions.ProtectedHidVolPassword, sizeof (mountOptions.ProtectedHidVolPassword));
burn (&mountOptions.ProtectedHidVolPkcs5Prf, sizeof (mountOptions.ProtectedHidVolPkcs5Prf));
}
return result == IDOK;
}
// GUI actions
-static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, int pkcs5)
+static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szVolFileName, int pim, int pkcs5)
{
BOOL status = FALSE;
wchar_t fileName[MAX_PATH];
int mounted = 0, EffectiveVolumePkcs5 = 0;
int EffectiveVolumePim = (pim < 0)? CmdVolumePim : pim;
BOOL bEffectiveCacheDuringMultipleMount = bCmdCacheDuringMultipleMount? TRUE: bCacheDuringMultipleMount;
BOOL bEffectiveTryEmptyPasswordWhenKeyfileUsed = bCmdTryEmptyPasswordWhenKeyfileUsedValid? bCmdTryEmptyPasswordWhenKeyfileUsed : bTryEmptyPasswordWhenKeyfileUsed;
BOOL bUseCmdVolumePassword = CmdVolumePasswordValid && ((CmdVolumePassword.Length > 0) || (KeyFilesEnable && FirstKeyFile));
/* Priority is given to arguments and command line parameters
* Default values used only when nothing specified
*/
if (pkcs5 > 0)
EffectiveVolumePkcs5 = pkcs5;
else if (CmdVolumePkcs5 > 0)
EffectiveVolumePkcs5 = CmdVolumePkcs5;
else
EffectiveVolumePkcs5 = DefaultVolumePkcs5;
bPrebootPasswordDlgMode = mountOptions.PartitionInInactiveSysEncScope;
if (nDosDriveNo == -1)
nDosDriveNo = HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST))) - L'A';
if (!MultipleMountOperationInProgress)
{
VolumePassword.Length = 0;
VolumePkcs5 = 0;
VolumePim = -1;
}
- if (szFileName == NULL)
+ if (szVolFileName == NULL)
{
GetVolumePath (hwndDlg, fileName, ARRAYSIZE (fileName));
}
else
- StringCchCopyW (fileName, ARRAYSIZE (fileName), szFileName);
+ StringCchCopyW (fileName, ARRAYSIZE (fileName), szVolFileName);
if (wcslen(fileName) == 0)
{
status = FALSE;
goto ret;
}
if (!TranslateVolumeID (hwndDlg, fileName, ARRAYSIZE (fileName)))
{
status = FALSE;
goto ret;
}
- szFileName = fileName;
+ szVolFileName = fileName;
- if (IsMountedVolume (szFileName))
+ if (IsMountedVolume (szVolFileName))
{
Warning ("VOL_ALREADY_MOUNTED", hwndDlg);
status = FALSE;
goto ret;
}
- if (!VolumePathExists (szFileName))
+ if (!VolumePathExists (szVolFileName))
{
if (!MultipleMountOperationInProgress)
handleWin32Error (hwndDlg, SRC_POS);
status = FALSE;
goto ret;
}
ResetWrongPwdRetryCount ();
WaitCursor ();
if (!bUseCmdVolumePassword)
{
// First try cached passwords and if they fail ask user for a new one
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, EffectiveVolumePkcs5, EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szVolFileName, NULL, EffectiveVolumePkcs5, EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
// If keyfiles are enabled, test empty password first
if (!mounted && KeyFilesEnable && FirstKeyFile && bEffectiveTryEmptyPasswordWhenKeyfileUsed)
{
Password emptyPassword = {0};
- KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szFileName);
+ KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szVolFileName);
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, EffectiveVolumePkcs5, EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szVolFileName, &emptyPassword, EffectiveVolumePkcs5, EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
burn (&emptyPassword, sizeof (emptyPassword));
}
}
// Test password and/or keyfiles used for the previous volume
if (!mounted && bEffectiveCacheDuringMultipleMount && MultipleMountOperationInProgress && VolumePassword.Length != 0)
{
// if no PIM specified for favorite, we use also the PIM of the previous volume alongside its password.
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, EffectiveVolumePkcs5, (EffectiveVolumePim < 0)? VolumePim : EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szVolFileName, &VolumePassword, EffectiveVolumePkcs5, (EffectiveVolumePim < 0)? VolumePim : EffectiveVolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE);
}
NormalCursor ();
if (mounted)
{
// Check for problematic file extensions (exe, dll, sys)
- if (CheckFileExtension(szFileName))
+ if (CheckFileExtension(szVolFileName))
Warning ("EXE_FILE_EXTENSION_MOUNT_WARNING", hwndDlg);
}
while (mounted == 0)
{
if (bUseCmdVolumePassword)
{
VolumePassword = CmdVolumePassword;
VolumePkcs5 = EffectiveVolumePkcs5;
VolumePim = EffectiveVolumePim;
}
else if (!Silent)
{
int GuiPkcs5 = EffectiveVolumePkcs5;
int GuiPim = EffectiveVolumePim;
- StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szFileName);
+ StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), szVolFileName);
if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiPim, NULL, TRUE))
goto ret;
else
{
VolumePkcs5 = GuiPkcs5;
VolumePim = GuiPim;
burn (&GuiPkcs5, sizeof(GuiPkcs5));
burn (&GuiPim, sizeof(GuiPim));
}
}
WaitCursor ();
if (KeyFilesEnable)
- KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, szFileName);
+ KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, szVolFileName);
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, !Silent);
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szVolFileName, &VolumePassword, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, !Silent);
NormalCursor ();
// Check for problematic file extensions (exe, dll, sys)
- if (mounted > 0 && CheckFileExtension (szFileName))
+ if (mounted > 0 && CheckFileExtension (szVolFileName))
Warning ("EXE_FILE_EXTENSION_MOUNT_WARNING", hwndDlg);
if (!MultipleMountOperationInProgress)
{
burn (&VolumePassword, sizeof (VolumePassword));
burn (&VolumePkcs5, sizeof (VolumePkcs5));
burn (&VolumePim, sizeof (VolumePim));
}
burn (&mountOptions.ProtectedHidVolPassword, sizeof (mountOptions.ProtectedHidVolPassword));
burn (&mountOptions.ProtectedHidVolPkcs5Prf, sizeof (mountOptions.ProtectedHidVolPkcs5Prf));
if (CmdVolumePassword.Length > 0 || Silent)
break;
}
if (mounted > 0)
{
status = TRUE;
if (bBeep)
MessageBeep (0xFFFFFFFF);
RefreshMainDlg(MainDlg);
if (bExplore)
{
WaitCursor();
OpenVolumeExplorerWindow (nDosDriveNo);
NormalCursor();
@@ -5564,61 +5567,61 @@ retry:
BroadcastDeviceChange (DBT_DEVICEREMOVECOMPLETE, 0, prevMountList.ulMountedDrives & ~mountList.ulMountedDrives);
RefreshMainDlg (hwndDlg);
NormalCursor();
if (unmount.nReturnCode != 0)
{
if (forceUnmount)
status = FALSE;
if (unmount.nReturnCode == ERR_FILES_OPEN)
{
if (interact && IDYES == AskWarnYesNoTopmost ("UNMOUNTALL_LOCK_FAILED", hwndDlg))
{
forceUnmount = TRUE;
goto retry;
}
// Undo SHCNE_DRIVEREMOVED
if ( DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, NULL, 0, &mountList, sizeof (mountList), &dwResult, NULL)
&& mountList.ulMountedDrives
&& (mountList.ulMountedDrives < (1 << 26))
)
{
for (i = 0; i < 26; 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);
}
}
}
return FALSE;
}
if (interact && !Silent)
MessageBoxW (hwndDlg, GetString ("UNMOUNT_FAILED"), lpszTitle, MB_ICONERROR);
}
else
{
if (bBeep)
MessageBeep (0xFFFFFFFF);
}
return status;
}
static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
{
HWND driveList = GetDlgItem (MainDlg, IDC_DRIVELIST);
int selDrive = ListView_GetSelectionMark (driveList);
BOOL shared = FALSE, status = FALSE, bHeaderBakRetry = FALSE;
int mountedVolCount = 0;
vector <HostDevice> devices;
int EffectiveVolumePkcs5 = CmdVolumePkcs5;
/* Priority is given to command line parameters
@@ -5656,126 +5659,126 @@ static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt)
VolumePkcs5 = GuiPkcs5;
VolumePim = GuiPim;
burn (&GuiPkcs5, sizeof(GuiPkcs5));
burn (&GuiPim, sizeof(GuiPim));
}
}
else if (CmdVolumePasswordValid)
{
bPasswordPrompt = FALSE;
VolumePassword = CmdVolumePassword;
VolumePkcs5 = EffectiveVolumePkcs5;
VolumePim = CmdVolumePim;
}
WaitCursor();
if (FirstCmdKeyFile)
KeyFilesApply (hwndDlg, &VolumePassword, FirstCmdKeyFile, NULL);
else if (KeyFilesEnable)
KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, NULL);
}
if (devices.empty())
devices = GetAvailableHostDevices (true, false, true, true);
foreach (const HostDevice &drive, devices)
{
vector <HostDevice> partitions = drive.Partitions;
partitions.insert (partitions.begin(), drive);
- foreach (const HostDevice &device, partitions)
+ for (const HostDevice &device: partitions)
{
- wchar_t szFileName[TC_MAX_PATH];
- StringCbCopyW (szFileName, sizeof (szFileName), device.Path.c_str());
- BOOL mounted = IsMountedVolume (szFileName);
+ wchar_t szPartPath[TC_MAX_PATH];
+ StringCbCopyW (szPartPath, sizeof (szPartPath), device.Path.c_str());
+ BOOL mounted = IsMountedVolume (szPartPath);
// Skip other partitions of the disk if partition0 (whole disk) is mounted
if (!device.IsPartition && mounted)
break;
if (device.Floppy)
break;
if (device.HasUnencryptedFilesystem && !mountOptions.UseBackupHeader && !bHeaderBakRetry)
continue;
if (!mounted)
{
int nDosDriveNo;
int driveAItem = -1, driveBItem = -1;
while (LOWORD (GetItemLong (driveList, selDrive)) != 0xffff)
{
if(LOWORD (GetItemLong (driveList, selDrive)) != TC_MLIST_ITEM_FREE)
{
selDrive++;
continue;
}
nDosDriveNo = HIWORD(GetItemLong (driveList, selDrive)) - L'A';
/* don't use drives A: and B: for now until no other free drive found */
if (nDosDriveNo == 0)
{
driveAItem = selDrive;
selDrive++;
continue;
}
if (nDosDriveNo == 1)
{
driveBItem = selDrive;
selDrive++;
continue;
}
break;
}
if (LOWORD (GetItemLong (driveList, selDrive)) == 0xffff)
{
/* use A: or B: if available as a last resort */
if (driveAItem >= 0)
{
nDosDriveNo = 0;
selDrive = driveAItem;
}
else if (driveBItem >= 0)
{
nDosDriveNo = 1;
selDrive = driveBItem;
}
else
goto ret;
}
// First try user password then cached passwords
- if ((mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, TRUE, FALSE)) > 0
- || ((VolumePassword.Length > 0) && ((mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, TRUE, FALSE)) > 0)))
+ if ((mounted = MountVolume (hwndDlg, nDosDriveNo, szPartPath, &VolumePassword, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, TRUE, FALSE)) > 0
+ || ((VolumePassword.Length > 0) && ((mounted = MountVolume (hwndDlg, nDosDriveNo, szPartPath, NULL, VolumePkcs5, VolumePim, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, TRUE, FALSE)) > 0)))
{
// A volume has been successfully mounted
ResetWrongPwdRetryCount ();
if (mounted == 2)
shared = TRUE;
LoadDriveLetters (hwndDlg, driveList, (HIWORD (GetItemLong (GetDlgItem (MainDlg, IDC_DRIVELIST), selDrive))));
selDrive++;
if (bExplore)
{
WaitCursor();
OpenVolumeExplorerWindow (nDosDriveNo);
NormalCursor();
}
if (bBeep)
MessageBeep (0xFFFFFFFF);
status = TRUE;
mountedVolCount++;
// Skip other partitions of the disk if partition0 (whole disk) has been mounted
if (!device.IsPartition)
break;
}
}
@@ -5992,61 +5995,64 @@ static void ChangePassword (HWND hwndDlg)
// Change password of the system partition/drive
static void ChangeSysEncPassword (HWND hwndDlg, BOOL bOnlyChangeKDF)
{
try
{
BootEncStatus = BootEncObj->GetStatus();
}
catch (Exception &e)
{
e.Show (MainDlg);
}
if (!BootEncStatus.DriveEncrypted
&& !BootEncStatus.DriveMounted
&& !BootEncStatus.VolumeHeaderPresent
&& !SysEncryptionOrDecryptionRequired ())
{
Warning ("SYS_DRIVE_NOT_ENCRYPTED", hwndDlg);
return;
}
if (SysEncryptionOrDecryptionRequired ()
|| BootEncStatus.SetupInProgress)
{
Warning ("SYSTEM_ENCRYPTION_NOT_COMPLETED", hwndDlg);
return;
}
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;
if (bOnlyChangeKDF)
pwdChangeDlgMode = PCDM_CHANGE_PKCS5_PRF;
else
pwdChangeDlgMode = PCDM_CHANGE_PASSWORD;
INT_PTR result = DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_PASSWORDCHANGE_DLG), hwndDlg, (DLGPROC) PasswordChangeDlgProc);
bSysEncPwdChangeDlgMode = FALSE;
if (bKeyboardLayoutChanged)
{
// Restore the original keyboard layout
if (LoadKeyboardLayout (OrigKeyboardLayout, KLF_ACTIVATE | KLF_SUBSTITUTE_OK) == NULL)
Warning ("CANNOT_RESTORE_KEYBOARD_LAYOUT", hwndDlg);
else
bKeyboardLayoutChanged = FALSE;
}
bKeybLayoutAltKeyWarningShown = FALSE;
if (result == IDOK)
{
switch (pwdChangeDlgMode)
{
case PCDM_CHANGE_PKCS5_PRF:
Info ("PKCS5_PRF_CHANGED", hwndDlg);
@@ -7653,111 +7659,111 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
DWORD dwResult;
previousState = TRUE;
if (bWipeCacheOnAutoDismount)
{
DeviceIoControl (hDriver, TC_IOCTL_WIPE_PASSWORD_CACHE, NULL, 0, NULL, 0, &dwResult, NULL);
SecurityToken::CloseAllSessions(); // TODO Use Token
}
DismountAll (hwndDlg, bForceAutoDismount, FALSE, UNMOUNT_MAX_AUTO_RETRIES, UNMOUNT_AUTO_RETRY_DELAY);
}
else
{
previousState = running;
}
}
// Auto-mount favorite volumes on arrival
#if TIMER_INTERVAL_MAIN != 500
#error TIMER_INTERVAL_MAIN != 500
#endif
static int favoritesAutoMountTimerDivisor = 0;
if ((++favoritesAutoMountTimerDivisor & 1) && !FavoritesOnArrivalMountRequired.empty())
{
static bool reentry = false;
if (reentry)
break;
reentry = true;
- foreach (FavoriteVolume favorite, FavoritesOnArrivalMountRequired)
+ for (FavoriteVolume favorite: FavoritesOnArrivalMountRequired)
{
if (favorite.UseVolumeID)
{
if (IsMountedVolumeID (favorite.VolumeID))
continue;
std::wstring volDevPath = FindDeviceByVolumeID (favorite.VolumeID, FALSE);
if (volDevPath.length() > 0)
{
favorite.Path = volDevPath;
favorite.DisconnectedDevice = false;
}
else
continue;
}
else if (!favorite.VolumePathId.empty())
{
if (IsMountedVolume (favorite.Path.c_str()))
continue;
wchar_t volDevPath[TC_MAX_PATH];
if (QueryDosDevice (favorite.VolumePathId.substr (4, favorite.VolumePathId.size() - 5).c_str(), volDevPath, TC_MAX_PATH) == 0)
continue;
favorite.DisconnectedDevice = false;
}
else if (favorite.Path.find (L"\\\\?\\Volume{") == 0)
{
wstring resolvedPath = VolumeGuidPathToDevicePath (favorite.Path);
if (resolvedPath.empty())
continue;
favorite.DisconnectedDevice = false;
favorite.VolumePathId = favorite.Path;
favorite.Path = resolvedPath;
}
if (IsMountedVolume (favorite.Path.c_str()))
continue;
if (!IsVolumeDeviceHosted (favorite.Path.c_str()))
{
if (!FileExists (favorite.Path.c_str()))
continue;
}
else if (favorite.VolumePathId.empty())
continue;
bool mountedAndNotDisconnected = false;
- foreach (FavoriteVolume mountedFavorite, FavoritesMountedOnArrivalStillConnected)
+ for (FavoriteVolume mountedFavorite: FavoritesMountedOnArrivalStillConnected)
{
if (favorite.Path == mountedFavorite.Path)
{
mountedAndNotDisconnected = true;
break;
}
}
if (!mountedAndNotDisconnected)
{
FavoriteMountOnArrivalInProgress = TRUE;
MountFavoriteVolumes (hwndDlg, FALSE, FALSE, FALSE, favorite);
FavoriteMountOnArrivalInProgress = FALSE;
FavoritesMountedOnArrivalStillConnected.push_back (favorite);
}
}
bool deleted;
for (list <FavoriteVolume>::iterator favorite = FavoritesMountedOnArrivalStillConnected.begin();
favorite != FavoritesMountedOnArrivalStillConnected.end();
deleted ? favorite : ++favorite)
{
deleted = false;
if (IsMountedVolume (favorite->Path.c_str()))
continue;
if (!IsVolumeDeviceHosted (favorite->Path.c_str()))
{
@@ -7958,66 +7964,66 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
// The wizard added VeraCrypt.exe to the system startup sequence or performed other operations that
// require us to update our cached settings.
LoadSettings (hwndDlg);
return 1;
case WM_DEVICECHANGE:
if (!IgnoreWmDeviceChange && wParam != DBT_DEVICEARRIVAL)
{
// Check if any host device has been removed and force dismount of volumes accordingly
PDEV_BROADCAST_HDR hdr = (PDEV_BROADCAST_HDR) lParam;
int m;
if (GetMountList (&LastKnownMountList))
{
if (wParam == DBT_DEVICEREMOVECOMPLETE && hdr->dbch_devicetype == DBT_DEVTYP_VOLUME)
{
// File-hosted volumes
PDEV_BROADCAST_VOLUME vol = (PDEV_BROADCAST_VOLUME) lParam;
int i;
for (i = 0; i < 26; i++)
{
if (LastKnownMountList.ulMountedDrives && (vol->dbcv_unitmask & (1 << i)) && !(GetUsedLogicalDrives() & (1 << i)))
{
for (m = 0; m < 26; m++)
{
if ((LastKnownMountList.ulMountedDrives & (1 << m)) && IsNullTerminateString (LastKnownMountList.wszVolume[m], TC_MAX_PATH))
{
- wchar_t *vol = (wchar_t *) LastKnownMountList.wszVolume[m];
+ wchar_t *wszVol = (wchar_t *) LastKnownMountList.wszVolume[m];
- if (wcsstr (vol, L"\\??\\") == vol)
+ if (wcsstr (wszVol, L"\\??\\") == wszVol)
vol += 4;
- if (vol[1] == L':' && i == (vol[0] - (vol[0] <= L'Z' ? L'A' : L'a')))
+ if (wszVol[1] == L':' && i == (wszVol[0] - (wszVol[0] <= L'Z' ? L'A' : L'a')))
{
UnmountVolume (hwndDlg, m, TRUE);
WarningBalloon ("HOST_DEVICE_REMOVAL_DISMOUNT_WARN_TITLE", "HOST_DEVICE_REMOVAL_DISMOUNT_WARN", hwndDlg);
}
}
}
}
}
}
// Device-hosted volumes
for (m = 0; m < 26; m++)
{
if ((LastKnownMountList.ulMountedDrives & (1 << m)) && IsNullTerminateString (LastKnownMountList.wszVolume[m], TC_MAX_PATH))
{
wchar_t *vol = (wchar_t *) LastKnownMountList.wszVolume[m];
if (wcsstr (vol, L"\\??\\") == vol)
vol += 4;
if (IsVolumeDeviceHosted (vol))
{
OPEN_TEST_STRUCT ots = {0};
if (!OpenDevice (vol, &ots, FALSE, FALSE))
{
UnmountVolume (hwndDlg, m, TRUE);
WarningBalloon ("HOST_DEVICE_REMOVAL_DISMOUNT_WARN_TITLE", "HOST_DEVICE_REMOVAL_DISMOUNT_WARN", hwndDlg);
}
}
@@ -11077,61 +11083,61 @@ error:
CloseVolume (&volume);
CloseVolume (&hiddenVolume);
if (fBackup != -1)
_close (fBackup);
SetLastError (dwError);
if (nStatus != 0)
handleError (hwndDlg, nStatus, SRC_POS);
burn (&VolumePassword, sizeof (VolumePassword));
burn (&VolumePkcs5, sizeof (VolumePkcs5));
burn (&VolumePim, sizeof (VolumePim));
burn (&hiddenVolPassword, sizeof (hiddenVolPassword));
burn (temporaryKey, sizeof (temporaryKey));
burn (originalK2, sizeof (originalK2));
RestoreDefaultKeyFilesParam();
RandStop (FALSE);
NormalCursor();
return nStatus;
}
int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume)
{
int nDosLinkCreated = -1, nStatus = ERR_OS_ERROR;
wchar_t szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
- wchar_t szFileName[TC_MAX_PATH];
+ wchar_t szHeaderFileName[TC_MAX_PATH];
wchar_t szDosDevice[TC_MAX_PATH];
void *dev = INVALID_HANDLE_VALUE;
DWORD dwError;
BOOL bDevice;
unsigned __int64 hostSize = 0;
FILETIME ftCreationTime;
FILETIME ftLastWriteTime;
FILETIME ftLastAccessTime;
wchar_t szTmp[4096];
BOOL bTimeStampValid = FALSE;
HANDLE fBackup = INVALID_HANDLE_VALUE;
LARGE_INTEGER headerOffset;
CRYPTO_INFO *restoredCryptoInfo = NULL;
int EffectiveVolumePkcs5 = CmdVolumePkcs5;
int EffectiveVolumePim = CmdVolumePim;
/* Priority is given to command line parameters
* Default values used only when nothing specified in command line
*/
if (EffectiveVolumePkcs5 == 0)
EffectiveVolumePkcs5 = DefaultVolumePkcs5;
if (!lpszVolume)
{
nStatus = ERR_OUTOFMEMORY;
handleError (hwndDlg, nStatus, SRC_POS);
return nStatus;
}
switch (IsSystemDevicePath (lpszVolume, hwndDlg, TRUE))
@@ -11243,68 +11249,68 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume)
nStatus = ReEncryptVolumeHeader (hwndDlg, buffer, FALSE, volume.CryptoInfo, &VolumePassword, VolumePim, FALSE);
if (nStatus != 0)
goto error;
headerOffset.QuadPart = volume.CryptoInfo->hiddenVolume ? TC_HIDDEN_VOLUME_HEADER_OFFSET : TC_VOLUME_HEADER_OFFSET;
if (!SetFilePointerEx (volume.HostFileHandle, headerOffset, NULL, FILE_BEGIN))
{
nStatus = ERR_OS_ERROR;
goto error;
}
if (!WriteEffectiveVolumeHeader (volume.IsDevice, volume.HostFileHandle, (uint8 *) buffer))
{
nStatus = ERR_OS_ERROR;
goto error;
}
}
else
{
// Restore header from an external backup
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CONFIRM_VOL_HEADER_RESTORE"), lpszVolume);
if (MessageBoxW (hwndDlg, szTmp, lpszTitle, YES_NO|MB_ICONWARNING|MB_DEFBUTTON2) == IDNO)
{
nStatus = ERR_SUCCESS;
goto ret;
}
/* Select backup file */
- if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, FALSE))
+ if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szHeaderFileName, bHistory, FALSE))
{
nStatus = ERR_SUCCESS;
goto ret;
}
/* Open the backup file */
- fBackup = CreateFile (szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+ fBackup = CreateFile (szHeaderFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (fBackup == INVALID_HANDLE_VALUE)
{
nStatus = ERR_OS_ERROR;
goto error;
}
// Determine size of the backup file
LARGE_INTEGER backupSize;
if (!GetFileSizeEx (fBackup, &backupSize))
{
nStatus = ERR_OS_ERROR;
goto error;
}
CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), lpszVolume, &bDevice);
if (bDevice == FALSE)
StringCbCopyW (szCFDevice, sizeof(szCFDevice), szDiskFile);
else
{
nDosLinkCreated = FakeDosNameForDevice (szDiskFile, szDosDevice, sizeof(szDosDevice),szCFDevice, sizeof(szCFDevice),FALSE);
if (nDosLinkCreated != 0)
goto error;
}
// Open the volume
dev = CreateFile (szCFDevice, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (dev == INVALID_HANDLE_VALUE)
{
@@ -11386,61 +11392,60 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume)
}
else
{
LARGE_INTEGER fileSize;
if (!GetFileSizeEx (dev, &fileSize))
{
nStatus = ERR_OS_ERROR;
goto error;
}
hostSize = fileSize.QuadPart;
}
/* Read the volume header from the backup file */
unsigned char buffer[TC_VOLUME_HEADER_GROUP_SIZE];
DWORD bytesRead;
if (!ReadFile (fBackup, buffer, sizeof (buffer), &bytesRead, NULL))
{
nStatus = ERR_OS_ERROR;
goto error;
}
if (bytesRead != backupSize.QuadPart)
{
nStatus = ERR_VOL_SIZE_WRONG;
goto error;
}
- LARGE_INTEGER headerOffset;
LARGE_INTEGER headerBackupOffset;
bool legacyBackup;
int headerOffsetBackupFile;
// Determine the format of the backup file
switch (backupSize.QuadPart)
{
case TC_VOLUME_HEADER_GROUP_SIZE:
legacyBackup = false;
break;
case TC_VOLUME_HEADER_SIZE_LEGACY * 2:
legacyBackup = true;
break;
default:
Error ("HEADER_BACKUP_SIZE_INCORRECT", hwndDlg);
nStatus = ERR_SUCCESS;
goto error;
}
// Open the header
while (TRUE)
{
int GuiPkcs5 = ((EffectiveVolumePkcs5 > 0) && (VolumePkcs5 == 0))? EffectiveVolumePkcs5 : VolumePkcs5;
int GuiPim = ((EffectiveVolumePim > 0) && (VolumePim <= 0))? EffectiveVolumePim : VolumePim;
if (!AskVolumePassword (hwndDlg, &VolumePassword, &GuiPkcs5, &GuiPim, "ENTER_HEADER_BACKUP_PASSWORD", FALSE))
{
nStatus = ERR_SUCCESS;
goto ret;
@@ -11703,61 +11708,61 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
if (hDisableMemProtectionTooltipWnd)
{
DestroyWindow (hDisableMemProtectionTooltipWnd);
hDisableMemProtectionTooltipWnd = NULL;
}
break;
case WM_COMMAND:
switch (lw)
{
case IDCANCEL:
EndDialog (hwndDlg, lw);
return 1;
case IDOK:
{
if (IsNonInstallMode())
{
Error ("FEATURE_REQUIRES_INSTALLATION", hwndDlg);
EndDialog (hwndDlg, IDCANCEL);
return 1;
}
BOOL disableHW = !IsDlgButtonChecked (hwndDlg, IDC_ENABLE_HARDWARE_ENCRYPTION);
BOOL enableCpuRng = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_CPU_RNG);
BOOL enableRamEncryption = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION);
BOOL enableExtendedIOCTL = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_EXTENDED_IOCTL_SUPPORT);
BOOL allowTrimCommand = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD);
BOOL allowWindowsDefrag = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG);
- BOOL bDisableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION);
+ BOOL disableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION);
try
{
VOLUME_PROPERTIES_STRUCT prop;
bool rebootRequired = false;
uint32 driverConfig = ReadDriverConfigurationFlags();
try
{
BootEncStatus = BootEncObj->GetStatus();
BootEncObj->GetVolumeProperties (&prop);
}
catch (...)
{
BootEncStatus.DriveMounted = false;
}
if (BootEncStatus.DriveMounted && !bSystemIsGPT)
{
uint8 userConfig;
string customUserMessage;
uint16 bootLoaderVersion;
if (!BootEncObj->ReadBootSectorConfig (nullptr, 0, &userConfig, &customUserMessage, &bootLoaderVersion))
return 1;
if (bootLoaderVersion != VERSION_NUM)
Warning ("BOOT_LOADER_VERSION_INCORRECT_PREFERENCES", hwndDlg);
if (disableHW)
@@ -11773,63 +11778,63 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM
SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ALLOW_NONSYS_TRIM, allowTrimCommand);
if (IsOSAtLeast (WIN_8_1))
SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ALLOW_WINDOWS_DEFRAG, allowWindowsDefrag);
SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_CPU_RNG, enableCpuRng);
BOOL originalRamEncryptionEnabled = (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION)? TRUE : FALSE;
if (originalRamEncryptionEnabled != enableRamEncryption)
{
if (enableRamEncryption)
{
// Disable Hibernate and Fast Startup if they are enabled
BOOL bHibernateEnabled, bHiberbootEnabled;
if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled))
{
if (bHibernateEnabled)
{
BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Power", L"HibernateEnabled", 0);
}
if (bHiberbootEnabled)
{
BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0);
}
}
}
rebootRequired = true;
}
SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption);
BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig();
- if(originalDisableMemoryProtection != bDisableMemoryProtection)
+ if(originalDisableMemoryProtection != disableMemoryProtection)
rebootRequired = true;
- SetMemoryProtectionConfig (!bDisableMemoryProtection);
+ SetMemoryProtectionConfig (!disableMemoryProtection);
DWORD bytesReturned;
if (!DeviceIoControl (hDriver, TC_IOCTL_REREAD_DRIVER_CONFIG, NULL, 0, NULL, 0, &bytesReturned, NULL))
handleWin32Error (hwndDlg, SRC_POS);
EnableHwEncryption (!disableHW);
EnableCpuRng (enableCpuRng);
uint32 cpuFreeCount = 0;
if (IsDlgButtonChecked (hwndDlg, IDC_LIMIT_ENC_THREAD_POOL))
{
LRESULT cpuFreeItem = SendMessage (GetDlgItem (hwndDlg, IDC_ENCRYPTION_FREE_CPU_COUNT), CB_GETCURSEL, 0, 0);
if (cpuFreeItem != CB_ERR)
cpuFreeCount = (uint32) (cpuFreeItem + 1);
}
if (ReadEncryptionThreadPoolFreeCpuCountLimit() != cpuFreeCount)
{
BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME, cpuFreeCount);
rebootRequired = true;
}
if (rebootRequired)
Warning ("SETTING_REQUIRES_REBOOT", hwndDlg);
EndDialog (hwndDlg, lw);
return 1;
}
catch (Exception &e)
{
@@ -12133,62 +12138,62 @@ static BOOL CALLBACK DefaultMountParametersDlgProc (HWND hwndDlg, UINT msg, WPAR
SaveSettings (hwndDlg);
NormalCursor ();
EndDialog (hwndDlg, lw);
return 1;
}
}
return 0;
}
return 0;
}
void SecurityTokenPreferencesDialog (HWND hwndDlg)
{
DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TOKEN_PREFERENCES), hwndDlg, (DLGPROC) SecurityTokenPreferencesDlgProc, 0);
}
static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
WORD lw = LOWORD (wParam);
static std::string platforminfo;
static uint8 currentUserConfig;
static string currentCustomUserMessage;
switch (msg)
{
case WM_INITDIALOG:
{
- BootEncryptionStatus BootEncStatus = BootEncObj->GetStatus();
- if (!BootEncStatus.DriveMounted)
+ BootEncryptionStatus bootEncStatus = BootEncObj->GetStatus();
+ if (!bootEncStatus.DriveMounted)
{
Warning ("SYS_DRIVE_NOT_ENCRYPTED", hwndDlg);
EndDialog (hwndDlg, IDCANCEL);
return 1;
}
try
{
LocalizeDialog (hwndDlg, "IDD_SYSENC_SETTINGS");
uint32 driverConfig = ReadDriverConfigurationFlags();
uint32 serviceConfig = ReadServiceConfigurationFlags();
uint8 userConfig;
string customUserMessage;
uint16 bootLoaderVersion = 0;
BOOL bPasswordCacheEnabled = (driverConfig & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD)? TRUE : FALSE;
BOOL bPimCacheEnabled = (driverConfig & TC_DRIVER_CONFIG_CACHE_BOOT_PIM)? TRUE : FALSE;
BOOL bBlockSysEncTrimEnabled = (driverConfig & VC_DRIVER_CONFIG_BLOCK_SYS_TRIM)? TRUE : FALSE;
BOOL bClearKeysEnabled = (driverConfig & VC_DRIVER_CONFIG_CLEAR_KEYS_ON_NEW_DEVICE_INSERTION)? TRUE : FALSE;
BOOL bAutoFixBootloader = (serviceConfig & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_UPDATE_LOADER)? FALSE : TRUE;
BOOL bForceVeraCryptNextBoot = FALSE;
BOOL bForceSetVeraCryptBootEntry = TRUE;
BOOL bForceVeraCryptFirstEntry = TRUE;
if (bSystemIsGPT)
{
bForceVeraCryptNextBoot = (serviceConfig & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_FORCE_SET_BOOTNEXT)? TRUE : FALSE;
bForceSetVeraCryptBootEntry = (serviceConfig & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_SET_BOOTENTRY)? FALSE : TRUE;
bForceVeraCryptFirstEntry = (serviceConfig & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_FORCE_FIRST_BOOTENTRY)? FALSE : TRUE;
}
BOOL bIsHiddenOS = IsHiddenOSRunning ();