1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Windows: avoid freezing the wait dialog by setting its parent to desktop when having lengthy driver calls (like mounting)

This commit is contained in:
Mounir IDRASSI
2015-09-11 00:25:23 +02:00
parent fe6ea62363
commit 89a7fad16d
3 changed files with 29 additions and 18 deletions

View File

@@ -6606,6 +6606,11 @@ void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, v
else else
{ {
WaitDialogDisplaying = TRUE; WaitDialogDisplaying = TRUE;
if (hwnd)
EnableWindow (hwnd, FALSE);
else
EnableWindow (MainDlg, FALSE);
finally_do_arg (HWND, hwnd, { if (finally_arg) EnableWindow(finally_arg, TRUE); else EnableWindow (MainDlg, TRUE);});
DialogBoxParamW (hInst, DialogBoxParamW (hInst,
MAKEINTRESOURCEW (IDD_STATIC_MODAL_WAIT_DLG), hParent, MAKEINTRESOURCEW (IDD_STATIC_MODAL_WAIT_DLG), hParent,
@@ -7084,7 +7089,7 @@ retry:
} }
else else
{ {
ShowWaitDialog (hwndDlg, TRUE, UnmountWaitThreadProc, &param); ShowWaitDialog (hwndDlg, FALSE, UnmountWaitThreadProc, &param);
} }
SetLastError (param.dwLastError); SetLastError (param.dwLastError);

View File

@@ -4709,7 +4709,7 @@ retry:
if (interact && !Silent) if (interact && !Silent)
{ {
ShowWaitDialog (hwndDlg, TRUE, DismountAllThreadProc, &dismountAllThreadParam); ShowWaitDialog (hwndDlg, FALSE, DismountAllThreadProc, &dismountAllThreadParam);
} }
else else
DismountAllThreadProc (&dismountAllThreadParam, hwndDlg); DismountAllThreadProc (&dismountAllThreadParam, hwndDlg);
@@ -5051,7 +5051,7 @@ static BOOL MountAllDevices (HWND hwndDlg, BOOL bPasswordPrompt)
param.bPasswordPrompt = bPasswordPrompt; param.bPasswordPrompt = bPasswordPrompt;
param.bRet = FALSE; param.bRet = FALSE;
ShowWaitDialog (hwndDlg, TRUE, mountAllDevicesThreadProc, &param); ShowWaitDialog (hwndDlg, FALSE, mountAllDevicesThreadProc, &param);
return param.bRet; return param.bRet;
} }
@@ -7801,7 +7801,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDM_MOUNT_FAVORITE_VOLUMES) if (lw == IDM_MOUNT_FAVORITE_VOLUMES)
{ {
ShowWaitDialog (hwndDlg, TRUE, mountFavoriteVolumeThreadFunction, NULL); _beginthread(mountFavoriteVolumeThreadFunction, 0, NULL);
return 1; return 1;
} }
@@ -7875,13 +7875,13 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
} }
else else
{ {
mountFavoriteVolumeThreadParam param; mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
param.systemFavorites = FALSE; pParam->systemFavorites = FALSE;
param.logOnMount = FALSE; pParam->logOnMount = FALSE;
param.hotKeyMount = FALSE; pParam->hotKeyMount = FALSE;
param.favoriteVolumeToMount = &FavoriteVolumes[favoriteIndex]; pParam->favoriteVolumeToMount = &FavoriteVolumes[favoriteIndex];
ShowWaitDialog (hwndDlg, TRUE, mountFavoriteVolumeThreadFunction, &param); _beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
} }
} }
@@ -8968,7 +8968,7 @@ BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOO
return bRet; return bRet;
} }
void CALLBACK mountFavoriteVolumeThreadFunction (void *pArg, HWND hwnd) void CALLBACK mountFavoriteVolumeCallbackFunction (void *pArg, HWND hwnd)
{ {
mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) pArg; mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) pArg;
@@ -8978,11 +8978,17 @@ void CALLBACK mountFavoriteVolumeThreadFunction (void *pArg, HWND hwnd)
MountFavoriteVolumes (hwnd, pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount, *(pParam->favoriteVolumeToMount)); MountFavoriteVolumes (hwnd, pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount, *(pParam->favoriteVolumeToMount));
else else
MountFavoriteVolumes (hwnd, pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount); MountFavoriteVolumes (hwnd, pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount);
free (pParam);
} }
else else
MountFavoriteVolumes (hwnd); MountFavoriteVolumes (hwnd);
} }
void __cdecl mountFavoriteVolumeThreadFunction (void *pArg)
{
ShowWaitDialog (NULL, FALSE, mountFavoriteVolumeCallbackFunction, pArg);
}
static void SaveDefaultKeyFilesParam (HWND hwnd) static void SaveDefaultKeyFilesParam (HWND hwnd)
{ {
@@ -9116,13 +9122,13 @@ static void HandleHotKey (HWND hwndDlg, WPARAM wParam)
case HK_MOUNT_FAVORITE_VOLUMES: case HK_MOUNT_FAVORITE_VOLUMES:
{ {
mountFavoriteVolumeThreadParam param; mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
param.systemFavorites = FALSE; pParam->systemFavorites = FALSE;
param.logOnMount = FALSE; pParam->logOnMount = FALSE;
param.hotKeyMount = TRUE; pParam->hotKeyMount = TRUE;
param.favoriteVolumeToMount = NULL; pParam->favoriteVolumeToMount = NULL;
ShowWaitDialog (hwndDlg, TRUE, mountFavoriteVolumeThreadFunction, &param); _beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
} }
break; break;

View File

@@ -127,6 +127,6 @@ typedef struct
void SetDriverConfigurationFlag (uint32 flag, BOOL state); void SetDriverConfigurationFlag (uint32 flag, BOOL state);
BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites = FALSE, BOOL logOnMount = FALSE, BOOL hotKeyMount = FALSE, const VeraCrypt::FavoriteVolume &favoriteVolumeToMount = VeraCrypt::FavoriteVolume()); BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites = FALSE, BOOL logOnMount = FALSE, BOOL hotKeyMount = FALSE, const VeraCrypt::FavoriteVolume &favoriteVolumeToMount = VeraCrypt::FavoriteVolume());
void CALLBACK mountFavoriteVolumeThreadFunction (void *pArg, HWND hwnd); void __cdecl mountFavoriteVolumeThreadFunction (void *pArg);
#endif #endif