mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Windows: workaround freezing of waiting dialog but setting its parent to the desktop and making all mount calls in a separate thread. DeviceIoControl is making our like hard because it doesn't behave as a normal system call and it blocks our window message loop even when called from a separate thread.
This commit is contained in:
@@ -310,7 +310,8 @@ BEGIN
|
|||||||
END
|
END
|
||||||
|
|
||||||
IDD_STATIC_MODAL_WAIT_DLG DIALOGEX 0, 0, 292, 61
|
IDD_STATIC_MODAL_WAIT_DLG DIALOGEX 0, 0, 292, 61
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
|
STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION
|
||||||
|
EXSTYLE WS_EX_TOPMOST
|
||||||
CAPTION "VeraCrypt"
|
CAPTION "VeraCrypt"
|
||||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|||||||
@@ -6371,7 +6371,7 @@ retry:
|
|||||||
threadParam.pdwResult = &dwResult;
|
threadParam.pdwResult = &dwResult;
|
||||||
|
|
||||||
DialogBoxParamW (hInst,
|
DialogBoxParamW (hInst,
|
||||||
MAKEINTRESOURCEW (IDD_STATIC_MODAL_WAIT_DLG), hwndDlg,
|
MAKEINTRESOURCEW (IDD_STATIC_MODAL_WAIT_DLG), GetDesktopWindow(),
|
||||||
(DLGPROC) MountWaitDlgProc, (LPARAM) &threadParam);
|
(DLGPROC) MountWaitDlgProc, (LPARAM) &threadParam);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3707,6 +3707,16 @@ static BOOL Dismount (HWND hwndDlg, int nDosDriveNo)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __cdecl mountThreadFunction (void *hwndDlgArg)
|
||||||
|
{
|
||||||
|
HWND hwndDlg =(HWND) hwndDlgArg;
|
||||||
|
// Disable parent dialog during processing to avoid user interaction
|
||||||
|
EnableWindow(hwndDlg, FALSE);
|
||||||
|
finally_do_arg (HWND, hwndDlg, { EnableWindow(finally_arg, TRUE); });
|
||||||
|
|
||||||
|
Mount (hwndDlg, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dismountMaxRetries, int dismountAutoRetryDelay)
|
static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dismountMaxRetries, int dismountAutoRetryDelay)
|
||||||
{
|
{
|
||||||
BOOL status = TRUE;
|
BOOL status = TRUE;
|
||||||
@@ -5745,7 +5755,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CheckMountList (FALSE))
|
if (CheckMountList (FALSE))
|
||||||
Mount (hwndDlg, 0, 0);
|
_beginthread(mountThreadFunction, 0, hwndDlg);
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -5872,7 +5882,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
bPrebootPasswordDlgMode = FALSE;
|
bPrebootPasswordDlgMode = FALSE;
|
||||||
|
|
||||||
if (CheckMountList (FALSE))
|
if (CheckMountList (FALSE))
|
||||||
Mount (hwndDlg, 0, 0);
|
_beginthread(mountThreadFunction, 0, hwndDlg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -6015,7 +6025,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
bPrebootPasswordDlgMode = TRUE;
|
bPrebootPasswordDlgMode = TRUE;
|
||||||
|
|
||||||
if (CheckMountList (FALSE))
|
if (CheckMountList (FALSE))
|
||||||
Mount (hwndDlg, 0, 0);
|
_beginthread(mountThreadFunction, 0, hwndDlg);
|
||||||
|
|
||||||
bPrebootPasswordDlgMode = FALSE;
|
bPrebootPasswordDlgMode = FALSE;
|
||||||
}
|
}
|
||||||
@@ -6627,7 +6637,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
if (lw == IDM_MOUNT_FAVORITE_VOLUMES)
|
if (lw == IDM_MOUNT_FAVORITE_VOLUMES)
|
||||||
{
|
{
|
||||||
MountFavoriteVolumes();
|
_beginthread(mountFavoriteVolumeThreadFunction, 0, NULL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6680,7 +6690,15 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
NormalCursor();
|
NormalCursor();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
MountFavoriteVolumes (FALSE, FALSE, FALSE, FavoriteVolumes[favoriteIndex]);
|
{
|
||||||
|
mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
|
||||||
|
pParam->systemFavorites = FALSE;
|
||||||
|
pParam->logOnMount = FALSE;
|
||||||
|
pParam->hotKeyMount = FALSE;
|
||||||
|
pParam->favoriteVolumeToMount = &FavoriteVolumes[favoriteIndex];
|
||||||
|
|
||||||
|
_beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -7501,6 +7519,26 @@ skipMount:
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void __cdecl mountFavoriteVolumeThreadFunction (void *pArg)
|
||||||
|
{
|
||||||
|
mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) pArg;
|
||||||
|
// Disable main dialog during processing to avoid user interaction
|
||||||
|
EnableWindow(MainDlg, FALSE);
|
||||||
|
finally_do ({ EnableWindow(MainDlg, TRUE); });
|
||||||
|
|
||||||
|
if (pParam)
|
||||||
|
{
|
||||||
|
if (pParam->favoriteVolumeToMount)
|
||||||
|
MountFavoriteVolumes (pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount, *(pParam->favoriteVolumeToMount));
|
||||||
|
else
|
||||||
|
MountFavoriteVolumes (pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount);
|
||||||
|
|
||||||
|
free(pParam);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
MountFavoriteVolumes ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void SaveDefaultKeyFilesParam (void)
|
static void SaveDefaultKeyFilesParam (void)
|
||||||
{
|
{
|
||||||
@@ -7633,7 +7671,14 @@ static void HandleHotKey (HWND hwndDlg, WPARAM wParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HK_MOUNT_FAVORITE_VOLUMES:
|
case HK_MOUNT_FAVORITE_VOLUMES:
|
||||||
MountFavoriteVolumes (FALSE, FALSE, TRUE);
|
{
|
||||||
|
mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
|
||||||
|
pParam->systemFavorites = FALSE;
|
||||||
|
pParam->logOnMount = FALSE;
|
||||||
|
pParam->hotKeyMount = TRUE;
|
||||||
|
|
||||||
|
_beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HK_SHOW_HIDE_MAIN_WINDOW:
|
case HK_SHOW_HIDE_MAIN_WINDOW:
|
||||||
@@ -8797,7 +8842,7 @@ void MountSelectedVolume (HWND hwndDlg, BOOL mountWithOptions)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CheckMountList (FALSE))
|
if (CheckMountList (FALSE))
|
||||||
Mount (hwndDlg, 0, 0);
|
_beginthread (mountThreadFunction, 0, hwndDlg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Warning ("SELECT_FREE_DRIVE");
|
Warning ("SELECT_FREE_DRIVE");
|
||||||
|
|||||||
@@ -113,8 +113,17 @@ static BOOL HandleDriveListMouseWheelEvent (UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
BOOL systemFavorites;
|
||||||
|
BOOL logOnMount;
|
||||||
|
BOOL hotKeyMount;
|
||||||
|
VeraCrypt::FavoriteVolume* favoriteVolumeToMount;
|
||||||
|
} mountFavoriteVolumeThreadParam;
|
||||||
|
|
||||||
void SetDriverConfigurationFlag (uint32 flag, BOOL state);
|
void SetDriverConfigurationFlag (uint32 flag, BOOL state);
|
||||||
BOOL MountFavoriteVolumes (BOOL systemFavorites = FALSE, BOOL logOnMount = FALSE, BOOL hotKeyMount = FALSE, const VeraCrypt::FavoriteVolume &favoriteVolumeToMount = VeraCrypt::FavoriteVolume());
|
BOOL MountFavoriteVolumes (BOOL systemFavorites = FALSE, BOOL logOnMount = FALSE, BOOL hotKeyMount = FALSE, const VeraCrypt::FavoriteVolume &favoriteVolumeToMount = VeraCrypt::FavoriteVolume());
|
||||||
|
void __cdecl mountFavoriteVolumeThreadFunction (void *pArg);
|
||||||
BOOL GetExecutableImageInformation (const string &path, string &version, string &description, string &companyName, string &productName);
|
BOOL GetExecutableImageInformation (const string &path, string &version, string &description, string &companyName, string &productName);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user