From c1bc9dee0eb0744817aff7fac230ca5cfd940c26 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 5 Aug 2018 23:37:09 +0200 Subject: Windows: avoid timeout of Secure Desktop display by waiting for the user to be really authenticated. Under Windows 10, a user session can be started in the background even before the user has been authenticated and this was causing VeraCrypt to be started before the user has logged in, in turn this was causing Secure Desktop to fail. --- src/Common/Dlgcode.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 48a5e852..cff7fd6e 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -13259,11 +13259,9 @@ static DWORD WINAPI SecureDesktopThread(LPVOID lpThreadParameter) SecureDesktopMonitoringThreadParam monitorParam; HDESK hOriginalDesk = GetThreadDesktop (GetCurrentThreadId ()); BOOL bNewDesktopSet = FALSE; - int counter = 0; // wait for SwitchDesktop to succeed before using it for current thread - // we wait a maximum of 5 seconds - for (counter = 0; counter < 10; counter++) + while (true) { if (SwitchDesktop (pParam->hDesk)) { @@ -13352,6 +13350,21 @@ INT_PTR SecureDesktopDialogBoxParam( map ctfmonBeforeList, ctfmonAfterList; DWORD desktopAccess = DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_WRITEOBJECTS; HDESK hSecureDesk; + + HDESK hInputDesk = NULL; + + // 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 + // case, we wait for the user to be really authenticated before starting + // secure desktop mechanism + + while (!(hInputDesk = OpenInputDesktop (0, TRUE, GENERIC_READ))) + { + Sleep (SECUREDESKTOP_MONOTIR_PERIOD); + } + + CloseDesktop (hInputDesk); // get the initial list of ctfmon.exe processes before creating new desktop GetCtfMonProcessIdList (ctfmonBeforeList); -- cgit v1.2.3