From 2061b4c28ca189781dc9d2625f1bd4899fccbd81 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 10 Feb 2019 22:48:06 +0100 Subject: Windows: Ensure that only one thread at a time can create a secure desktop --- src/Common/Dlgcode.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/Common') diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index c8efe2a7..12ca8543 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -214,6 +214,9 @@ CRITICAL_SECTION csVolumeIdCandidates; static std::vector mountableDevices; static std::vector rawHostDeviceList; +/* Critical section used to ensure that only one thread at a time can create a secure desktop */ +CRITICAL_SECTION csSecureDesktop; + HINSTANCE hInst = NULL; HCURSOR hCursor = NULL; @@ -445,6 +448,7 @@ void InitGlobalLocks () InitializeCriticalSection (&csWNetCalls); InitializeCriticalSection (&csMountableDevices); InitializeCriticalSection (&csVolumeIdCandidates); + InitializeCriticalSection (&csSecureDesktop); } void FinalizeGlobalLocks () @@ -452,6 +456,7 @@ void FinalizeGlobalLocks () DeleteCriticalSection (&csWNetCalls); DeleteCriticalSection (&csMountableDevices); DeleteCriticalSection (&csVolumeIdCandidates); + DeleteCriticalSection (&csSecureDesktop); } void cleanup () @@ -13556,6 +13561,9 @@ INT_PTR SecureDesktopDialogBoxParam( HDESK hInputDesk = NULL; + EnterCriticalSection (&csSecureDesktop); + finally_do ({ LeaveCriticalSection (&csSecureDesktop); }); + // wait for the input desktop to be available before switching to // secure desktop. Under Windows 10, the user session can be started // in the background even before the user has authenticated and in this -- cgit v1.2.3