mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-10 21:23:40 +01:00
Windows: Fix freeze when password dialog displayed in secure desktop and try to access token keyfiles protected by PIN
This commit is contained in:
parent
0eace45cea
commit
7efe4e4f2a
@ -235,7 +235,8 @@ static std::vector<HostDevice> rawHostDeviceList;
|
|||||||
CRITICAL_SECTION csSecureDesktop;
|
CRITICAL_SECTION csSecureDesktop;
|
||||||
|
|
||||||
/* Boolean that indicates if our Secure Desktop is active and being used or not */
|
/* Boolean that indicates if our Secure Desktop is active and being used or not */
|
||||||
BOOL bSecureDesktopOngoing = FALSE;
|
volatile BOOL bSecureDesktopOngoing = FALSE;
|
||||||
|
TCHAR SecureDesktopName[65];
|
||||||
|
|
||||||
HINSTANCE hInst = NULL;
|
HINSTANCE hInst = NULL;
|
||||||
HCURSOR hCursor = NULL;
|
HCURSOR hCursor = NULL;
|
||||||
@ -12214,6 +12215,35 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" BOOL IsThreadInSecureDesktop(DWORD dwThreadID)
|
||||||
|
{
|
||||||
|
BOOL bRet = FALSE;
|
||||||
|
if (bSecureDesktopOngoing)
|
||||||
|
{
|
||||||
|
HDESK currentDesk = GetThreadDesktop (dwThreadID);
|
||||||
|
if (currentDesk)
|
||||||
|
{
|
||||||
|
LPWSTR szName = NULL;
|
||||||
|
DWORD dwLen = 0;
|
||||||
|
if (!GetUserObjectInformation (currentDesk, UOI_NAME, NULL, 0, &dwLen))
|
||||||
|
{
|
||||||
|
szName = (LPWSTR) malloc (dwLen);
|
||||||
|
if (szName)
|
||||||
|
{
|
||||||
|
if (GetUserObjectInformation (currentDesk, UOI_NAME, szName, dwLen, &dwLen))
|
||||||
|
{
|
||||||
|
if (0 == _wcsicmp (szName, SecureDesktopName))
|
||||||
|
bRet = TRUE;
|
||||||
|
}
|
||||||
|
free (szName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BOOL InitSecurityTokenLibrary (HWND hwndDlg)
|
BOOL InitSecurityTokenLibrary (HWND hwndDlg)
|
||||||
{
|
{
|
||||||
@ -12238,6 +12268,8 @@ BOOL InitSecurityTokenLibrary (HWND hwndDlg)
|
|||||||
HWND hParent = IsWindow (m_hwnd)? m_hwnd : GetActiveWindow();
|
HWND hParent = IsWindow (m_hwnd)? m_hwnd : GetActiveWindow();
|
||||||
if (!hParent)
|
if (!hParent)
|
||||||
hParent = GetForegroundWindow ();
|
hParent = GetForegroundWindow ();
|
||||||
|
if (IsThreadInSecureDesktop(GetCurrentThreadId()) && !IsThreadInSecureDesktop(GetWindowThreadProcessId(hParent, NULL)))
|
||||||
|
hParent = GetActiveWindow ();
|
||||||
if (SecureDesktopDialogBoxParam (hInst, MAKEINTRESOURCEW (IDD_TOKEN_PASSWORD), hParent, (DLGPROC) SecurityTokenPasswordDlgProc, (LPARAM) &str) == IDCANCEL)
|
if (SecureDesktopDialogBoxParam (hInst, MAKEINTRESOURCEW (IDD_TOKEN_PASSWORD), hParent, (DLGPROC) SecurityTokenPasswordDlgProc, (LPARAM) &str) == IDCANCEL)
|
||||||
throw UserAbort (SRC_POS);
|
throw UserAbort (SRC_POS);
|
||||||
}
|
}
|
||||||
@ -13847,7 +13879,7 @@ INT_PTR SecureDesktopDialogBoxParam(
|
|||||||
INT_PTR retValue = 0;
|
INT_PTR retValue = 0;
|
||||||
BOOL bEffectiveUseSecureDesktop = bCmdUseSecureDesktopValid? bCmdUseSecureDesktop : bUseSecureDesktop;
|
BOOL bEffectiveUseSecureDesktop = bCmdUseSecureDesktopValid? bCmdUseSecureDesktop : bUseSecureDesktop;
|
||||||
|
|
||||||
if (bEffectiveUseSecureDesktop)
|
if (bEffectiveUseSecureDesktop && !IsThreadInSecureDesktop(GetCurrentThreadId()))
|
||||||
{
|
{
|
||||||
EnterCriticalSection (&csSecureDesktop);
|
EnterCriticalSection (&csSecureDesktop);
|
||||||
bSecureDesktopOngoing = TRUE;
|
bSecureDesktopOngoing = TRUE;
|
||||||
@ -13893,6 +13925,8 @@ INT_PTR SecureDesktopDialogBoxParam(
|
|||||||
HANDLE hThread = ::CreateThread (NULL, 0, SecureDesktopThread, (LPVOID) ¶m, 0, NULL);
|
HANDLE hThread = ::CreateThread (NULL, 0, SecureDesktopThread, (LPVOID) ¶m, 0, NULL);
|
||||||
if (hThread)
|
if (hThread)
|
||||||
{
|
{
|
||||||
|
StringCbCopy(SecureDesktopName, sizeof (SecureDesktopName), szDesktopName);
|
||||||
|
|
||||||
WaitForSingleObject (hThread, INFINITE);
|
WaitForSingleObject (hThread, INFINITE);
|
||||||
CloseHandle (hThread);
|
CloseHandle (hThread);
|
||||||
|
|
||||||
|
@ -124,7 +124,8 @@ extern BOOL bHideWaitingDialog;
|
|||||||
extern BOOL bCmdHideWaitingDialog;
|
extern BOOL bCmdHideWaitingDialog;
|
||||||
extern BOOL bCmdHideWaitingDialogValid;
|
extern BOOL bCmdHideWaitingDialogValid;
|
||||||
extern BOOL bUseSecureDesktop;
|
extern BOOL bUseSecureDesktop;
|
||||||
extern BOOL bSecureDesktopOngoing;
|
extern volatile BOOL bSecureDesktopOngoing;
|
||||||
|
extern TCHAR SecureDesktopName[65];
|
||||||
extern BOOL bUseLegacyMaxPasswordLength;
|
extern BOOL bUseLegacyMaxPasswordLength;
|
||||||
extern BOOL bCmdUseSecureDesktop;
|
extern BOOL bCmdUseSecureDesktop;
|
||||||
extern BOOL bCmdUseSecureDesktopValid;
|
extern BOOL bCmdUseSecureDesktopValid;
|
||||||
@ -550,6 +551,7 @@ BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_
|
|||||||
BOOL GetFreeDriveLetter(WCHAR* pCh);
|
BOOL GetFreeDriveLetter(WCHAR* pCh);
|
||||||
BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable);
|
BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable);
|
||||||
BOOL DeleteDirectory (const wchar_t* szDirName);
|
BOOL DeleteDirectory (const wchar_t* szDirName);
|
||||||
|
BOOL IsThreadInSecureDesktop(DWORD dwThreadID);
|
||||||
INT_PTR SecureDesktopDialogBoxParam (HINSTANCE, LPCWSTR, HWND, DLGPROC, LPARAM);
|
INT_PTR SecureDesktopDialogBoxParam (HINSTANCE, LPCWSTR, HWND, DLGPROC, LPARAM);
|
||||||
BOOL VerifyModuleSignature (const wchar_t* path);
|
BOOL VerifyModuleSignature (const wchar_t* path);
|
||||||
void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, BOOL* pbInstallPathDetermined);
|
void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, BOOL* pbInstallPathDetermined);
|
||||||
|
Loading…
Reference in New Issue
Block a user