[PATCH 1/8] dinput: Don't pass a module handle to SetWindowsHookExW.

Rémi Bernon rbernon at codeweavers.com
Wed Jan 5 07:58:35 CST 2022


For low-level hooks, which don't need it. Passing a module handle will
make set_windows_hook call GetModuleFileNameW which requires the loader
lock.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52263
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---

This is a bit longer than I'd like and I don't like very much the idea
of the thread timeout, but I don't see any other solution.

Maybe a finer grained loader locking could solve the underlying problem,
but it's not going to be there soon.

 dlls/dinput/dinput_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c
index a62d4d2ea3d..980edeba817 100644
--- a/dlls/dinput/dinput_main.c
+++ b/dlls/dinput/dinput_main.c
@@ -1317,7 +1317,7 @@ static DWORD WINAPI dinput_thread_proc( void *params )
             LeaveCriticalSection( &dinput_hook_crit );
 
             if (kbd_cnt && !kbd_hook)
-                kbd_hook = SetWindowsHookExW( WH_KEYBOARD_LL, LL_hook_proc, DINPUT_instance, 0 );
+                kbd_hook = SetWindowsHookExW( WH_KEYBOARD_LL, LL_hook_proc, NULL, 0 );
             else if (!kbd_cnt && kbd_hook)
             {
                 UnhookWindowsHookEx( kbd_hook );
@@ -1325,7 +1325,7 @@ static DWORD WINAPI dinput_thread_proc( void *params )
             }
 
             if (mice_cnt && !mouse_hook)
-                mouse_hook = SetWindowsHookExW( WH_MOUSE_LL, LL_hook_proc, DINPUT_instance, 0 );
+                mouse_hook = SetWindowsHookExW( WH_MOUSE_LL, LL_hook_proc, NULL, 0 );
             else if (!mice_cnt && mouse_hook)
             {
                 UnhookWindowsHookEx( mouse_hook );
-- 
2.34.1




More information about the wine-devel mailing list