Skip to content

Commit ed0fbd8

Browse files
bzozMylesBorins
authored andcommitted
deps: cherry-pick e7f4e9e from upstream libuv
Original commit message: tty, win: get SetWinEventHook pointer at startup SetWinEventHook is not available on some Windows versions. Fixes: #16603 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> PR-URL: #16724Fixes: #16603 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent 185229e commit ed0fbd8

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

‎deps/uv/src/win/tty.c‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2285,13 +2285,16 @@ static DWORD WINAPI uv__tty_console_resize_message_loop_thread(void* param){
22852285
uv__tty_console_width=sb_info.dwSize.X;
22862286
uv__tty_console_height=sb_info.srWindow.Bottom-sb_info.srWindow.Top+1;
22872287

2288-
if (!SetWinEventHook(EVENT_CONSOLE_LAYOUT,
2289-
EVENT_CONSOLE_LAYOUT,
2290-
NULL,
2291-
uv__tty_console_resize_event,
2292-
0,
2293-
0,
2294-
WINEVENT_OUTOFCONTEXT))
2288+
if (pSetWinEventHook==NULL)
2289+
return0;
2290+
2291+
if (!pSetWinEventHook(EVENT_CONSOLE_LAYOUT,
2292+
EVENT_CONSOLE_LAYOUT,
2293+
NULL,
2294+
uv__tty_console_resize_event,
2295+
0,
2296+
0,
2297+
WINEVENT_OUTOFCONTEXT))
22952298
return0;
22962299

22972300
while (GetMessage(&msg, NULL, 0, 0)){

‎deps/uv/src/win/winapi.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW;
5252
/* Powrprof.dll function pointer */
5353
sPowerRegisterSuspendResumeNotificationpPowerRegisterSuspendResumeNotification;
5454

55+
/* User32.dll function pointer */
56+
sSetWinEventHookpSetWinEventHook;
57+
5558

5659
voiduv_winapi_init(void){
5760
HMODULEntdll_module;
5861
HMODULEkernel32_module;
5962
HMODULEpowrprof_module;
63+
HMODULEuser32_module;
6064

6165
ntdll_module=GetModuleHandleA("ntdll.dll");
6266
if (ntdll_module==NULL){
@@ -156,4 +160,10 @@ void uv_winapi_init(void){
156160
GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification");
157161
}
158162

163+
user32_module=LoadLibraryA("user32.dll");
164+
if (user32_module!=NULL){
165+
pSetWinEventHook= (sSetWinEventHook)
166+
GetProcAddress(user32_module, "SetWinEventHook");
167+
}
168+
159169
}

‎deps/uv/src/win/winapi.h‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4725,6 +4725,25 @@ typedef DWORD (WINAPI *sPowerRegisterSuspendResumeNotification)
47254725
HANDLERecipient,
47264726
_PHPOWERNOTIFYRegistrationHandle);
47274727

4728+
/* from Winuser.h */
4729+
typedefVOID (CALLBACK*WINEVENTPROC)
4730+
(HWINEVENTHOOKhWinEventHook,
4731+
DWORDevent,
4732+
HWNDhwnd,
4733+
LONGidObject,
4734+
LONGidChild,
4735+
DWORDidEventThread,
4736+
DWORDdwmsEventTime);
4737+
4738+
typedefHWINEVENTHOOK (WINAPI*sSetWinEventHook)
4739+
(UINTeventMin,
4740+
UINTeventMax,
4741+
HMODULEhmodWinEventProc,
4742+
WINEVENTPROClpfnWinEventProc,
4743+
DWORDidProcess,
4744+
DWORDidThread,
4745+
UINTdwflags);
4746+
47284747

47294748
/* Ntdll function pointers */
47304749
externsRtlNtStatusToDosErrorpRtlNtStatusToDosError;
@@ -4753,4 +4772,7 @@ extern sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW;
47534772
/* Powrprof.dll function pointer */
47544773
externsPowerRegisterSuspendResumeNotificationpPowerRegisterSuspendResumeNotification;
47554774

4775+
/* User32.dll function pointer */
4776+
externsSetWinEventHookpSetWinEventHook;
4777+
47564778
#endif/* UV_WIN_WINAPI_H_ */

0 commit comments

Comments
(0)