Vitaliy Margolen : user32: Pass hook handle to the destination thread.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Oct 5 13:06:05 CDT 2006
Module: wine
Branch: master
Commit: bc55b75dc9a701cd2ff9d3775d6ae89df116d354
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bc55b75dc9a701cd2ff9d3775d6ae89df116d354
Author: Vitaliy Margolen <wine-patch at kievinfo.com>
Date: Wed Oct 4 21:27:09 2006 -0600
user32: Pass hook handle to the destination thread.
---
dlls/user/hook.c | 43 +++++++++++++++++++++++++++++++++++++++----
dlls/user/message.c | 31 ++++++++++++++++++++++++-------
dlls/user/user_private.h | 7 +++++++
3 files changed, 70 insertions(+), 11 deletions(-)
diff --git a/dlls/user/hook.c b/dlls/user/hook.c
index d016337..557f666 100644
--- a/dlls/user/hook.c
+++ b/dlls/user/hook.c
@@ -329,18 +329,24 @@ static LRESULT call_hook( struct hook_in
if (info->tid)
{
+ struct hook_extra_info h_extra;
+ h_extra.handle = info->handle;
+ h_extra.lparam = lparam;
+
TRACE( "calling hook in thread %04x %s code %x wp %x lp %lx\n",
info->tid, hook_names[info->id-WH_MINHOOK], code, wparam, lparam );
switch(info->id)
{
case WH_KEYBOARD_LL:
- MSG_SendInternalMessageTimeout( info->pid, info->tid, WM_WINE_KEYBOARD_LL_HOOK, wparam, lparam,
- SMTO_ABORTIFHUNG, get_ll_hook_timeout(), &ret );
+ MSG_SendInternalMessageTimeout( info->pid, info->tid, WM_WINE_KEYBOARD_LL_HOOK,
+ wparam, (LPARAM)&h_extra, SMTO_ABORTIFHUNG,
+ get_ll_hook_timeout(), &ret );
break;
case WH_MOUSE_LL:
- MSG_SendInternalMessageTimeout( info->pid, info->tid, WM_WINE_MOUSE_LL_HOOK, wparam, lparam,
- SMTO_ABORTIFHUNG, get_ll_hook_timeout(), &ret );
+ MSG_SendInternalMessageTimeout( info->pid, info->tid, WM_WINE_MOUSE_LL_HOOK,
+ wparam, (LPARAM)&h_extra, SMTO_ABORTIFHUNG,
+ get_ll_hook_timeout(), &ret );
break;
default:
ERR("Unknown hook id %d\n", info->id);
@@ -551,6 +557,35 @@ LRESULT WINAPI CallNextHookEx( HHOOK hho
}
+LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam )
+{
+ struct hook_info info;
+
+ ZeroMemory( &info, sizeof(info) - sizeof(info.module) );
+
+ SERVER_START_REQ( get_hook_info )
+ {
+ req->handle = hhook;
+ req->get_next = 0;
+ req->event = EVENT_MIN;
+ wine_server_set_reply( req, info.module, sizeof(info.module)-sizeof(WCHAR) );
+ if (!wine_server_call_err( req ))
+ {
+ info.module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0;
+ info.handle = reply->handle;
+ info.id = reply->id;
+ info.pid = reply->pid;
+ info.tid = reply->tid;
+ info.proc = reply->proc;
+ info.next_unicode = reply->unicode;
+ }
+ }
+ SERVER_END_REQ;
+
+ info.prev_unicode = TRUE; /* assume Unicode for this function */
+ return call_hook( &info, code, wparam, lparam );
+}
+
/***********************************************************************
* CallMsgFilterA (USER32.@)
*/
diff --git a/dlls/user/message.c b/dlls/user/message.c
index ccef67b..b92951c 100644
--- a/dlls/user/message.c
+++ b/dlls/user/message.c
@@ -612,11 +612,19 @@ static size_t pack_message( HWND hwnd, U
push_data( data, (WINDOWPOS *)lparam, sizeof(WINDOWPOS) );
return 0;
case WM_WINE_KEYBOARD_LL_HOOK:
- push_data( data, (KBDLLHOOKSTRUCT *)lparam, sizeof(KBDLLHOOKSTRUCT) );
+ {
+ struct hook_extra_info *h_extra = (struct hook_extra_info *)lparam;
+ push_data( data, h_extra, sizeof(*h_extra) );
+ push_data( data, (LPVOID)h_extra->lparam, sizeof(KBDLLHOOKSTRUCT) );
return 0;
+ }
case WM_WINE_MOUSE_LL_HOOK:
- push_data( data, (MSLLHOOKSTRUCT *)lparam, sizeof(MSLLHOOKSTRUCT) );
+ {
+ struct hook_extra_info *h_extra = (struct hook_extra_info *)lparam;
+ push_data( data, h_extra, sizeof(*h_extra) );
+ push_data( data, (LPVOID)h_extra->lparam, sizeof(MSLLHOOKSTRUCT) );
return 0;
+ }
case WM_NCPAINT:
if (wparam <= 1) return 0;
FIXME( "WM_NCPAINT hdc packing not supported yet\n" );
@@ -876,11 +884,17 @@ static BOOL unpack_message( HWND hwnd, U
minsize = sizeof(DEV_BROADCAST_HDR);
break;
case WM_WINE_KEYBOARD_LL_HOOK:
- minsize = sizeof(KBDLLHOOKSTRUCT);
- break;
case WM_WINE_MOUSE_LL_HOOK:
- minsize = sizeof(MSLLHOOKSTRUCT);
+ {
+ struct hook_extra_info *h_extra = (struct hook_extra_info *)*buffer;
+
+ minsize = sizeof(struct hook_extra_info) +
+ (message == WM_WINE_KEYBOARD_LL_HOOK ? sizeof(KBDLLHOOKSTRUCT)
+ : sizeof(MSLLHOOKSTRUCT));
+ if (size < minsize) return FALSE;
+ h_extra->lparam = (LPARAM)(h_extra + 1);
break;
+ }
case WM_NCPAINT:
if (*wparam <= 1) return TRUE;
FIXME( "WM_NCPAINT hdc unpacking not supported\n" );
@@ -1189,9 +1203,12 @@ static LRESULT handle_internal_message(
if (hwnd == GetDesktopWindow()) return 0;
return (LRESULT)SetActiveWindow( (HWND)wparam );
case WM_WINE_KEYBOARD_LL_HOOK:
- return HOOK_CallHooks( WH_KEYBOARD_LL, HC_ACTION, wparam, lparam, TRUE );
case WM_WINE_MOUSE_LL_HOOK:
- return HOOK_CallHooks( WH_MOUSE_LL, HC_ACTION, wparam, lparam, TRUE );
+ {
+ struct hook_extra_info *h_extra = (struct hook_extra_info *)lparam;
+
+ return call_current_hook( h_extra->handle, HC_ACTION, wparam, h_extra->lparam );
+ }
default:
if (msg >= WM_WINE_FIRST_DRIVER_MSG && msg <= WM_WINE_LAST_DRIVER_MSG)
return USER_Driver->pWindowMessage( hwnd, msg, wparam, lparam );
diff --git a/dlls/user/user_private.h b/dlls/user/user_private.h
index 332e8f0..ca8f7aa 100644
--- a/dlls/user/user_private.h
+++ b/dlls/user/user_private.h
@@ -184,6 +184,12 @@ struct user_thread_info
ULONG pad[11]; /* Available for more data */
};
+struct hook_extra_info
+{
+ HHOOK handle;
+ LPARAM lparam;
+};
+
static inline struct user_thread_info *get_user_thread_info(void)
{
return (struct user_thread_info *)NtCurrentTeb()->Win32ClientInfo;
@@ -202,6 +208,7 @@ extern HBRUSH SYSCOLOR_55AABrush;
extern BOOL CLIPBOARD_ReleaseOwner(void);
extern BOOL FOCUS_MouseActivate( HWND hwnd );
extern BOOL HOOK_IsHooked( INT id );
+extern LRESULT call_current_hook( HHOOK hhook, INT code, WPARAM wparam, LPARAM lparam );
extern LRESULT MSG_SendInternalMessageTimeout( DWORD dest_pid, DWORD dest_tid,
UINT msg, WPARAM wparam, LPARAM lparam,
UINT flags, UINT timeout, PDWORD_PTR res_ptr );
More information about the wine-cvs
mailing list