@@ -166,69 +166,3 @@ index 88602c7ee8623f16f87398cf3ffd1f71555fc1a0..5ffde08e1aed041c4da679156ed10f7e
166166 int uv_os_gethostname(char* buffer, size_t* size) {
167167 WCHAR buf[UV_MAXHOSTNAMESIZE];
168168 size_t len;
169- @@ -1674,7 +1803,9 @@ int uv_os_gethostname(char* buffer, size_t* size) {
170-
171- uv__once_init(); /* Initialize winsock */
172-
173- - if (GetHostNameW(buf, UV_MAXHOSTNAMESIZE) != 0)
174- + sGetHostNameW gethostnamew =
175- + pGetHostNameW == NULL ? uv__gethostnamew_nt60 : pGetHostNameW;
176- + if (gethostnamew(buf, UV_MAXHOSTNAMESIZE) != 0)
177- return uv_translate_sys_error(WSAGetLastError());
178-
179- convert_result = uv__convert_utf16_to_utf8(buf, -1, &utf8_str);
180- diff --git a/deps/uv/src/win/winapi.c b/deps/uv/src/win/winapi.c
181- index bb86ec8ceac8ba3fccd02b292aca7ddfab38e187..9d6effb10ddd1801f7411ee71a70575b7072ab7d 100644
182- --- a/deps/uv/src/win/winapi.c
183- +++ b/deps/uv/src/win/winapi.c
184- @@ -45,12 +45,15 @@ sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification;
185- /* User32.dll function pointer */
186- sSetWinEventHook pSetWinEventHook;
187-
188- + /* ws2_32.dll function pointer */
189- + sGetHostNameW pGetHostNameW;
190-
191- void uv_winapi_init(void) {
192- HMODULE ntdll_module;
193- HMODULE powrprof_module;
194- HMODULE user32_module;
195- HMODULE kernel32_module;
196- + HMODULE ws2_32_module;;
197-
198- ntdll_module = GetModuleHandleA("ntdll.dll");
199- if (ntdll_module == NULL) {
200- @@ -134,4 +137,10 @@ void uv_winapi_init(void) {
201- pSetWinEventHook = (sSetWinEventHook)
202- GetProcAddress(user32_module, "SetWinEventHook");
203- }
204- +
205- + ws2_32_module = LoadLibraryA("ws2_32.dll");
206- + if (ws2_32_module != NULL) {
207- + pGetHostNameW = (sGetHostNameW)
208- + GetProcAddress(ws2_32_module, "GetHostNameW");
209- + }
210- }
211- diff --git a/deps/uv/src/win/winapi.h b/deps/uv/src/win/winapi.h
212- index 0b66b5634bca88cec65b1bf0c0193986f5ddd542..5951717ab9e21db274f956c44410cc03c1617eaf 100644
213- --- a/deps/uv/src/win/winapi.h
214- +++ b/deps/uv/src/win/winapi.h
215- @@ -4739,6 +4739,11 @@ typedef struct _TCP_INITIAL_RTO_PARAMETERS {
216- # define SIO_TCP_INITIAL_RTO _WSAIOW(IOC_VENDOR,17)
217- #endif
218-
219- + /* From winsock2.h */
220- + typedef int (WSAAPI *sGetHostNameW)
221- + (PWSTR name,
222- + int namelen);
223- +
224- /* Ntdll function pointers */
225- extern sRtlGetVersion pRtlGetVersion;
226- extern sRtlNtStatusToDosError pRtlNtStatusToDosError;
227- @@ -4759,4 +4764,7 @@ extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotifi
228- /* User32.dll function pointer */
229- extern sSetWinEventHook pSetWinEventHook;
230-
231- + /* ws2_32.dll function pointer */
232- + extern sGetHostNameW pGetHostNameW;
233- +
234- #endif /* UV_WIN_WINAPI_H_ */
0 commit comments