From 2545ffe74c6a348c9ef7bf90fa05c6d06a8cc91d Mon Sep 17 00:00:00 2001 From: chemodax <53048645+chemodax@users.noreply.github.com> Date: Sun, 29 Jun 2025 20:32:14 +0200 Subject: [PATCH] win: replace GetModuleHandleA with GetModuleHandleW (#4812) --- src/win/thread.c | 2 +- src/win/winapi.c | 10 +++++----- test/run-tests.c | 2 +- test/test-spawn.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/win/thread.c b/src/win/thread.c index 753cb6a34..9c38e3d8b 100644 --- a/src/win/thread.c +++ b/src/win/thread.c @@ -284,7 +284,7 @@ int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) { static void uv__thread_name_init_once(void) { HMODULE m; - m = GetModuleHandleA("api-ms-win-core-processthreads-l1-1-3.dll"); + m = GetModuleHandleW(L"api-ms-win-core-processthreads-l1-1-3.dll"); if (m != NULL) { pGetThreadDescription = (void*) GetProcAddress(m, "GetThreadDescription"); pSetThreadDescription = (void*) GetProcAddress(m, "SetThreadDescription"); diff --git a/src/win/winapi.c b/src/win/winapi.c index 315a0d49a..786a9daa6 100644 --- a/src/win/winapi.c +++ b/src/win/winapi.c @@ -55,9 +55,9 @@ void uv__winapi_init(void) { HMODULE ws2_32_module; HMODULE api_win_core_file_module; - ntdll_module = GetModuleHandleA("ntdll.dll"); + ntdll_module = GetModuleHandleW(L"ntdll.dll"); if (ntdll_module == NULL) { - uv_fatal_error(GetLastError(), "GetModuleHandleA"); + uv_fatal_error(GetLastError(), "GetModuleHandleW"); } pRtlGetVersion = (sRtlGetVersion) GetProcAddress(ntdll_module, @@ -123,20 +123,20 @@ void uv__winapi_init(void) { GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification"); } - user32_module = GetModuleHandleA("user32.dll"); + user32_module = GetModuleHandleW(L"user32.dll"); if (user32_module != NULL) { pSetWinEventHook = (sSetWinEventHook) GetProcAddress(user32_module, "SetWinEventHook"); } - ws2_32_module = GetModuleHandleA("ws2_32.dll"); + ws2_32_module = GetModuleHandleW(L"ws2_32.dll"); if (ws2_32_module != NULL) { pGetHostNameW = (uv_sGetHostNameW) GetProcAddress( ws2_32_module, "GetHostNameW"); } - api_win_core_file_module = GetModuleHandleA("api-ms-win-core-file-l2-1-4.dll"); + api_win_core_file_module = GetModuleHandleW(L"api-ms-win-core-file-l2-1-4.dll"); if (api_win_core_file_module != NULL) { pGetFileInformationByName = (sGetFileInformationByName)GetProcAddress( api_win_core_file_module, "GetFileInformationByName"); diff --git a/test/run-tests.c b/test/run-tests.c index 17fb0e0cf..a5007e24e 100644 --- a/test/run-tests.c +++ b/test/run-tests.c @@ -223,7 +223,7 @@ static int maybe_run_test(int argc, char **argv) { ASSERT_GT((intptr_t) closed_fd, 0); ASSERT_GT((intptr_t) open_fd, 0); ASSERT_NE(0, GetHandleInformation(open_fd, &flags)); - kernelbase_module = GetModuleHandleA("kernelbase.dll"); + kernelbase_module = GetModuleHandleW(L"kernelbase.dll"); pCompareObjectHandles = (sCompareObjectHandles) GetProcAddress(kernelbase_module, "CompareObjectHandles"); ASSERT_NE(pCompareObjectHandles == NULL || \ diff --git a/test/test-spawn.c b/test/test-spawn.c index 964c8a86c..1c470a09f 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -1701,7 +1701,7 @@ TEST_IMPL(spawn_fs_open) { #ifdef _WIN32 ASSERT_NE(0, DuplicateHandle(GetCurrentProcess(), fd, GetCurrentProcess(), &dup_fd, 0, /* inherit */ TRUE, DUPLICATE_SAME_ACCESS)); - kernelbase_module = GetModuleHandleA("kernelbase.dll"); + kernelbase_module = GetModuleHandleW("kernelbase.dll"); pCompareObjectHandles = (sCompareObjectHandles) GetProcAddress(kernelbase_module, "CompareObjectHandles"); ASSERT_NE(pCompareObjectHandles == NULL ||