Commit bc55b75d authored by Vitaliy Margolen's avatar Vitaliy Margolen Committed by Alexandre Julliard

user32: Pass hook handle to the destination thread.

parent 2f80fcd8
......@@ -329,18 +329,24 @@ static LRESULT call_hook( struct hook_info *info, INT code, WPARAM wparam, LPARA
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 hhook, INT code, WPARAM wparam, LPARAM lpar
}
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.@)
*/
......
......@@ -612,11 +612,19 @@ static size_t pack_message( HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
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, UINT message, WPARAM *wparam, LPARAM *lpa
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( HWND hwnd, UINT msg, WPARAM wparam, LPAR
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 );
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment