Windows: Ensure that only one thread at a time can create a secure desktop

This commit is contained in:
Mounir IDRASSI 2019-02-10 22:48:06 +01:00
parent 3903fcc595
commit 2061b4c28c
No known key found for this signature in database
GPG Key ID: 02C30AE90FAE4A6F

View File

@ -214,6 +214,9 @@ CRITICAL_SECTION csVolumeIdCandidates;
static std::vector<HostDevice> mountableDevices; static std::vector<HostDevice> mountableDevices;
static std::vector<HostDevice> rawHostDeviceList; static std::vector<HostDevice> rawHostDeviceList;
/* Critical section used to ensure that only one thread at a time can create a secure desktop */
CRITICAL_SECTION csSecureDesktop;
HINSTANCE hInst = NULL; HINSTANCE hInst = NULL;
HCURSOR hCursor = NULL; HCURSOR hCursor = NULL;
@ -445,6 +448,7 @@ void InitGlobalLocks ()
InitializeCriticalSection (&csWNetCalls); InitializeCriticalSection (&csWNetCalls);
InitializeCriticalSection (&csMountableDevices); InitializeCriticalSection (&csMountableDevices);
InitializeCriticalSection (&csVolumeIdCandidates); InitializeCriticalSection (&csVolumeIdCandidates);
InitializeCriticalSection (&csSecureDesktop);
} }
void FinalizeGlobalLocks () void FinalizeGlobalLocks ()
@ -452,6 +456,7 @@ void FinalizeGlobalLocks ()
DeleteCriticalSection (&csWNetCalls); DeleteCriticalSection (&csWNetCalls);
DeleteCriticalSection (&csMountableDevices); DeleteCriticalSection (&csMountableDevices);
DeleteCriticalSection (&csVolumeIdCandidates); DeleteCriticalSection (&csVolumeIdCandidates);
DeleteCriticalSection (&csSecureDesktop);
} }
void cleanup () void cleanup ()
@ -13556,6 +13561,9 @@ INT_PTR SecureDesktopDialogBoxParam(
HDESK hInputDesk = NULL; HDESK hInputDesk = NULL;
EnterCriticalSection (&csSecureDesktop);
finally_do ({ LeaveCriticalSection (&csSecureDesktop); });
// wait for the input desktop to be available before switching to // wait for the input desktop to be available before switching to
// secure desktop. Under Windows 10, the user session can be started // secure desktop. Under Windows 10, the user session can be started
// in the background even before the user has authenticated and in this // in the background even before the user has authenticated and in this