aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/os_win.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/os_win.c b/src/os_win.c
index 91dfaf399..7d0e4a90f 100644
--- a/src/os_win.c
+++ b/src/os_win.c
@@ -1421,12 +1421,30 @@ void winDlClose(sqlite3_vfs *pVfs, void *pHandle){
** Write up to nBuf bytes of randomness into zBuf.
*/
static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
- if( sizeof(LPSYSTEMTIME)>=nBuf ){
- GetSystemTime((LPSYSTEMTIME)zBuf);
- return sizeof(LPSYSTEMTIME);
- }else{
- return 0;
- }
+ int n = 0;
+ if( sizeof(LPSYSTEMTIME)<=nBuf-n ){
+ SYSTEMTIME x;
+ GetSystemTime(&x);
+ memcpy(&zBuf[n], &x, sizeof(x));
+ n += sizeof(x);
+ }
+ if( sizeof(DWORD)<=nBuf-n ){
+ DWORD pid = GetCurrentProcessId();
+ memcpy(&zBuf[n], &pid, sizeof(pid));
+ n += sizeof(pid);
+ }
+ if( sizeof(DWORD)<=nBuf-n ){
+ DWORD cnt = GetTickCount();
+ memcpy(&zBuf[n], &cnt, sizeof(cnt));
+ n += sizeof(cnt);
+ }
+ if( sizeof(LARGE_INTEGER)<=nBuf-n ){
+ LARGE_INTEGER i;
+ QueryPerformanceCounter(&i);
+ memcpy(&zBuf[n], &i, sizeof(i));
+ n += sizeof(i);
+ }
+ return n;
}