diff --git a/libdnet-stripped/src/rand.c b/libdnet-stripped/src/rand.c index 246da824e..9095ad823 100644 --- a/libdnet-stripped/src/rand.c +++ b/libdnet-stripped/src/rand.c @@ -14,8 +14,9 @@ #ifdef _WIN32 /* XXX */ # undef _WIN32_WINNT -# define _WIN32_WINNT 0x0400 -# include +# define _WIN32_WINNT _WIN32_WINNT_WIN7 +# include +# pragma comment(lib, "bcrypt.lib") # define inline __inline #else # include @@ -69,12 +70,8 @@ rand_open(void) rand_t *r; u_char seed[256]; #ifdef _WIN32 - HCRYPTPROV hcrypt = 0; - - CryptAcquireContext(&hcrypt, NULL, NULL, PROV_RSA_FULL, - CRYPT_VERIFYCONTEXT); - CryptGenRandom(hcrypt, sizeof(seed), seed); - CryptReleaseContext(hcrypt, 0); + if (STATUS_SUCCESS != BCryptGenRandom(NULL, seed, sizeof(seed), BCRYPT_USE_SYSTEM_PREFERRED_RNG)) + return NULL; #else struct timeval *tv = (struct timeval *)seed; int fd; diff --git a/nbase/nbase_winconfig.h b/nbase/nbase_winconfig.h index 878fb4415..57b0ea244 100644 --- a/nbase/nbase_winconfig.h +++ b/nbase/nbase_winconfig.h @@ -72,9 +72,9 @@ are in . http://msdn.microsoft.com/en-us/library/aa383745.aspx http://blogs.msdn.com/oldnewthing/archive/2007/04/11/2079137.aspx */ #undef _WIN32_WINNT -#define _WIN32_WINNT _WIN32_WINNT_WIN6 +#define _WIN32_WINNT _WIN32_WINNT_WIN7 #undef NTDDI_VERSION -#define NTDDI_VERSION NTDDI_WIN6 +#define NTDDI_VERSION NTDDI_WIN7 //This disables the warning 4800 http://msdn.microsoft.com/en-us/library/b6801kcy(v=vs.71).aspx #pragma warning(disable : 4800)