| 1 | #include "kernelrandombytes.h" |
| 2 | #include <Windows.h> |
| 3 | |
| 4 | #define RtlGenRandom SystemFunction036 |
| 5 | |
| 6 | #ifdef __cplusplus |
| 7 | extern "C" { |
| 8 | #endif |
| 9 | BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength); |
| 10 | #ifdef __cplusplus |
| 11 | } |
| 12 | #endif |
| 13 | |
| 14 | void kernelrandombytes(unsigned char *x,unsigned long long xlen) |
| 15 | { |
| 16 | int i; |
| 17 | |
| 18 | while (xlen > 0) { |
| 19 | if (xlen < 256) i = xlen; else i = 256; |
| 20 | RtlGenRandom(x, i); |
| 21 | x += i; |
| 22 | xlen -= i; |
| 23 | } |
| 24 | } |