VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-12-26 15:53:55 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-12-26 15:55:21 (GMT)
commit258ba629a2dc1af61b2fade1e040830080ffcc57 (patch)
treecb095dbf7cd4740518f358c353a8e122c0057ee2 /src/Mount
parentd90d9f0c401a21c85a525aaca0b97df8f7955db8 (diff)
downloadVeraCrypt-258ba629a2dc1af61b2fade1e040830080ffcc57.zip
VeraCrypt-258ba629a2dc1af61b2fade1e040830080ffcc57.tar.gz
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.
Diffstat (limited to 'src/Mount')
-rw-r--r--src/Mount/Mount.c59
-rw-r--r--src/Mount/Mount.h9
2 files changed, 61 insertions, 7 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 969b43d..263cce9 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -3707,6 +3707,16 @@ static BOOL Dismount (HWND hwndDlg, int nDosDriveNo)
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)
{
BOOL status = TRUE;
@@ -5745,7 +5755,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
if (CheckMountList (FALSE))
- Mount (hwndDlg, 0, 0);
+ _beginthread(mountThreadFunction, 0, hwndDlg);
}
return 1;
}
@@ -5872,7 +5882,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
bPrebootPasswordDlgMode = FALSE;
if (CheckMountList (FALSE))
- Mount (hwndDlg, 0, 0);
+ _beginthread(mountThreadFunction, 0, hwndDlg);
}
break;
@@ -6015,7 +6025,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
bPrebootPasswordDlgMode = TRUE;
if (CheckMountList (FALSE))
- Mount (hwndDlg, 0, 0);
+ _beginthread(mountThreadFunction, 0, hwndDlg);
bPrebootPasswordDlgMode = FALSE;
}
@@ -6627,7 +6637,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDM_MOUNT_FAVORITE_VOLUMES)
{
- MountFavoriteVolumes();
+ _beginthread(mountFavoriteVolumeThreadFunction, 0, NULL);
return 1;
}
@@ -6680,7 +6690,15 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
NormalCursor();
}
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;
@@ -7501,6 +7519,26 @@ skipMount:
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)
{
@@ -7633,7 +7671,14 @@ static void HandleHotKey (HWND hwndDlg, WPARAM wParam)
break;
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;
case HK_SHOW_HIDE_MAIN_WINDOW:
@@ -8797,7 +8842,7 @@ void MountSelectedVolume (HWND hwndDlg, BOOL mountWithOptions)
}
if (CheckMountList (FALSE))
- Mount (hwndDlg, 0, 0);
+ _beginthread (mountThreadFunction, 0, hwndDlg);
}
else
Warning ("SELECT_FREE_DRIVE");
diff --git a/src/Mount/Mount.h b/src/Mount/Mount.h
index e982de8..9b320a8 100644
--- a/src/Mount/Mount.h
+++ b/src/Mount/Mount.h
@@ -113,8 +113,17 @@ static BOOL HandleDriveListMouseWheelEvent (UINT uMsg, WPARAM wParam, LPARAM lPa
#ifdef __cplusplus
}
+typedef struct
+{
+ BOOL systemFavorites;
+ BOOL logOnMount;
+ BOOL hotKeyMount;
+ VeraCrypt::FavoriteVolume* favoriteVolumeToMount;
+} mountFavoriteVolumeThreadParam;
+
void SetDriverConfigurationFlag (uint32 flag, BOOL state);
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);
#endif