Jacek Caban : user32: Use User32CallWinEventHook in peek_message.

Alexandre Julliard julliard at winehq.org
Wed Mar 23 17:03:55 CDT 2022


Module: wine
Branch: master
Commit: 9ced5b0509b829833f818e6c39c3bc8ddde01341
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9ced5b0509b829833f818e6c39c3bc8ddde01341

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Mar 23 14:01:42 2022 +0100

user32: Use User32CallWinEventHook in peek_message.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/hook.c    |  6 +++---
 dlls/user32/message.c | 43 ++++++++++++++++---------------------------
 dlls/win32u/hook.c    |  2 ++
 include/ntuser.h      |  2 ++
 4 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/dlls/user32/hook.c b/dlls/user32/hook.c
index 783ded6c12a..6dc8c571c0c 100644
--- a/dlls/user32/hook.c
+++ b/dlls/user32/hook.c
@@ -451,14 +451,14 @@ BOOL WINAPI User32CallWinEventHook( const struct win_event_hook_params *params,
 
     TRACE_(relay)( "\1Call winevent hook proc %p (hhook=%p,event=%x,hwnd=%p,object_id=%x,child_id=%x,tid=%04x,time=%x)\n",
                    proc, params->handle, params->event, params->hwnd, params->object_id,
-                   params->child_id, GetCurrentThreadId(), GetCurrentTime() );
+                   params->child_id, params->tid, params->time );
 
     proc( params->handle, params->event, params->hwnd, params->object_id, params->child_id,
-          GetCurrentThreadId(), GetCurrentTime() );
+          params->tid, params->time );
 
     TRACE_(relay)( "\1Ret  winevent hook proc %p (hhook=%p,event=%x,hwnd=%p,object_id=%x,child_id=%x,tid=%04x,time=%x)\n",
                    proc, params->handle, params->event, params->hwnd, params->object_id,
-                   params->child_id, GetCurrentThreadId(), GetCurrentTime() );
+                   params->child_id, params->tid, params->time );
 
     if (free_module) FreeLibrary( free_module );
     return TRUE;
diff --git a/dlls/user32/message.c b/dlls/user32/message.c
index 8100ee63fc3..1e7ec2b0615 100644
--- a/dlls/user32/message.c
+++ b/dlls/user32/message.c
@@ -2716,38 +2716,27 @@ static int peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, UINT flags,
         case MSG_WINEVENT:
             if (size >= sizeof(msg_data->winevent))
             {
-                WINEVENTPROC hook_proc;
-                HMODULE free_module = 0;
+                struct win_event_hook_params params;
 
-                hook_proc = wine_server_get_ptr( msg_data->winevent.hook_proc );
+                params.proc = wine_server_get_ptr( msg_data->winevent.hook_proc );
                 size -= sizeof(msg_data->winevent);
                 if (size)
                 {
-                    WCHAR module[MAX_PATH];
-
-                    size = min( size, (MAX_PATH - 1) * sizeof(WCHAR) );
-                    memcpy( module, &msg_data->winevent + 1, size );
-                    module[size / sizeof(WCHAR)] = 0;
-                    if (!(hook_proc = get_hook_proc( hook_proc, module, &free_module )))
-                    {
-                        ERR( "invalid winevent hook module name %s\n", debugstr_w(module) );
-                        continue;
-                    }
+                    size = min( size, sizeof(params.module) - sizeof(WCHAR) );
+                    memcpy( params.module, &msg_data->winevent + 1, size );
                 }
-
-                TRACE_(relay)( "\1Call winevent proc %p (hook=%04x,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n",
-                               hook_proc, msg_data->winevent.hook, info.msg.message, info.msg.hwnd,
-                               info.msg.wParam, info.msg.lParam, msg_data->winevent.tid, info.msg.time);
-
-                hook_proc( wine_server_ptr_handle( msg_data->winevent.hook ), info.msg.message,
-                           info.msg.hwnd, info.msg.wParam, info.msg.lParam,
-                           msg_data->winevent.tid, info.msg.time );
-
-                TRACE_(relay)( "\1Ret  winevent proc %p (hook=%04x,event=%x,hwnd=%p,object_id=%lx,child_id=%lx,tid=%04x,time=%x)\n",
-                               hook_proc, msg_data->winevent.hook, info.msg.message, info.msg.hwnd,
-                               info.msg.wParam, info.msg.lParam, msg_data->winevent.tid, info.msg.time);
-
-                if (free_module) FreeLibrary(free_module);
+                params.module[size / sizeof(WCHAR)] = 0;
+                size = FIELD_OFFSET( struct win_hook_params, module[size / sizeof(WCHAR) + 1] );
+
+                params.handle    = wine_server_ptr_handle( msg_data->winevent.hook );
+                params.event     = info.msg.message;
+                params.hwnd      = info.msg.hwnd;
+                params.object_id = info.msg.wParam;
+                params.child_id  = info.msg.lParam;
+                params.tid       = msg_data->winevent.tid;
+                params.time      = info.msg.time;
+
+                User32CallWinEventHook( &params, size );
             }
             continue;
         case MSG_HOOK_LL:
diff --git a/dlls/win32u/hook.c b/dlls/win32u/hook.c
index e1851aa896a..21e00d1ff3c 100644
--- a/dlls/win32u/hook.c
+++ b/dlls/win32u/hook.c
@@ -476,6 +476,7 @@ void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG c
     info.hwnd      = hwnd;
     info.object_id = object_id;
     info.child_id  = child_id;
+    info.tid       = GetCurrentThreadId();
 
     SERVER_START_REQ( start_hook_chain )
     {
@@ -502,6 +503,7 @@ void WINAPI NtUserNotifyWinEvent( DWORD event, HWND hwnd, LONG object_id, LONG c
         TRACE( "calling WH_WINEVENT hook %p event %x hwnd %p %x %x module %s\n",
                info.proc, event, hwnd, object_id, child_id, debugstr_w(info.module) );
 
+        info.time = NtGetTickCount();
         KeUserModeCallback( NtUserCallWinEventHook, &info,
                             FIELD_OFFSET( struct win_hook_params, module[lstrlenW(info.module) + 1] ),
                             &ret_ptr, &ret_len );
diff --git a/include/ntuser.h b/include/ntuser.h
index 746549e4b28..5b7cc0be597 100644
--- a/include/ntuser.h
+++ b/include/ntuser.h
@@ -58,6 +58,8 @@ struct win_event_hook_params
     LONG object_id;
     LONG child_id;
     void *handle;
+    DWORD tid;
+    DWORD time;
     WINEVENTPROC proc;
     WCHAR module[MAX_PATH];
 };




More information about the wine-cvs mailing list