VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-09-09 23:33:30 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-09-10 01:44:14 +0200
commit957ff20f37d25927cf48efb52289f6c6a60f1e0b (patch)
tree16da07185c5275486854fc19e214d2996ef89e5c /src/Mount
parentec7b5cd7e63bf78fa98c9b9713846b99b835dd71 (diff)
downloadVeraCrypt-957ff20f37d25927cf48efb52289f6c6a60f1e0b.tar.gz
VeraCrypt-957ff20f37d25927cf48efb52289f6c6a60f1e0b.zip
Windows: Implement waiting dialog for Mount All Favorites Volumes operation.
Diffstat (limited to 'src/Mount')
-rw-r--r--src/Mount/Mount.c58
-rw-r--r--src/Mount/Mount.h4
2 files changed, 29 insertions, 33 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 5c28bf93..af661312 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -4356,7 +4356,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
bPrebootPasswordDlgMode = mountOptions.PartitionInInactiveSysEncScope;
if (nDosDriveNo == 0)
- nDosDriveNo = HIWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))) - 'A';
+ nDosDriveNo = HIWORD (GetSelectedLong (GetDlgItem (MainDlg, IDC_DRIVELIST))) - 'A';
if (!MultipleMountOperationInProgress)
{
@@ -4508,7 +4508,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
if (bBeep)
MessageBeep (0xFFFFFFFF);
- RefreshMainDlg(hwndDlg);
+ RefreshMainDlg(MainDlg);
if (bExplore)
{
@@ -6526,7 +6526,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (!mountedAndNotDisconnected)
{
FavoriteMountOnArrivalInProgress = TRUE;
- MountFavoriteVolumes (FALSE, FALSE, FALSE, favorite);
+ MountFavoriteVolumes (hwndDlg, FALSE, FALSE, FALSE, favorite);
FavoriteMountOnArrivalInProgress = FALSE;
FavoritesMountedOnArrivalStillConnected.push_back (favorite);
@@ -7801,7 +7801,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
if (lw == IDM_MOUNT_FAVORITE_VOLUMES)
{
- _beginthread(mountFavoriteVolumeThreadFunction, 0, NULL);
+ ShowWaitDialog (hwndDlg, TRUE, mountFavoriteVolumeThreadFunction, NULL);
return 1;
}
@@ -7875,13 +7875,13 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
}
else
{
- mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
- pParam->systemFavorites = FALSE;
- pParam->logOnMount = FALSE;
- pParam->hotKeyMount = FALSE;
- pParam->favoriteVolumeToMount = &FavoriteVolumes[favoriteIndex];
+ mountFavoriteVolumeThreadParam param;
+ param.systemFavorites = FALSE;
+ param.logOnMount = FALSE;
+ param.hotKeyMount = FALSE;
+ param.favoriteVolumeToMount = &FavoriteVolumes[favoriteIndex];
- _beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
+ ShowWaitDialog (hwndDlg, TRUE, mountFavoriteVolumeThreadFunction, &param);
}
}
@@ -8435,7 +8435,7 @@ static VOID WINAPI SystemFavoritesServiceMain (DWORD argc, LPTSTR *argv)
try
{
- status = MountFavoriteVolumes (TRUE);
+ status = MountFavoriteVolumes (NULL, TRUE);
}
catch (...) { }
@@ -8703,7 +8703,7 @@ void DismountIdleVolumes ()
}
}
-static BOOL MountFavoriteVolumeBase (const FavoriteVolume &favorite, BOOL& lastbExplore, BOOL& userForcedReadOnly, BOOL systemFavorites, BOOL logOnMount, BOOL hotKeyMount, const FavoriteVolume &favoriteVolumeToMount)
+static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite, BOOL& lastbExplore, BOOL& userForcedReadOnly, BOOL systemFavorites, BOOL logOnMount, BOOL hotKeyMount, const FavoriteVolume &favoriteVolumeToMount)
{
BOOL status = TRUE;
int drive;
@@ -8763,7 +8763,7 @@ static BOOL MountFavoriteVolumeBase (const FavoriteVolume &favorite, BOOL& lastb
else
mountOptions.ProtectedHidVolPkcs5Prf = CmdVolumePkcs5;
mountOptions.ProtectedHidVolPim = CmdVolumePim;
- if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_MOUNT_OPTIONS), MainDlg, (DLGPROC) MountOptionsDlgProc, (LPARAM) &mountOptions) == IDCANCEL)
+ if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_MOUNT_OPTIONS), hwnd, (DLGPROC) MountOptionsDlgProc, (LPARAM) &mountOptions) == IDCANCEL)
{
status = FALSE;
goto skipMount;
@@ -8775,7 +8775,7 @@ static BOOL MountFavoriteVolumeBase (const FavoriteVolume &favorite, BOOL& lastb
if (ServiceMode)
SystemFavoritesServiceLogInfo (string ("Mounting system favorite \"") + favorite.Path + "\"");
- status = Mount (MainDlg, drive, (char *) favorite.Path.c_str(), favorite.Pim);
+ status = Mount (hwnd, drive, (char *) favorite.Path.c_str(), favorite.Pim);
if (ServiceMode)
{
@@ -8837,7 +8837,7 @@ skipMount:
}
-BOOL MountFavoriteVolumes (BOOL systemFavorites, BOOL logOnMount, BOOL hotKeyMount, const FavoriteVolume &favoriteVolumeToMount)
+BOOL MountFavoriteVolumes (HWND hwnd, BOOL systemFavorites, BOOL logOnMount, BOOL hotKeyMount, const FavoriteVolume &favoriteVolumeToMount)
{
BOOL bRet = TRUE, status = TRUE;
BOOL lastbExplore;
@@ -8899,7 +8899,7 @@ BOOL MountFavoriteVolumes (BOOL systemFavorites, BOOL logOnMount, BOOL hotKeyMou
continue;
}
- status = MountFavoriteVolumeBase (favorite, lastbExplore, userForcedReadOnly, systemFavorites, logOnMount, hotKeyMount, favoriteVolumeToMount);
+ status = MountFavoriteVolumeBase (hwnd, favorite, lastbExplore, userForcedReadOnly, systemFavorites, logOnMount, hotKeyMount, favoriteVolumeToMount);
if (!status)
bRet = FALSE;
}
@@ -8938,7 +8938,7 @@ BOOL MountFavoriteVolumes (BOOL systemFavorites, BOOL logOnMount, BOOL hotKeyMou
// favorite OK.
SystemFavoritesServiceLogInfo (string ("Favorite \"") + favorite->VolumePathId + "\" is connected. Performing mount.");
- status = MountFavoriteVolumeBase (*favorite, lastbExplore, userForcedReadOnly, systemFavorites, logOnMount, hotKeyMount, favoriteVolumeToMount);
+ status = MountFavoriteVolumeBase (hwnd, *favorite, lastbExplore, userForcedReadOnly, systemFavorites, logOnMount, hotKeyMount, favoriteVolumeToMount);
if (!status)
bRet = FALSE;
}
@@ -8968,24 +8968,19 @@ BOOL MountFavoriteVolumes (BOOL systemFavorites, BOOL logOnMount, BOOL hotKeyMou
return bRet;
}
-void __cdecl mountFavoriteVolumeThreadFunction (void *pArg)
+void CALLBACK mountFavoriteVolumeThreadFunction (void *pArg, HWND hwnd)
{
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));
+ MountFavoriteVolumes (hwnd, pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount, *(pParam->favoriteVolumeToMount));
else
- MountFavoriteVolumes (pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount);
-
- free(pParam);
+ MountFavoriteVolumes (hwnd, pParam->systemFavorites, pParam->logOnMount, pParam->hotKeyMount);
}
else
- MountFavoriteVolumes ();
+ MountFavoriteVolumes (hwnd);
}
@@ -9121,12 +9116,13 @@ static void HandleHotKey (HWND hwndDlg, WPARAM wParam)
case HK_MOUNT_FAVORITE_VOLUMES:
{
- mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
- pParam->systemFavorites = FALSE;
- pParam->logOnMount = FALSE;
- pParam->hotKeyMount = TRUE;
+ mountFavoriteVolumeThreadParam param;
+ param.systemFavorites = FALSE;
+ param.logOnMount = FALSE;
+ param.hotKeyMount = TRUE;
+ param.favoriteVolumeToMount = NULL;
- _beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
+ ShowWaitDialog (hwndDlg, TRUE, mountFavoriteVolumeThreadFunction, &param);
}
break;
diff --git a/src/Mount/Mount.h b/src/Mount/Mount.h
index a816dd67..dcae9921 100644
--- a/src/Mount/Mount.h
+++ b/src/Mount/Mount.h
@@ -126,7 +126,7 @@ typedef struct
} 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 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);
#endif