fix API of RtlGenRandom
parent
cbca434cf0
commit
729f2aceb0
|
@ -133,7 +133,7 @@ pub fn getRandomBytes(buf: []u8) !void {
|
|||
// Call RtlGenRandom() instead of CryptGetRandom() on Windows
|
||||
// https://github.com/rust-lang-nursery/rand/issues/111
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=504270
|
||||
if (!windows.RtlGenRandom(buf.ptr, buf.len)) {
|
||||
if (windows.RtlGenRandom(buf.ptr, buf.len) == 0) {
|
||||
const err = windows.GetLastError();
|
||||
return switch (err) {
|
||||
else => unexpectedErrorWindows(err),
|
||||
|
|
|
@ -31,5 +31,5 @@ pub extern "advapi32" stdcallcc fn RegQueryValueExW(hKey: HKEY, lpValueName: LPC
|
|||
|
||||
// RtlGenRandom is known as SystemFunction036 under advapi32
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */
|
||||
pub extern "advapi32" stdcallcc fn SystemFunction036(output: PVOID, length: ULONG_PTR) BOOL;
|
||||
pub extern "advapi32" stdcallcc fn SystemFunction036(output: [*]u8, length: usize) BOOL;
|
||||
pub const RtlGenRandom = SystemFunction036;
|
||||
|
|
Loading…
Reference in New Issue