diff options
Diffstat (limited to 'src/Common/Random.c')
-rw-r--r-- | src/Common/Random.c | 8 |
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 @@ -13,8 +13,9 @@ #include "Tcdefs.h" #include "Crc.h" #include "Random.h" +#include "Dlgcode.h" #include "Crypto\cpu.h" #include "Crypto\jitterentropy.h" #include "Crypto\rdrand.h" #include <Strsafe.h> @@ -95,8 +96,9 @@ 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; @@ -128,13 +130,15 @@ int RandinitWithCheck ( int* pAlreadyInitialized) memset (pRandPool, 0, RANDOMPOOL_ALLOCSIZE); 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; } |