mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-28 05:53:29 +01:00
Windows: Use periodic update of connected devices only if there is a Favorite that uses VolumeID. Add command option to disable the period update of devices.
This commit is contained in:
parent
7d88577c61
commit
909255d55f
@ -188,6 +188,9 @@ BOOL MountVolumesAsSystemFavorite = FALSE;
|
|||||||
BOOL FavoriteMountOnArrivalInProgress = FALSE;
|
BOOL FavoriteMountOnArrivalInProgress = FALSE;
|
||||||
BOOL MultipleMountOperationInProgress = FALSE;
|
BOOL MultipleMountOperationInProgress = FALSE;
|
||||||
|
|
||||||
|
volatile BOOL NeedPeriodicDeviceListUpdate = FALSE;
|
||||||
|
BOOL DisablePeriodicDeviceListUpdate = FALSE;
|
||||||
|
|
||||||
BOOL WaitDialogDisplaying = FALSE;
|
BOOL WaitDialogDisplaying = FALSE;
|
||||||
|
|
||||||
/* Handle to the device driver */
|
/* Handle to the device driver */
|
||||||
@ -12530,7 +12533,7 @@ wstring FindDeviceByVolumeID (const BYTE volumeID [VOLUME_ID_SIZE], BOOL bFromSe
|
|||||||
|
|
||||||
/* not mounted. Look for it in the local drives*/
|
/* not mounted. Look for it in the local drives*/
|
||||||
|
|
||||||
if (bFromService)
|
if (bFromService || !NeedPeriodicDeviceListUpdate)
|
||||||
{
|
{
|
||||||
for (int devNumber = 0; devNumber < MAX_HOST_DRIVE_NUMBER; devNumber++)
|
for (int devNumber = 0; devNumber < MAX_HOST_DRIVE_NUMBER; devNumber++)
|
||||||
{
|
{
|
||||||
|
@ -165,6 +165,9 @@ extern BOOL MountVolumesAsSystemFavorite;
|
|||||||
extern BOOL FavoriteMountOnArrivalInProgress;
|
extern BOOL FavoriteMountOnArrivalInProgress;
|
||||||
extern BOOL MultipleMountOperationInProgress;
|
extern BOOL MultipleMountOperationInProgress;
|
||||||
|
|
||||||
|
extern volatile BOOL NeedPeriodicDeviceListUpdate;
|
||||||
|
extern BOOL DisablePeriodicDeviceListUpdate;
|
||||||
|
|
||||||
#ifndef SETUP
|
#ifndef SETUP
|
||||||
extern BOOL bLanguageSetInSetup;
|
extern BOOL bLanguageSetInSetup;
|
||||||
#endif
|
#endif
|
||||||
|
@ -243,76 +243,84 @@ namespace VeraCrypt
|
|||||||
switch (lw)
|
switch (lw)
|
||||||
{
|
{
|
||||||
case IDOK:
|
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
|
BootEncryption BootEncObj (NULL);
|
||||||
|
|
||||||
|
if (BootEncObj.GetStatus().DriveMounted)
|
||||||
{
|
{
|
||||||
uint32 reqConfig = IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT) ? TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES : 0;
|
try
|
||||||
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);
|
|
||||||
|
|
||||||
SetDriverConfigurationFlag (TC_DRIVER_CONFIG_DISABLE_NONADMIN_SYS_FAVORITES_ACCESS, IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_DISABLE_HOTKEY));
|
|
||||||
}
|
|
||||||
catch (Exception &e)
|
|
||||||
{
|
|
||||||
e.Show (hwndDlg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (System) Favorites list */
|
|
||||||
|
|
||||||
if (SelectedItem != -1 && !Favorites.empty())
|
|
||||||
SetFavoriteVolume (hwndDlg, Favorites[SelectedItem], SystemFavoritesMode);
|
|
||||||
|
|
||||||
if (SaveFavoriteVolumes (hwndDlg, Favorites, SystemFavoritesMode))
|
|
||||||
{
|
|
||||||
if (!SystemFavoritesMode)
|
|
||||||
{
|
|
||||||
bMountFavoritesOnLogon = FALSE;
|
|
||||||
|
|
||||||
foreach (const FavoriteVolume &favorite, Favorites)
|
|
||||||
{
|
|
||||||
if (favorite.MountOnLogOn)
|
|
||||||
{
|
{
|
||||||
bMountFavoritesOnLogon = TRUE;
|
uint32 reqConfig = IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT) ? TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES : 0;
|
||||||
break;
|
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);
|
||||||
|
|
||||||
|
SetDriverConfigurationFlag (TC_DRIVER_CONFIG_DISABLE_NONADMIN_SYS_FAVORITES_ACCESS, IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_DISABLE_HOTKEY));
|
||||||
|
}
|
||||||
|
catch (Exception &e)
|
||||||
|
{
|
||||||
|
e.Show (hwndDlg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!bEnableBkgTask || bCloseBkgTaskWhenNoVolumes || IsNonInstallMode())
|
/* (System) Favorites list */
|
||||||
|
|
||||||
|
if (SelectedItem != -1 && !Favorites.empty())
|
||||||
|
SetFavoriteVolume (hwndDlg, Favorites[SelectedItem], SystemFavoritesMode);
|
||||||
|
|
||||||
|
if (SaveFavoriteVolumes (hwndDlg, Favorites, SystemFavoritesMode))
|
||||||
|
{
|
||||||
|
if (!SystemFavoritesMode)
|
||||||
{
|
{
|
||||||
foreach (const FavoriteVolume favorite, Favorites)
|
bMountFavoritesOnLogon = FALSE;
|
||||||
|
|
||||||
|
foreach (const FavoriteVolume &favorite, Favorites)
|
||||||
{
|
{
|
||||||
if (favorite.MountOnArrival)
|
if (favorite.MountOnLogOn)
|
||||||
{
|
{
|
||||||
Warning ("FAVORITE_ARRIVAL_MOUNT_BACKGROUND_TASK_ERR", hwndDlg);
|
bMountFavoritesOnLogon = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bEnableBkgTask || bCloseBkgTaskWhenNoVolumes || IsNonInstallMode())
|
||||||
|
{
|
||||||
|
foreach (const FavoriteVolume favorite, Favorites)
|
||||||
|
{
|
||||||
|
if (favorite.MountOnArrival)
|
||||||
|
{
|
||||||
|
Warning ("FAVORITE_ARRIVAL_MOUNT_BACKGROUND_TASK_ERR", hwndDlg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
FavoriteVolumes = Favorites;
|
OnFavoriteVolumesUpdated();
|
||||||
|
LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), 0);
|
||||||
|
|
||||||
ManageStartupSeq();
|
EndDialog (hwndDlg, IDOK);
|
||||||
SaveSettings (hwndDlg);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
SystemFavoriteVolumes = Favorites;
|
|
||||||
|
|
||||||
OnFavoriteVolumesUpdated();
|
|
||||||
LoadDriveLetters (hwndDlg, GetDlgItem (MainDlg, IDC_DRIVELIST), 0);
|
|
||||||
|
|
||||||
EndDialog (hwndDlg, IDOK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case IDCANCEL:
|
case IDCANCEL:
|
||||||
@ -554,6 +562,7 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation)
|
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation)
|
||||||
{
|
{
|
||||||
|
bool bVolumeIdInUse = false;
|
||||||
favorites.clear();
|
favorites.clear();
|
||||||
wstring favoritesFilePath = systemFavorites ? GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false) : GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES);
|
wstring favoritesFilePath = systemFavorites ? GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false) : GetConfigPath (TC_APPD_FILENAME_FAVORITE_VOLUMES);
|
||||||
|
|
||||||
@ -701,10 +710,21 @@ namespace VeraCrypt
|
|||||||
favorite.Pkcs5 = -1;
|
favorite.Pkcs5 = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!systemFavorites && favorite.UseVolumeID)
|
||||||
|
bVolumeIdInUse = true;
|
||||||
|
|
||||||
favorites.push_back (favorite);
|
favorites.push_back (favorite);
|
||||||
xml++;
|
xml++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!systemFavorites)
|
||||||
|
{
|
||||||
|
if (bVolumeIdInUse && !DisablePeriodicDeviceListUpdate)
|
||||||
|
NeedPeriodicDeviceListUpdate = TRUE;
|
||||||
|
else
|
||||||
|
NeedPeriodicDeviceListUpdate = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
free (favoritesXml);
|
free (favoritesXml);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,6 +783,7 @@ namespace VeraCrypt
|
|||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int cnt = 0;
|
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");
|
f = _wfopen (GetConfigPath (systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES), L"w,ccs=UTF-8");
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
@ -827,7 +848,11 @@ namespace VeraCrypt
|
|||||||
s += L" useLabelInExplorer=\"1\"";
|
s += L" useLabelInExplorer=\"1\"";
|
||||||
|
|
||||||
if (favorite.UseVolumeID && !IsRepeatedByteArray (0, favorite.VolumeID, sizeof (favorite.VolumeID)))
|
if (favorite.UseVolumeID && !IsRepeatedByteArray (0, favorite.VolumeID, sizeof (favorite.VolumeID)))
|
||||||
|
{
|
||||||
s += L" useVolumeID=\"1\"";
|
s += L" useVolumeID=\"1\"";
|
||||||
|
if (!systemFavorites)
|
||||||
|
bVolumeIdInUse = true;
|
||||||
|
}
|
||||||
|
|
||||||
s += L">" + wstring (tq) + L"</volume>";
|
s += L">" + wstring (tq) + L"</volume>";
|
||||||
|
|
||||||
@ -838,6 +863,14 @@ namespace VeraCrypt
|
|||||||
fputws (L"\n\t</favorites>", f);
|
fputws (L"\n\t</favorites>", f);
|
||||||
XmlWriteFooter (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))
|
if (!CheckFileStreamWriteErrors (hwndDlg, f, systemFavorites ? TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES : TC_APPD_FILENAME_FAVORITE_VOLUMES))
|
||||||
{
|
{
|
||||||
fclose (f);
|
fclose (f);
|
||||||
|
@ -512,8 +512,11 @@ static void InitMainDialog (HWND hwndDlg)
|
|||||||
e.Show (NULL);
|
e.Show (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// initialize the list of devices available for mounting as early as possible
|
if (NeedPeriodicDeviceListUpdate)
|
||||||
UpdateMountableHostDeviceList ();
|
{
|
||||||
|
// initialize the list of devices available for mounting as early as possible
|
||||||
|
UpdateMountableHostDeviceList ();
|
||||||
|
}
|
||||||
|
|
||||||
if (Silent)
|
if (Silent)
|
||||||
LoadDriveLetters (hwndDlg, NULL, 0);
|
LoadDriveLetters (hwndDlg, NULL, 0);
|
||||||
@ -7337,7 +7340,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
{
|
{
|
||||||
if (wParam == TIMER_ID_UPDATE_DEVICE_LIST)
|
if (wParam == TIMER_ID_UPDATE_DEVICE_LIST)
|
||||||
{
|
{
|
||||||
UpdateMountableHostDeviceList ();
|
if (NeedPeriodicDeviceListUpdate)
|
||||||
|
UpdateMountableHostDeviceList ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -8873,6 +8877,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
|||||||
OptionTryEmptyPassword,
|
OptionTryEmptyPassword,
|
||||||
OptionNoWaitDlg,
|
OptionNoWaitDlg,
|
||||||
OptionSecureDesktop,
|
OptionSecureDesktop,
|
||||||
|
OptionDisableDeviceUpdate,
|
||||||
};
|
};
|
||||||
|
|
||||||
argument args[]=
|
argument args[]=
|
||||||
@ -8901,6 +8906,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
|||||||
{ OptionTryEmptyPassword, L"/tryemptypass", NULL, FALSE },
|
{ OptionTryEmptyPassword, L"/tryemptypass", NULL, FALSE },
|
||||||
{ OptionNoWaitDlg, L"/nowaitdlg", NULL, FALSE },
|
{ OptionNoWaitDlg, L"/nowaitdlg", NULL, FALSE },
|
||||||
{ OptionSecureDesktop, L"/secureDesktop", NULL, FALSE },
|
{ OptionSecureDesktop, L"/secureDesktop", NULL, FALSE },
|
||||||
|
{ OptionDisableDeviceUpdate, L"/disableDeviceUpdate", NULL, FALSE },
|
||||||
};
|
};
|
||||||
|
|
||||||
argumentspec as;
|
argumentspec as;
|
||||||
@ -8991,6 +8997,12 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case OptionDisableDeviceUpdate:
|
||||||
|
{
|
||||||
|
DisablePeriodicDeviceListUpdate = TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case OptionCache:
|
case OptionCache:
|
||||||
{
|
{
|
||||||
wchar_t szTmp[16] = {0};
|
wchar_t szTmp[16] = {0};
|
||||||
@ -9530,8 +9542,6 @@ static VOID WINAPI SystemFavoritesServiceMain (DWORD argc, LPTSTR *argv)
|
|||||||
SystemFavoritesServiceSetStatus (SERVICE_START_PENDING, 120000);
|
SystemFavoritesServiceSetStatus (SERVICE_START_PENDING, 120000);
|
||||||
|
|
||||||
SystemFavoritesServiceLogInfo (wstring (L"Initializing list of host devices"));
|
SystemFavoritesServiceLogInfo (wstring (L"Initializing list of host devices"));
|
||||||
// initialize the list of devices available for mounting as early as possible
|
|
||||||
UpdateMountableHostDeviceList ();
|
|
||||||
|
|
||||||
SystemFavoritesServiceLogInfo (wstring (L"Starting System Favorites mounting process"));
|
SystemFavoritesServiceLogInfo (wstring (L"Starting System Favorites mounting process"));
|
||||||
|
|
||||||
@ -10112,9 +10122,6 @@ BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOO
|
|||||||
{
|
{
|
||||||
Sleep (5000);
|
Sleep (5000);
|
||||||
|
|
||||||
SystemFavoritesServiceLogInfo (wstring (L"Updating list of host devices"));
|
|
||||||
UpdateMountableHostDeviceList ();
|
|
||||||
|
|
||||||
SystemFavoritesServiceLogInfo (wstring (L"Trying to mount skipped system favorites"));
|
SystemFavoritesServiceLogInfo (wstring (L"Trying to mount skipped system favorites"));
|
||||||
|
|
||||||
// Update the service status to avoid being killed
|
// Update the service status to avoid being killed
|
||||||
|
Loading…
Reference in New Issue
Block a user