mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 19:08:26 -06:00
Windows: make random generator function compatible with 64-bit execution environment
This commit is contained in:
@@ -36,6 +36,12 @@ static HANDLE PeriodicFastPollThreadHandle = NULL;
|
|||||||
/* Macro to add four bytes to the pool */
|
/* Macro to add four bytes to the pool */
|
||||||
#define RandaddInt32(x) RandAddInt((unsigned __int32)x);
|
#define RandaddInt32(x) RandAddInt((unsigned __int32)x);
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
#define RandaddIntPtr(x) RandAddInt64((unsigned __int64)x);
|
||||||
|
#else
|
||||||
|
#define RandaddIntPtr(x) RandAddInt((unsigned __int32)x);
|
||||||
|
#endif
|
||||||
|
|
||||||
void RandAddInt (unsigned __int32 x)
|
void RandAddInt (unsigned __int32 x)
|
||||||
{
|
{
|
||||||
RandaddByte(x);
|
RandaddByte(x);
|
||||||
@@ -44,6 +50,19 @@ void RandAddInt (unsigned __int32 x)
|
|||||||
RandaddByte((x >> 24));
|
RandaddByte((x >> 24));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RandAddInt64 (unsigned __int64 x)
|
||||||
|
{
|
||||||
|
RandaddByte(x);
|
||||||
|
RandaddByte((x >> 8));
|
||||||
|
RandaddByte((x >> 16));
|
||||||
|
RandaddByte((x >> 24));
|
||||||
|
|
||||||
|
RandaddByte((x >> 32));
|
||||||
|
RandaddByte((x >> 40));
|
||||||
|
RandaddByte((x >> 48));
|
||||||
|
RandaddByte((x >> 56));
|
||||||
|
}
|
||||||
|
|
||||||
#include <tlhelp32.h>
|
#include <tlhelp32.h>
|
||||||
#include "Dlgcode.h"
|
#include "Dlgcode.h"
|
||||||
|
|
||||||
@@ -539,7 +558,7 @@ LRESULT CALLBACK KeyboardProc (int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection (&critRandProt);
|
EnterCriticalSection (&critRandProt);
|
||||||
RandaddInt32 ((unsigned __int32) (crc32int(&lParam) + timeCrc));
|
RandaddInt32 ((unsigned __int32) (GetCrc32((unsigned char*) &lParam, sizeof(lParam)) + timeCrc));
|
||||||
LeaveCriticalSection (&critRandProt);
|
LeaveCriticalSection (&critRandProt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -734,36 +753,36 @@ BOOL FastPoll (void)
|
|||||||
int nOriginalRandIndex = nRandIndex;
|
int nOriginalRandIndex = nRandIndex;
|
||||||
static BOOL addedFixedItems = FALSE;
|
static BOOL addedFixedItems = FALSE;
|
||||||
FILETIME creationTime, exitTime, kernelTime, userTime;
|
FILETIME creationTime, exitTime, kernelTime, userTime;
|
||||||
DWORD minimumWorkingSetSize, maximumWorkingSetSize;
|
SIZE_T minimumWorkingSetSize, maximumWorkingSetSize;
|
||||||
LARGE_INTEGER performanceCount;
|
LARGE_INTEGER performanceCount;
|
||||||
MEMORYSTATUS memoryStatus;
|
MEMORYSTATUS memoryStatus;
|
||||||
HANDLE handle;
|
HANDLE handle;
|
||||||
POINT point;
|
POINT point;
|
||||||
|
|
||||||
/* Get various basic pieces of system information */
|
/* Get various basic pieces of system information */
|
||||||
RandaddInt32 (GetActiveWindow ()); /* Handle of active window */
|
RandaddIntPtr (GetActiveWindow ()); /* Handle of active window */
|
||||||
RandaddInt32 (GetCapture ()); /* Handle of window with mouse
|
RandaddIntPtr (GetCapture ()); /* Handle of window with mouse
|
||||||
capture */
|
capture */
|
||||||
RandaddInt32 (GetClipboardOwner ()); /* Handle of clipboard owner */
|
RandaddIntPtr (GetClipboardOwner ()); /* Handle of clipboard owner */
|
||||||
RandaddInt32 (GetClipboardViewer ()); /* Handle of start of
|
RandaddIntPtr (GetClipboardViewer ()); /* Handle of start of
|
||||||
clpbd.viewer list */
|
clpbd.viewer list */
|
||||||
RandaddInt32 (GetCurrentProcess ()); /* Pseudohandle of current
|
RandaddIntPtr (GetCurrentProcess ()); /* Pseudohandle of current
|
||||||
process */
|
process */
|
||||||
RandaddInt32 (GetCurrentProcessId ()); /* Current process ID */
|
RandaddInt32 (GetCurrentProcessId ()); /* Current process ID */
|
||||||
RandaddInt32 (GetCurrentThread ()); /* Pseudohandle of current
|
RandaddIntPtr (GetCurrentThread ()); /* Pseudohandle of current
|
||||||
thread */
|
thread */
|
||||||
RandaddInt32 (GetCurrentThreadId ()); /* Current thread ID */
|
RandaddInt32 (GetCurrentThreadId ()); /* Current thread ID */
|
||||||
RandaddInt32 (GetCurrentTime ()); /* Milliseconds since Windows
|
RandaddInt32 (GetCurrentTime ()); /* Milliseconds since Windows
|
||||||
started */
|
started */
|
||||||
RandaddInt32 (GetDesktopWindow ()); /* Handle of desktop window */
|
RandaddIntPtr (GetDesktopWindow ()); /* Handle of desktop window */
|
||||||
RandaddInt32 (GetFocus ()); /* Handle of window with kb.focus */
|
RandaddIntPtr (GetFocus ()); /* Handle of window with kb.focus */
|
||||||
RandaddInt32 (GetInputState ()); /* Whether sys.queue has any events */
|
RandaddInt32 (GetInputState ()); /* Whether sys.queue has any events */
|
||||||
RandaddInt32 (GetMessagePos ()); /* Cursor pos.for last message */
|
RandaddInt32 (GetMessagePos ()); /* Cursor pos.for last message */
|
||||||
RandaddInt32 (GetMessageTime ()); /* 1 ms time for last message */
|
RandaddInt32 (GetMessageTime ()); /* 1 ms time for last message */
|
||||||
RandaddInt32 (GetOpenClipboardWindow ()); /* Handle of window with
|
RandaddIntPtr (GetOpenClipboardWindow ()); /* Handle of window with
|
||||||
clpbd.open */
|
clpbd.open */
|
||||||
RandaddInt32 (GetProcessHeap ()); /* Handle of process heap */
|
RandaddIntPtr (GetProcessHeap ()); /* Handle of process heap */
|
||||||
RandaddInt32 (GetProcessWindowStation ()); /* Handle of procs
|
RandaddIntPtr (GetProcessWindowStation ()); /* Handle of procs
|
||||||
window station */
|
window station */
|
||||||
RandaddInt32 (GetQueueStatus (QS_ALLEVENTS)); /* Types of events in
|
RandaddInt32 (GetQueueStatus (QS_ALLEVENTS)); /* Types of events in
|
||||||
input queue */
|
input queue */
|
||||||
@@ -800,8 +819,8 @@ BOOL FastPoll (void)
|
|||||||
process */
|
process */
|
||||||
GetProcessWorkingSetSize (handle, &minimumWorkingSetSize,
|
GetProcessWorkingSetSize (handle, &minimumWorkingSetSize,
|
||||||
&maximumWorkingSetSize);
|
&maximumWorkingSetSize);
|
||||||
RandaddInt32 (minimumWorkingSetSize);
|
RandaddIntPtr (minimumWorkingSetSize);
|
||||||
RandaddInt32 (maximumWorkingSetSize);
|
RandaddIntPtr (maximumWorkingSetSize);
|
||||||
|
|
||||||
/* The following are fixed for the lifetime of the process so we only
|
/* The following are fixed for the lifetime of the process so we only
|
||||||
add them once */
|
add them once */
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ extern BOOL volatile bFastPollEnabled;
|
|||||||
extern BOOL volatile bRandmixEnabled;
|
extern BOOL volatile bRandmixEnabled;
|
||||||
extern DWORD CryptoAPILastError;
|
extern DWORD CryptoAPILastError;
|
||||||
|
|
||||||
|
void RandAddInt64 ( unsigned __int64 x );
|
||||||
|
|
||||||
LRESULT CALLBACK MouseProc ( int nCode , WPARAM wParam , LPARAM lParam );
|
LRESULT CALLBACK MouseProc ( int nCode , WPARAM wParam , LPARAM lParam );
|
||||||
LRESULT CALLBACK KeyboardProc ( int nCode , WPARAM wParam , LPARAM lParam );
|
LRESULT CALLBACK KeyboardProc ( int nCode , WPARAM wParam , LPARAM lParam );
|
||||||
static unsigned __stdcall PeriodicFastPollThreadProc (void *dummy);
|
static unsigned __stdcall PeriodicFastPollThreadProc (void *dummy);
|
||||||
|
|||||||
Reference in New Issue
Block a user