From fb430c403b2e0deb3f34328d3b65bd39c10b14ba Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 10 Jan 2016 19:35:57 +0100 Subject: Windows: Don't show disconnected network drives in the list of available drives. Add option to make them available for mounting if needed. --- src/Mount/Mount.c | 16 ++++++++++++---- src/Mount/Mount.rc | 38 ++++++++++++++++++++------------------ src/Mount/Mount.vcproj | 12 ++++++++---- src/Mount/Resource.h | 3 ++- 4 files changed, 42 insertions(+), 27 deletions(-) (limited to 'src/Mount') diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 59023200..1aef7a53 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -705,6 +705,8 @@ void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL* if (!bOnlyCheckModified) bPreserveTimestamp = defaultMountOptions.PreserveTimestamp; + ConfigReadCompareInt ("ShowDisconnectedNetworkDrives", FALSE, &bShowDisconnectedNetworkDrives, bOnlyCheckModified, pbSettingsModified); + ConfigReadCompareInt ("MountVolumesRemovable", FALSE, &defaultMountOptions.Removable, bOnlyCheckModified, pbSettingsModified); ConfigReadCompareInt ("MountVolumesReadOnly", FALSE, &defaultMountOptions.ReadOnly, bOnlyCheckModified, pbSettingsModified); @@ -860,6 +862,7 @@ void SaveSettings (HWND hwndDlg) ConfigWriteInt ("MountVolumesReadOnly", defaultMountOptions.ReadOnly); ConfigWriteInt ("MountVolumesRemovable", defaultMountOptions.Removable); ConfigWriteInt ("PreserveTimestamps", defaultMountOptions.PreserveTimestamp); + ConfigWriteInt ("ShowDisconnectedNetworkDrives",bShowDisconnectedNetworkDrives); ConfigWriteInt ("EnableBackgroundTask", bEnableBkgTask); ConfigWriteInt ("CloseBackgroundTaskOnNoVolumes", bCloseBkgTaskWhenNoVolumes); @@ -1454,7 +1457,7 @@ void LoadDriveLetters (HWND hwndDlg, HWND hTree, int drive) AbortProcessSilent(); } - LastKnownLogicalDrives = dwUsedDrives = GetLogicalDrives (); + LastKnownLogicalDrives = dwUsedDrives = GetUsedLogicalDrives (); if (dwUsedDrives == 0) Warning ("DRIVELETTERS", hwndDlg); @@ -3069,6 +3072,9 @@ BOOL CALLBACK PreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM SendMessage (GetDlgItem (hwndDlg, IDC_PRESERVE_TIMESTAMPS), BM_SETCHECK, defaultMountOptions.PreserveTimestamp ? BST_CHECKED:BST_UNCHECKED, 0); + + SendMessage (GetDlgItem (hwndDlg, IDC_SHOW_DISCONNECTED_NETWORK_DRIVES), BM_SETCHECK, + bShowDisconnectedNetworkDrives ? BST_CHECKED:BST_UNCHECKED, 0); SendMessage (GetDlgItem (hwndDlg, IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT), BM_SETCHECK, bCacheDuringMultipleMount ? BST_CHECKED:BST_UNCHECKED, 0); @@ -3183,6 +3189,7 @@ BOOL CALLBACK PreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM bExplore = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_OPEN_EXPLORER)); bUseDifferentTrayIconIfVolMounted = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_USE_DIFF_TRAY_ICON_IF_VOL_MOUNTED)); bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PRESERVE_TIMESTAMPS)); + bShowDisconnectedNetworkDrives = IsButtonChecked (GetDlgItem (hwndDlg, IDC_SHOW_DISCONNECTED_NETWORK_DRIVES)); bCacheDuringMultipleMount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT)); bWipeCacheOnExit = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_EXIT)); bWipeCacheOnAutoDismount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT)); @@ -5830,7 +5837,7 @@ static BOOL CheckMountList (HWND hwndDlg, BOOL bForceTaskBarUpdate) return TRUE; } - if (LastKnownLogicalDrives != GetLogicalDrives() + if (LastKnownLogicalDrives != GetUsedLogicalDrives() || memcmp (&LastKnownMountList, ¤t, sizeof (current)) != 0) { wchar_t selDrive; @@ -6188,6 +6195,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa // Set critical default options in case UsePreferences is false bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = TRUE; + bShowDisconnectedNetworkDrives = FALSE; ResetWrongPwdRetryCount (); @@ -7006,7 +7014,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa for (i = 0; i < 26; i++) { - if ((vol->dbcv_unitmask & (1 << i)) && !(GetLogicalDrives() & (1 << i))) + if ((vol->dbcv_unitmask & (1 << i)) && !(GetUsedLogicalDrives() & (1 << i))) { for (m = 0; m < 26; m++) { @@ -7891,7 +7899,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (lw == IDM_REFRESH_DRIVE_LETTERS) { - DWORD driveMap = GetLogicalDrives (); + DWORD driveMap = GetUsedLogicalDrives (); WaitCursor (); diff --git a/src/Mount/Mount.rc b/src/Mount/Mount.rc index 9e34d6bb..76cae781 100644 --- a/src/Mount/Mount.rc +++ b/src/Mount/Mount.rc @@ -41,7 +41,7 @@ IDR_MOUNT_TLB TYPELIB "Mount.tlb" // Dialog // -IDD_PREFERENCES_DLG DIALOGEX 0, 0, 336, 305 +IDD_PREFERENCES_DLG DIALOGEX 0, 0, 336, 316 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Preferences" FONT 8, "MS Shell Dlg", 400, 0, 0x1 @@ -58,10 +58,12 @@ BEGIN CONTROL "Mount all device-hosted VeraCrypt volumes",IDC_PREF_LOGON_MOUNT_DEVICES, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,140,75,188,10 CONTROL "User logs off",IDC_PREF_DISMOUNT_LOGOFF,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,81,104,114,11 - CONTROL "Entering power saving mode",IDC_PREF_DISMOUNT_POWERSAVING, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,197,115,130,11 + CONTROL "User session locked",IDC_PREF_DISMOUNT_SESSION_LOCKED, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,197,105,130,11 CONTROL "Screen saver is launched",IDC_PREF_DISMOUNT_SCREENSAVER, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,81,116,114,10 + CONTROL "Entering power saving mode",IDC_PREF_DISMOUNT_POWERSAVING, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,197,115,130,11 CONTROL "Auto-dismount volume after no data has been read/written to it for",IDC_PREF_DISMOUNT_INACTIVE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,128,246,11 EDITTEXT IDC_PREF_DISMOUNT_INACTIVE_TIME,258,127,27,12,ES_AUTOHSCROLL | ES_NUMBER,WS_EX_RIGHT @@ -73,29 +75,29 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,184,314,10 CONTROL "Preserve modification timestamp of file containers",IDC_PRESERVE_TIMESTAMPS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,196,316,10 + CONTROL "Make disconnected network drives available for mounting",IDC_SHOW_DISCONNECTED_NETWORK_DRIVES, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,208,316,10 CONTROL "Cache passwords in driver memory",IDC_PREF_CACHE_PASSWORDS, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,227,146,11 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,238,146,11 CONTROL "Wipe cached passwords on exit",IDC_PREF_WIPE_CACHE_ON_EXIT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,227,165,11 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,238,165,11 + CONTROL "Temporary Cache password during ""Mount Favorite Volumes"" operations",IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,252,294,11 CONTROL "Wipe cached passwords on auto-dismount",IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,255,296,11 - PUSHBUTTON "More Settings...",IDC_MORE_SETTINGS,5,289,85,14 - DEFPUSHBUTTON "OK",IDOK,225,289,50,14 - PUSHBUTTON "Cancel",IDCANCEL,281,289,50,14 - GROUPBOX "Windows",IDT_WINDOWS_RELATED_SETTING,4,160,328,52 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,266,296,11 + CONTROL "Include PIM when caching a password",IDC_PREF_CACHE_PIM, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,280,296,10 + PUSHBUTTON "More Settings...",IDC_MORE_SETTINGS,5,300,85,14 + DEFPUSHBUTTON "OK",IDOK,225,300,50,14 + PUSHBUTTON "Cancel",IDCANCEL,281,300,50,14 + GROUPBOX "Windows",IDT_WINDOWS_RELATED_SETTING,4,160,328,62 GROUPBOX "Default Mount Options",IDT_DEFAULT_MOUNT_OPTIONS,4,3,328,26 GROUPBOX "VeraCrypt Background Task",IDT_TASKBAR_ICON,4,33,328,26 GROUPBOX "Auto-Dismount",IDT_AUTO_DISMOUNT,4,94,328,62 LTEXT "minutes",IDT_MINUTES,289,129,39,10 LTEXT "Dismount all when:",IDT_AUTO_DISMOUNT_ON,9,110,71,17 - GROUPBOX "Password Cache",IDT_PW_CACHE_OPTIONS,4,216,328,68 + GROUPBOX "Password Cache",IDT_PW_CACHE_OPTIONS,4,227,328,68 GROUPBOX "Actions to perform upon logon to Windows",IDT_LOGON,4,63,328,28 - CONTROL "User session locked",IDC_PREF_DISMOUNT_SESSION_LOCKED, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,197,105,130,11 - CONTROL "Temporary Cache password during ""Mount Favorite Volumes"" operations",IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,241,294,11 - CONTROL "Include PIM when caching a password",IDC_PREF_CACHE_PIM, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,269,296,10 END IDD_VOLUME_PROPERTIES DIALOGEX 60, 30, 284, 224 @@ -390,7 +392,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 329 TOPMARGIN, 7 - BOTTOMMARGIN, 303 + BOTTOMMARGIN, 314 END IDD_VOLUME_PROPERTIES, DIALOG diff --git a/src/Mount/Mount.vcproj b/src/Mount/Mount.vcproj index 260e3041..64163c7c 100644 --- a/src/Mount/Mount.vcproj +++ b/src/Mount/Mount.vcproj @@ -74,11 +74,12 @@ />