Commit 729f2aceb0

Andrew Kelley <superjoe30@gmail.com>
2018-08-02 19:34:31
fix API of RtlGenRandom
1 parent cbca434
Changed files (2)
std
std/os/windows/advapi32.zig
@@ -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;
std/os/index.zig
@@ -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),