fix API of RtlGenRandom

master
Andrew Kelley 2018-08-02 13:34:31 -04:00
parent cbca434cf0
commit 729f2aceb0
2 changed files with 2 additions and 2 deletions

View File

@ -133,7 +133,7 @@ pub fn getRandomBytes(buf: []u8) !void {
// Call RtlGenRandom() instead of CryptGetRandom() on Windows // Call RtlGenRandom() instead of CryptGetRandom() on Windows
// https://github.com/rust-lang-nursery/rand/issues/111 // https://github.com/rust-lang-nursery/rand/issues/111
// https://bugzilla.mozilla.org/show_bug.cgi?id=504270 // 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(); const err = windows.GetLastError();
return switch (err) { return switch (err) {
else => unexpectedErrorWindows(err), else => unexpectedErrorWindows(err),

View File

@ -31,5 +31,5 @@ pub extern "advapi32" stdcallcc fn RegQueryValueExW(hKey: HKEY, lpValueName: LPC
// RtlGenRandom is known as SystemFunction036 under advapi32 // RtlGenRandom is known as SystemFunction036 under advapi32
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa387694.aspx */ // 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; pub const RtlGenRandom = SystemFunction036;