aboutsummaryrefslogtreecommitdiff
path: root/src/win/winapi.c
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2019-06-22 15:18:17 +0200
committerSaúl Ibarra Corretgé <s@saghul.net>2019-09-18 08:09:14 +0200
commit4ed2a78f0eb1c9d2a0c98ea4a88c6824e5958dc6 (patch)
treece6b8b3282f3ac65d6bbeba5cec36463b68f06e5 /src/win/winapi.c
parentfd1502f5630591bf8ce79502df9b5d76868dfd3b (diff)
downloadlibuv-4ed2a78f0eb1c9d2a0c98ea4a88c6824e5958dc6.tar.gz
libuv-4ed2a78f0eb1c9d2a0c98ea4a88c6824e5958dc6.zip
unix,win: add uv_random()
Add an API for obtaining cryptographically strong random data from the system PRNG. Co-authored-by: Saúl Ibarra Corretgé <s@saghul.net> Refs: https://github.com/libuv/libuv/pull/1055 PR-URL: https://github.com/libuv/libuv/pull/2347 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Diffstat (limited to 'src/win/winapi.c')
-rw-r--r--src/win/winapi.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/win/winapi.c b/src/win/winapi.c
index 19e4377f..85a9de8a 100644
--- a/src/win/winapi.c
+++ b/src/win/winapi.c
@@ -36,6 +36,9 @@ sNtQueryDirectoryFile pNtQueryDirectoryFile;
sNtQuerySystemInformation pNtQuerySystemInformation;
sNtQueryInformationProcess pNtQueryInformationProcess;
+/* Advapi32 function pointers */
+sRtlGenRandom pRtlGenRandom;
+
/* Kernel32 function pointers */
sGetQueuedCompletionStatusEx pGetQueuedCompletionStatusEx;
@@ -51,6 +54,7 @@ void uv_winapi_init(void) {
HMODULE powrprof_module;
HMODULE user32_module;
HMODULE kernel32_module;
+ HMODULE advapi32_module;
ntdll_module = GetModuleHandleA("ntdll.dll");
if (ntdll_module == NULL) {
@@ -135,4 +139,11 @@ void uv_winapi_init(void) {
GetProcAddress(user32_module, "SetWinEventHook");
}
+ advapi32_module = GetModuleHandleA("advapi32.dll");
+ if (advapi32_module == NULL) {
+ uv_fatal_error(GetLastError(), "GetModuleHandleA");
+ }
+
+ pRtlGenRandom =
+ (sRtlGenRandom) GetProcAddress(advapi32_module, "SystemFunction036");
}