-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tty, win: get SetWinEventHook pointer at startup #1611
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,11 +52,15 @@ sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW; | |
/* Powrprof.dll function pointer */ | ||
sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; | ||
|
||
/* User32.dll function pointer */ | ||
sSetWinEventHook pSetWinEventHook; | ||
|
||
|
||
void uv_winapi_init(void) { | ||
HMODULE ntdll_module; | ||
HMODULE kernel32_module; | ||
HMODULE powrprof_module; | ||
HMODULE user32_module; | ||
|
||
ntdll_module = GetModuleHandleA("ntdll.dll"); | ||
if (ntdll_module == NULL) { | ||
|
@@ -156,4 +160,10 @@ void uv_winapi_init(void) { | |
GetProcAddress(powrprof_module, "PowerRegisterSuspendResumeNotification"); | ||
} | ||
|
||
user32_module = LoadLibraryA("user32.dll"); | ||
if (user32_module != NULL) { | ||
pSetWinEventHook = (sSetWinEventHook) | ||
GetProcAddress(user32_module, "SetWinEventHook"); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Micro-nit: no blank line. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4725,6 +4725,25 @@ typedef DWORD (WINAPI *sPowerRegisterSuspendResumeNotification) | |
HANDLE Recipient, | ||
_PHPOWERNOTIFY RegistrationHandle); | ||
|
||
/* from Winuser.h */ | ||
typedef VOID (CALLBACK* WINEVENTPROC) | ||
(HWINEVENTHOOK hWinEventHook, | ||
DWORD event, | ||
HWND hwnd, | ||
LONG idObject, | ||
LONG idChild, | ||
DWORD idEventThread, | ||
DWORD dwmsEventTime); | ||
|
||
typedef HWINEVENTHOOK (WINAPI *sSetWinEventHook) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious- why is this needed? https://msdn.microsoft.com/en-us/library/windows/desktop/dd318453(v=vs.85).aspx states that HWINEVENTHOOK is available by simply including windows.h, which we do at the top of this file (and more generally, I would expect that most of the structs/types that we define in this file are available through windows.h so I'd like to understand why our definitions would not be redundant) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the header file it is inside It looks like it is not needed though. |
||
(UINT eventMin, | ||
UINT eventMax, | ||
HMODULE hmodWinEventProc, | ||
WINEVENTPROC lpfnWinEventProc, | ||
DWORD idProcess, | ||
DWORD idThread, | ||
UINT dwflags); | ||
|
||
|
||
/* Ntdll function pointers */ | ||
extern sRtlNtStatusToDosError pRtlNtStatusToDosError; | ||
|
@@ -4753,4 +4772,7 @@ extern sGetFinalPathNameByHandleW pGetFinalPathNameByHandleW; | |
/* Powrprof.dll function pointer */ | ||
extern sPowerRegisterSuspendResumeNotification pPowerRegisterSuspendResumeNotification; | ||
|
||
/* User32.dll function pointer */ | ||
extern sSetWinEventHook pSetWinEventHook; | ||
|
||
#endif /* UV_WIN_WINAPI_H_ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More a question than a comment but do we ever call FreeLibrary on these DLLs? I guess we just expect them to be loaded for the duration of the process? I imagine there are some scenarios where we'd want some of these DLLs to be unloaded earlier if possible but certainly not in this case