mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
Windows: Avoid simultaneous calls of favorites mounting, for example if corresponding hotkey is pressed multiple times.
This commit is contained in:
@@ -53,6 +53,9 @@
|
|||||||
#include <Strsafe.h>
|
#include <Strsafe.h>
|
||||||
#include <InitGuid.h>
|
#include <InitGuid.h>
|
||||||
#include <devguid.h>
|
#include <devguid.h>
|
||||||
|
#include <intrin.h>
|
||||||
|
|
||||||
|
#pragma intrinsic(_InterlockedCompareExchange, _InterlockedExchange)
|
||||||
|
|
||||||
#import <msxml6.dll> no_auto_exclude
|
#import <msxml6.dll> no_auto_exclude
|
||||||
|
|
||||||
@@ -168,6 +171,8 @@ static MOUNT_LIST_STRUCT LastKnownMountList = {0};
|
|||||||
VOLUME_NOTIFICATIONS_LIST VolumeNotificationsList;
|
VOLUME_NOTIFICATIONS_LIST VolumeNotificationsList;
|
||||||
static DWORD LastKnownLogicalDrives;
|
static DWORD LastKnownLogicalDrives;
|
||||||
|
|
||||||
|
static volatile LONG FavoriteMountOnGoing = 0;
|
||||||
|
|
||||||
static HANDLE TaskBarIconMutex = NULL;
|
static HANDLE TaskBarIconMutex = NULL;
|
||||||
static BOOL MainWindowHidden = FALSE;
|
static BOOL MainWindowHidden = FALSE;
|
||||||
static int pwdChangeDlgMode = PCDM_CHANGE_PASSWORD;
|
static int pwdChangeDlgMode = PCDM_CHANGE_PASSWORD;
|
||||||
@@ -8626,6 +8631,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
if (lw == IDM_MOUNT_FAVORITE_VOLUMES)
|
if (lw == IDM_MOUNT_FAVORITE_VOLUMES)
|
||||||
{
|
{
|
||||||
|
if (0 == _InterlockedCompareExchange(&FavoriteMountOnGoing, 1, 0))
|
||||||
_beginthread(mountFavoriteVolumeThreadFunction, 0, NULL);
|
_beginthread(mountFavoriteVolumeThreadFunction, 0, NULL);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -8706,6 +8712,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
NormalCursor();
|
NormalCursor();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (0 == _InterlockedCompareExchange(&FavoriteMountOnGoing, 1, 0))
|
||||||
{
|
{
|
||||||
mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
|
mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
|
||||||
pParam->systemFavorites = FALSE;
|
pParam->systemFavorites = FALSE;
|
||||||
@@ -8716,6 +8724,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
|||||||
_beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
|
_beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -10168,6 +10177,7 @@ void CALLBACK mountFavoriteVolumeCallbackFunction (void *pArg, HWND hwnd)
|
|||||||
void __cdecl mountFavoriteVolumeThreadFunction (void *pArg)
|
void __cdecl mountFavoriteVolumeThreadFunction (void *pArg)
|
||||||
{
|
{
|
||||||
ShowWaitDialog (MainDlg, FALSE, mountFavoriteVolumeCallbackFunction, pArg);
|
ShowWaitDialog (MainDlg, FALSE, mountFavoriteVolumeCallbackFunction, pArg);
|
||||||
|
_InterlockedExchange(&FavoriteMountOnGoing, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SaveDefaultKeyFilesParam (HWND hwnd)
|
static void SaveDefaultKeyFilesParam (HWND hwnd)
|
||||||
@@ -10301,6 +10311,8 @@ static void HandleHotKey (HWND hwndDlg, WPARAM wParam)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HK_MOUNT_FAVORITE_VOLUMES:
|
case HK_MOUNT_FAVORITE_VOLUMES:
|
||||||
|
{
|
||||||
|
if (0 == _InterlockedCompareExchange(&FavoriteMountOnGoing, 1, 0))
|
||||||
{
|
{
|
||||||
mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
|
mountFavoriteVolumeThreadParam* pParam = (mountFavoriteVolumeThreadParam*) calloc(1, sizeof(mountFavoriteVolumeThreadParam));
|
||||||
pParam->systemFavorites = FALSE;
|
pParam->systemFavorites = FALSE;
|
||||||
@@ -10310,6 +10322,7 @@ static void HandleHotKey (HWND hwndDlg, WPARAM wParam)
|
|||||||
|
|
||||||
_beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
|
_beginthread(mountFavoriteVolumeThreadFunction, 0, pParam);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HK_SHOW_HIDE_MAIN_WINDOW:
|
case HK_SHOW_HIDE_MAIN_WINDOW:
|
||||||
|
|||||||
Reference in New Issue
Block a user