diff --git a/src/random.h b/src/random.h index 439226f..c44f52a 100644 --- a/src/random.h +++ b/src/random.h @@ -17,7 +17,13 @@ */ #if defined(_WIN32) +/* + * The defined WIN32_NO_STATUS macro disables return code definitions in + * windows.h, which avoids "macro redefinition" MSVC warnings in ntstatus.h. + */ +#define WIN32_NO_STATUS #include +#undef WIN32_NO_STATUS #include #include #elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) @@ -36,7 +42,7 @@ /* Returns 1 on success, and 0 on failure. */ static int fill_random(unsigned char* data, size_t size) { #if defined(_WIN32) - NTSTATUS res = BCryptGenRandom(NULL, data, size, BCRYPT_USE_SYSTEM_PREFERRED_RNG); + NTSTATUS res = BCryptGenRandom(NULL, data, (ULONG)size, BCRYPT_USE_SYSTEM_PREFERRED_RNG); if (res != STATUS_SUCCESS || size > ULONG_MAX) { return 0; } else {