VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2021-02-24 21:48:33 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2021-02-24 21:51:00 +0100
commitc1e81d96924e5e68257f67b65f1dda72e0103bdc (patch)
tree71fb39b0c745e39a58edd34649797a5b4bd0c28c
parent7efe4e4f2a99450f3e6a15447a2ea816f9be848d (diff)
downloadVeraCrypt-c1e81d96924e5e68257f67b65f1dda72e0103bdc.tar.gz
VeraCrypt-c1e81d96924e5e68257f67b65f1dda72e0103bdc.zip
Windows: Fix failure to launch keyfile generator in secure desktop mode
Hooking is not allowed if thread is running in secure desktop so we ignore SetWindowsHookEx failure in this case and random generator will be initialized using the other entropy sources from the system.
-rw-r--r--src/Common/Random.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Common/Random.c b/src/Common/Random.c
index 09c55bf3..1080ce7e 100644
--- a/src/Common/Random.c
+++ b/src/Common/Random.c
@@ -14,6 +14,7 @@
#include "Tcdefs.h"
#include "Crc.h"
#include "Random.h"
+#include "Dlgcode.h"
#include "Crypto\cpu.h"
#include "Crypto\jitterentropy.h"
#include "Crypto\rdrand.h"
@@ -96,6 +97,7 @@ HCRYPTPROV hCryptProv;
/* Init the random number generator, setup the hooks, and start the thread */
int RandinitWithCheck ( int* pAlreadyInitialized)
{
+ BOOL bIgnoreHookError = FALSE;
DWORD dwLastError = ERROR_SUCCESS;
if (GetMaxPkcs5OutSize() > RNG_POOL_SIZE)
TC_THROW_FATAL_EXCEPTION;
@@ -129,11 +131,13 @@ int RandinitWithCheck ( int* pAlreadyInitialized)
VirtualLock (pRandPool, RANDOMPOOL_ALLOCSIZE);
}
+ bIgnoreHookError = IsThreadInSecureDesktop(GetCurrentThreadId());
+
hKeyboard = SetWindowsHookEx (WH_KEYBOARD, (HOOKPROC)&KeyboardProc, NULL, GetCurrentThreadId ());
- if (hKeyboard == 0) handleWin32Error (0, SRC_POS);
+ if (hKeyboard == 0 && !bIgnoreHookError) handleWin32Error (0, SRC_POS);
hMouse = SetWindowsHookEx (WH_MOUSE, (HOOKPROC)&MouseProc, NULL, GetCurrentThreadId ());
- if (hMouse == 0)
+ if (hMouse == 0 && !bIgnoreHookError)
{
handleWin32Error (0, SRC_POS);
goto error;