windows.h 503 B

1234567891011121314151617181920
  1. #include <windows.h>
  2. #define RtlGenRandom SystemFunction036
  3. #if defined(__cplusplus)
  4. extern "C"
  5. #endif
  6. BOOLEAN NTAPI
  7. RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength);
  8. #pragma comment(lib, "advapi32.lib")
  9. static int
  10. hydro_random_init(void)
  11. {
  12. if (!RtlGenRandom((PVOID) hydro_random_context.state,
  13. (ULONG) sizeof hydro_random_context.state)) {
  14. return -1;
  15. }
  16. hydro_random_context.counter = ~LOAD64_LE(hydro_random_context.state);
  17. return 0;
  18. }