VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount/Favorites.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mount/Favorites.cpp')
-rw-r--r--src/Mount/Favorites.cpp132
1 files changed, 86 insertions, 46 deletions
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index 284c0b5..e93b920 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -243,76 +243,91 @@ namespace VeraCrypt
switch (lw)
{
case IDOK:
-
- /* Global System Favorites settings */
-
- if (SystemFavoritesMode)
{
- BootEncryption BootEncObj (NULL);
+ BOOL bInitialOptionValue = NeedPeriodicDeviceListUpdate;
- if (BootEncObj.GetStatus().DriveMounted)
+ /* Global System Favorites settings */
+
+ if (SystemFavoritesMode)
{
- try
- {
- uint32 reqConfig = IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT) ? TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES : 0;
- if (reqConfig != (ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES))
- BootEncObj.SetDriverConfigurationFlag (TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES, reqConfig ? true : false);
+ BootEncryption BootEncObj (NULL);
- SetDriverConfigurationFlag (TC_DRIVER_CONFIG_DISABLE_NONADMIN_SYS_FAVORITES_ACCESS, IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_DISABLE_HOTKEY));
- }
- catch (Exception &e)
+ if (BootEncObj.GetStatus().DriveMounted)
{
- e.Show (hwndDlg);
+ try
+ {
+ uint32 reqConfig = IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT) ? TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES : 0;
+ if (reqConfig != (ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES))
+ BootEncObj.SetDriverConfigurationFlag (TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES, reqConfig ? true : false);
+
+ if (!BootEncObj.IsSystemFavoritesServiceRunning())
+ {
+ // The system favorites service should be always running
+ // If it is stopped for some reason, we reconfigure it
+ BootEncObj.RegisterSystemFavoritesService (TRUE);
+ }
+
+ SetDriverConfigurationFlag (TC_DRIVER_CONFIG_DISABLE_NONADMIN_SYS_FAVORITES_ACCESS, IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_DISABLE_HOTKEY));
+ }
+ catch (Exception &e)
+ {
+ e.Show (hwndDlg);
+ }
}
}
- }
- /* (System) Favorites list */
+ /* (System) Favorites list */
- if (SelectedItem != -1 && !Favorites.empty())
- SetFavoriteVolume (hwndDlg, Favorites[SelectedItem], SystemFavoritesMode);
+ if (SelectedItem != -1 && !Favorites.empty())
+ SetFavoriteVolume (hwndDlg, Favorites[SelectedItem], SystemFavoritesMode);
- if (SaveFavoriteVolumes (hwndDlg, Favorites, SystemFavoritesMode))
- {
- if (!SystemFavoritesMode)
+ if (SaveFavoriteVolumes (hwndDlg, Favorites, SystemFavoritesMode))
{
- bMountFavoritesOnLogon = FALSE;
-
- foreach (const FavoriteVolume &favorite, Favorites)
+ if (!SystemFavoritesMode)
{
- if (favorite.MountOnLogOn)
+ bMountFavoritesOnLogon = FALSE;
+
+ foreach (const FavoriteVolume &favorite, Favorites)
{
- bMountFavoritesOnLogon = TRUE;
- break;
+ if (favorite.MountOnLogOn)
+ {
+ bMountFavoritesOnLogon = TRUE;
+ break;
+ }
}
- }
- if (!bEnableBkgTask || bCloseBkgTaskWhenNoVolumes || IsNonInstallMode())
- {
- foreach (const FavoriteVolume favorite, Favorites)
+ if (!bEnableBkgTask || bCloseBkgTaskWhenNoVolumes || IsNonInstallMode())
{
- if (favorite.MountOnArrival)
+ foreach (const FavoriteVolume favorite, Favorites)
{
- Warning ("FAVORITE_ARRIVAL_MOUNT_BACKGROUND_TASK_ERR", hwndDlg);
- break;
+ if (favorite.MountOnArrival)
+ {
+ Warning ("FAVORITE_ARRIVAL_MOUNT_BACKGROUND_TASK_ERR", hwndDlg);
+ break;
+ }
}
}
- }
- FavoriteVolumes = Favorites;
+ if (!bInitialOptionValue && NeedPeriodicDeviceListUpdate)
+ {
+ // a favorite was set to use VolumeID. We update the list of devices available for mounting as early as possible
+ UpdateMountableHostDeviceList ();
+ }
+
+ FavoriteVolumes = Favorites;
- ManageStartupSeq();
- SaveSettings (hwndDlg);
- }
- else
- SystemFavoriteVolumes = Favorites;
+ ManageStartupSeq();
+ SaveSettings (hwndDlg);
+ }
+ else
+ SystemFavoriteVolumes = Favorites;
- OnFavoriteVolumesUpdated();
- LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), 0);
+ OnFavoriteVolumesUpdated();
+ LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), 0);
- EndDialog (hwndDlg, IDOK);
+ EndDialog (hwndDlg, IDOK);
+ }
}
-
return 1;
case IDCANCEL:
@@ -554,6 +569,7 @@ namespace VeraCrypt
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation)
{
+ bool bVolumeIdInUse = false;
favorites.clear();
wstring favoritesFilePath = systemFavorites ? GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false) : GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES);
@@ -701,10 +717,21 @@ 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);
}
@@ -763,6 +790,7 @@ namespace VeraCrypt
{
FILE *f;
int cnt = 0;
+ bool bVolumeIdInUse = false;
f = _wfopen (GetConfigPath (systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES), L"w,ccs=UTF-8");
if (f == NULL)
@@ -827,7 +855,11 @@ namespace VeraCrypt
s += L" useLabelInExplorer=\"1\"";
if (favorite.UseVolumeID && !IsRepeatedByteArray (0, favorite.VolumeID, sizeof (favorite.VolumeID)))
+ {
s += L" useVolumeID=\"1\"";
+ if (!systemFavorites)
+ bVolumeIdInUse = true;
+ }
s += L">" + wstring (tq) + L"</volume>";
@@ -838,6 +870,14 @@ namespace VeraCrypt
fputws (L"\n\t</favorites>", f);
XmlWriteFooter (f);
+ if (!systemFavorites)
+ {
+ if (bVolumeIdInUse && !DisablePeriodicDeviceListUpdate)
+ NeedPeriodicDeviceListUpdate = TRUE;
+ else
+ NeedPeriodicDeviceListUpdate = FALSE;
+ }
+
if (!CheckFileStreamWriteErrors (hwndDlg, f, systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES))
{
fclose (f);