server: Changed the get_next_hook request to allow retrieving the current hook too.

This commit is contained in:
Alexandre Julliard 2006-10-05 14:05:48 +02:00
parent 533f519950
commit 2f80fcd88d
6 changed files with 49 additions and 43 deletions

View File

@ -527,15 +527,16 @@ LRESULT WINAPI CallNextHookEx( HHOOK hhook, INT code, WPARAM wparam, LPARAM lpar
ZeroMemory( &info, sizeof(info) - sizeof(info.module) );
SERVER_START_REQ( get_next_hook )
SERVER_START_REQ( get_hook_info )
{
req->handle = thread_info->hook;
req->get_next = 1;
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->next;
info.handle = reply->handle;
info.id = reply->id;
info.pid = reply->pid;
info.tid = reply->tid;
@ -718,9 +719,10 @@ inline static BOOL find_next_hook(DWORD event, HWND hwnd, LONG object_id,
{
BOOL ret;
SERVER_START_REQ( get_next_hook )
SERVER_START_REQ( get_hook_info )
{
req->handle = info->handle;
req->get_next = 1;
req->event = event;
req->window = hwnd;
req->object_id = object_id;
@ -730,7 +732,7 @@ inline static BOOL find_next_hook(DWORD event, HWND hwnd, LONG object_id,
if (ret)
{
info->module[wine_server_reply_size(req) / sizeof(WCHAR)] = 0;
info->handle = reply->next;
info->handle = reply->handle;
info->proc = reply->proc;
info->tid = reply->tid;
}

View File

@ -3375,19 +3375,20 @@ struct finish_hook_chain_reply
struct get_next_hook_request
struct get_hook_info_request
{
struct request_header __header;
user_handle_t handle;
int get_next;
int event;
user_handle_t window;
int object_id;
int child_id;
};
struct get_next_hook_reply
struct get_hook_info_reply
{
struct reply_header __header;
user_handle_t next;
user_handle_t handle;
int id;
process_id_t pid;
thread_id_t tid;
@ -3961,7 +3962,7 @@ enum request
REQ_remove_hook,
REQ_start_hook_chain,
REQ_finish_hook_chain,
REQ_get_next_hook,
REQ_get_hook_info,
REQ_create_class,
REQ_destroy_class,
REQ_set_class_info,
@ -4182,7 +4183,7 @@ union generic_request
struct remove_hook_request remove_hook_request;
struct start_hook_chain_request start_hook_chain_request;
struct finish_hook_chain_request finish_hook_chain_request;
struct get_next_hook_request get_next_hook_request;
struct get_hook_info_request get_hook_info_request;
struct create_class_request create_class_request;
struct destroy_class_request destroy_class_request;
struct set_class_info_request set_class_info_request;
@ -4401,7 +4402,7 @@ union generic_reply
struct remove_hook_reply remove_hook_reply;
struct start_hook_chain_reply start_hook_chain_reply;
struct finish_hook_chain_reply finish_hook_chain_reply;
struct get_next_hook_reply get_next_hook_reply;
struct get_hook_info_reply get_hook_info_reply;
struct create_class_reply create_class_reply;
struct destroy_class_reply destroy_class_reply;
struct set_class_info_reply set_class_info_reply;
@ -4425,6 +4426,6 @@ union generic_reply
struct query_symlink_reply query_symlink_reply;
};
#define SERVER_PROTOCOL_VERSION 253
#define SERVER_PROTOCOL_VERSION 254
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -536,10 +536,10 @@ DECL_HANDLER(finish_hook_chain)
}
/* get the next hook to call */
DECL_HANDLER(get_next_hook)
/* get the hook information */
DECL_HANDLER(get_hook_info)
{
struct hook *hook, *next;
struct hook *hook;
if (!(hook = get_user_object( req->handle, USER_HOOK ))) return;
if (hook->thread && (hook->thread != current))
@ -547,22 +547,23 @@ DECL_HANDLER(get_next_hook)
set_error( STATUS_INVALID_HANDLE );
return;
}
if ((next = get_next_hook( current, hook, req->event, req->window, req->object_id, req->child_id )))
if (req->get_next && !(hook = get_next_hook( current, hook, req->event, req->window,
req->object_id, req->child_id )))
return;
reply->handle = hook->handle;
reply->id = hook->index + WH_MINHOOK;
reply->unicode = hook->unicode;
if (hook->module) set_reply_data( hook->module, min(hook->module_size,get_reply_max_size()) );
if (run_hook_in_owner_thread( hook ))
{
reply->next = next->handle;
reply->id = next->index + WH_MINHOOK;
reply->unicode = next->unicode;
if (next->module) set_reply_data( next->module, next->module_size );
if (run_hook_in_owner_thread( next ))
{
reply->pid = get_process_id( next->owner->process );
reply->tid = get_thread_id( next->owner );
}
else
{
reply->pid = 0;
reply->tid = 0;
}
reply->proc = next->proc;
reply->pid = get_process_id( hook->owner->process );
reply->tid = get_thread_id( hook->owner );
}
else
{
reply->pid = 0;
reply->tid = 0;
}
reply->proc = hook->proc;
}

View File

@ -2369,19 +2369,20 @@ enum message_type
@END
/* Get the next hook to call */
@REQ(get_next_hook)
/* Get the hook information */
@REQ(get_hook_info)
user_handle_t handle; /* handle to the current hook */
int get_next; /* do we want info about current or next hook? */
int event; /* signalled event */
user_handle_t window; /* handle to the event window */
int object_id; /* object id for out of context winevent */
int child_id; /* child id for out of context winevent */
@REPLY
user_handle_t next; /* handle to the next hook */
int id; /* id of the next hook */
user_handle_t handle; /* handle to the hook */
int id; /* id of the hook */
process_id_t pid; /* process id for low-level keyboard/mouse hooks */
thread_id_t tid; /* thread id for low-level keyboard/mouse hooks */
void* proc; /* next hook procedure */
void* proc; /* hook procedure */
int unicode; /* is it a unicode hook? */
VARARG(module,unicode_str); /* module name */
@END

View File

@ -302,7 +302,7 @@ DECL_HANDLER(set_hook);
DECL_HANDLER(remove_hook);
DECL_HANDLER(start_hook_chain);
DECL_HANDLER(finish_hook_chain);
DECL_HANDLER(get_next_hook);
DECL_HANDLER(get_hook_info);
DECL_HANDLER(create_class);
DECL_HANDLER(destroy_class);
DECL_HANDLER(set_class_info);
@ -522,7 +522,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] =
(req_handler)req_remove_hook,
(req_handler)req_start_hook_chain,
(req_handler)req_finish_hook_chain,
(req_handler)req_get_next_hook,
(req_handler)req_get_hook_info,
(req_handler)req_create_class,
(req_handler)req_destroy_class,
(req_handler)req_set_class_info,

View File

@ -2951,18 +2951,19 @@ static void dump_finish_hook_chain_request( const struct finish_hook_chain_reque
fprintf( stderr, " id=%d", req->id );
}
static void dump_get_next_hook_request( const struct get_next_hook_request *req )
static void dump_get_hook_info_request( const struct get_hook_info_request *req )
{
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " get_next=%d,", req->get_next );
fprintf( stderr, " event=%d,", req->event );
fprintf( stderr, " window=%p,", req->window );
fprintf( stderr, " object_id=%d,", req->object_id );
fprintf( stderr, " child_id=%d", req->child_id );
}
static void dump_get_next_hook_reply( const struct get_next_hook_reply *req )
static void dump_get_hook_info_reply( const struct get_hook_info_reply *req )
{
fprintf( stderr, " next=%p,", req->next );
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " id=%d,", req->id );
fprintf( stderr, " pid=%04x,", req->pid );
fprintf( stderr, " tid=%04x,", req->tid );
@ -3477,7 +3478,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_remove_hook_request,
(dump_func)dump_start_hook_chain_request,
(dump_func)dump_finish_hook_chain_request,
(dump_func)dump_get_next_hook_request,
(dump_func)dump_get_hook_info_request,
(dump_func)dump_create_class_request,
(dump_func)dump_destroy_class_request,
(dump_func)dump_set_class_info_request,
@ -3694,7 +3695,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
(dump_func)dump_remove_hook_reply,
(dump_func)dump_start_hook_chain_reply,
(dump_func)0,
(dump_func)dump_get_next_hook_reply,
(dump_func)dump_get_hook_info_reply,
(dump_func)0,
(dump_func)dump_destroy_class_reply,
(dump_func)dump_set_class_info_reply,
@ -3911,7 +3912,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = {
"remove_hook",
"start_hook_chain",
"finish_hook_chain",
"get_next_hook",
"get_hook_info",
"create_class",
"destroy_class",
"set_class_info",