| ... | ... | @@ -140,16 +140,16 @@ pub const RtlGenRandomError = error{Unexpected}; |
| 140 | 140 | pub fn RtlGenRandom(output: []u8) RtlGenRandomError!void { |
| 141 | 141 | var total_read: usize = 0; |
| 142 | 142 | var buff: []u8 = output[0..]; |
| 143 | | const max_read_size: ULONG = ULONG(maxInt(ULONG)); |
| 143 | const max_read_size: ULONG = maxInt(ULONG); |
| 144 | 144 | |
| 145 | 145 | while (total_read < output.len) { |
| 146 | | const to_read: ULONG = @intCast(ULONG, math.min(buff.len, max_read_size)); |
| 146 | const to_read: ULONG = math.min(buff.len, max_read_size); |
| 147 | 147 | |
| 148 | 148 | if (advapi32.RtlGenRandom(buff.ptr, to_read) == 0) { |
| 149 | 149 | return unexpectedError(kernel32.GetLastError()); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | | total_read += @intCast(usize, to_read); |
| 152 | total_read += to_read; |
| 153 | 153 | buff = buff[to_read..]; |
| 154 | 154 | } |
| 155 | 155 | } |