server: Return the data for winevent hooks in the varargs part of the get_message request.

This commit is contained in:
Alexandre Julliard 2006-10-04 16:04:53 +02:00
parent f16ddf1b32
commit 59dc456822
5 changed files with 83 additions and 54 deletions

View File

@ -68,8 +68,6 @@ struct received_message_info
enum message_type type;
MSG msg;
UINT flags; /* InSendMessageEx return flags */
HWINEVENTHOOK hook; /* winevent hook handle */
WINEVENTPROC hook_proc; /* winevent hook proc address */
};
/* structure to group all parameters for sent messages of the various kinds */
@ -1958,8 +1956,6 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags
info.msg.time = reply->time;
info.msg.pt.x = reply->x;
info.msg.pt.y = reply->y;
info.hook = reply->hook;
info.hook_proc = reply->hook_proc;
hw_id = reply->hw_id;
extra_info = reply->info;
thread_info->active_hooks = reply->active_hooks;
@ -1997,32 +1993,42 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags
info.msg.message, extra_info, info.msg.lParam );
goto next;
case MSG_WINEVENT:
if (size)
if (size >= sizeof(struct winevent_msg_data))
{
WCHAR module[MAX_PATH];
size = min( size, (MAX_PATH - 1) * sizeof(WCHAR) );
memcpy( module, buffer, size );
module[size / sizeof(WCHAR)] = 0;
if (!(info.hook_proc = get_hook_proc( info.hook_proc, module )))
WINEVENTPROC hook_proc;
const struct winevent_msg_data *data = (const struct winevent_msg_data *)buffer;
hook_proc = data->hook_proc;
size -= sizeof(*data);
if (size)
{
ERR( "invalid winevent hook module name %s\n", debugstr_w(module) );
goto next;
WCHAR module[MAX_PATH];
size = min( size, (MAX_PATH - 1) * sizeof(WCHAR) );
memcpy( module, buffer, size );
module[size / sizeof(WCHAR)] = 0;
if (!(hook_proc = get_hook_proc( hook_proc, module )))
{
ERR( "invalid winevent hook module name %s\n", debugstr_w(module) );
goto next;
}
}
if (TRACE_ON(relay))
DPRINTF( "%04x:Call winevent proc %p (hook=%p,event=%x,hwnd=%p,object_id=%x,child_id=%lx,tid=%04x,time=%x)\n",
GetCurrentThreadId(), hook_proc,
data->hook, info.msg.message, info.msg.hwnd, info.msg.wParam,
info.msg.lParam, data->tid, info.msg.time);
hook_proc( data->hook, info.msg.message, info.msg.hwnd, info.msg.wParam,
info.msg.lParam, data->tid, info.msg.time );
if (TRACE_ON(relay))
DPRINTF( "%04x:Ret winevent proc %p (hook=%p,event=%x,hwnd=%p,object_id=%x,child_id=%lx,tid=%04x,time=%x)\n",
GetCurrentThreadId(), hook_proc,
data->hook, info.msg.message, info.msg.hwnd, info.msg.wParam,
info.msg.lParam, data->tid, info.msg.time);
}
if (TRACE_ON(relay))
DPRINTF( "%04x:Call winevent proc %p (hook=%p,event=%x,hwnd=%p,object_id=%x,child_id=%lx,tid=%04lx,time=%x)\n",
GetCurrentThreadId(), info.hook_proc,
info.hook, info.msg.message, info.msg.hwnd, info.msg.wParam,
info.msg.lParam, extra_info, info.msg.time);
info.hook_proc( info.hook, info.msg.message, info.msg.hwnd, info.msg.wParam,
info.msg.lParam, extra_info, info.msg.time );
if (TRACE_ON(relay))
DPRINTF( "%04x:Ret winevent proc %p (hook=%p,event=%x,hwnd=%p,object_id=%x,child_id=%lx,tid=%04lx,time=%x)\n",
GetCurrentThreadId(), info.hook_proc,
info.hook, info.msg.message, info.msg.hwnd, info.msg.wParam,
info.msg.lParam, extra_info, info.msg.time);
goto next;
case MSG_OTHER_PROCESS:
info.flags = ISMEX_SEND;

View File

@ -157,6 +157,21 @@ typedef struct
} rectangle_t;
struct winevent_msg_data
{
user_handle_t hook;
thread_id_t tid;
void *hook_proc;
};
typedef union
{
unsigned char bytes[1];
struct winevent_msg_data winevent;
} message_data_t;
typedef struct
{
WCHAR ch;
@ -2276,13 +2291,11 @@ struct get_message_reply
unsigned long info;
int x;
int y;
user_handle_t hook;
void* hook_proc;
unsigned int time;
unsigned int hw_id;
unsigned int active_hooks;
data_size_t total;
/* VARARG(data,bytes); */
/* VARARG(data,message_data); */
};
#define GET_MSG_REMOVE 1
#define GET_MSG_SENT_ONLY 2
@ -4406,6 +4419,6 @@ union generic_reply
struct query_symlink_reply query_symlink_reply;
};
#define SERVER_PROTOCOL_VERSION 247
#define SERVER_PROTOCOL_VERSION 248
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -172,6 +172,21 @@ typedef struct
int bottom;
} rectangle_t;
/* structures for extra message data */
struct winevent_msg_data
{
user_handle_t hook; /* hook handle */
thread_id_t tid; /* thread id */
void *hook_proc; /* hook proc address */
/* followed by module name if any */
};
typedef union
{
unsigned char bytes[1]; /* raw data for sent messages */
struct winevent_msg_data winevent;
} message_data_t;
/* structure for console char/attribute info */
typedef struct
{
@ -1627,13 +1642,11 @@ enum message_type
unsigned long info; /* extra info (callback argument for MSG_CALLBACK_RESULT) */
int x; /* x position */
int y; /* y position */
user_handle_t hook; /* winevent hook handle */
void* hook_proc; /* winevent hook proc address */
unsigned int time; /* message time */
unsigned int hw_id; /* id if hardware message */
unsigned int active_hooks; /* active hooks bitmap */
data_size_t total; /* total size of extra data */
VARARG(data,bytes); /* message data for sent messages */
VARARG(data,message_data); /* message data for sent messages */
@END
#define GET_MSG_REMOVE 1 /* remove the message */
#define GET_MSG_SENT_ONLY 2 /* only get sent messages */

View File

@ -76,8 +76,6 @@ struct message
int x; /* x position */
int y; /* y position */
unsigned int time; /* message time */
user_handle_t hook; /* winevent hook handle */
void *hook_proc; /* winevent hook proc address */
void *data; /* message data for sent messages */
unsigned int data_size; /* size of message data */
unsigned int unique_id; /* unique id for nested hw message waits */
@ -550,8 +548,6 @@ static struct message_result *alloc_message_result( struct msg_queue *send_queue
callback_msg->x = 0;
callback_msg->y = 0;
callback_msg->info = callback_data;
callback_msg->hook = 0;
callback_msg->hook_proc = NULL;
callback_msg->result = NULL;
callback_msg->data = NULL;
callback_msg->data_size = 0;
@ -596,8 +592,6 @@ static void receive_message( struct msg_queue *queue, struct message *msg,
reply->y = msg->y;
reply->time = msg->time;
reply->info = msg->info;
reply->hook = msg->hook;
reply->hook_proc = msg->hook_proc;
if (msg->data) set_reply_data_ptr( msg->data, msg->data_size );
@ -1458,8 +1452,6 @@ void post_message( user_handle_t win, unsigned int message,
msg->x = 0;
msg->y = 0;
msg->info = 0;
msg->hook = 0;
msg->hook_proc = NULL;
msg->result = NULL;
msg->data = NULL;
msg->data_size = 0;
@ -1481,6 +1473,8 @@ void post_win_event( struct thread *thread, unsigned int event,
if (thread->queue && (msg = mem_alloc( sizeof(*msg) )))
{
struct winevent_msg_data *data;
msg->type = MSG_WINEVENT;
msg->win = get_user_full_handle( win );
msg->msg = event;
@ -1489,15 +1483,18 @@ void post_win_event( struct thread *thread, unsigned int event,
msg->time = get_tick_count();
msg->x = 0;
msg->y = 0;
msg->info = get_thread_id( current );
msg->info = 0;
msg->result = NULL;
msg->hook = hook;
msg->hook_proc = hook_proc;
if ((msg->data = malloc( module_size )))
if ((data = malloc( sizeof(*data) + module_size )))
{
msg->data_size = module_size;
memcpy( msg->data, module, module_size );
data->hook = hook;
data->tid = get_thread_id( current );
data->hook_proc = hook_proc;
memcpy( data + 1, module, module_size );
msg->data = data;
msg->data_size = sizeof(*data) + module_size;
if (debug_level > 1)
fprintf( stderr, "post_win_event: tid %04x event %04x win %p object_id %d child_id %d\n",
@ -1589,8 +1586,6 @@ DECL_HANDLER(send_message)
msg->x = 0;
msg->y = 0;
msg->info = req->info;
msg->hook = 0;
msg->hook_proc = NULL;
msg->result = NULL;
msg->data = NULL;
msg->data_size = 0;
@ -1671,8 +1666,6 @@ DECL_HANDLER(send_hardware_message)
msg->x = req->x;
msg->y = req->y;
msg->info = req->info;
msg->hook = 0;
msg->hook_proc = NULL;
msg->result = NULL;
msg->data = NULL;
msg->data_size = 0;

View File

@ -389,6 +389,12 @@ static void dump_varargs_rectangles( data_size_t size )
remove_data( size );
}
static void dump_varargs_message_data( data_size_t size )
{
/* FIXME: dump the structured data */
dump_varargs_bytes( size );
}
static void dump_varargs_properties( data_size_t size )
{
const property_data_t *prop = cur_data;
@ -2136,14 +2142,12 @@ static void dump_get_message_reply( const struct get_message_reply *req )
fprintf( stderr, " info=%lx,", req->info );
fprintf( stderr, " x=%d,", req->x );
fprintf( stderr, " y=%d,", req->y );
fprintf( stderr, " hook=%p,", req->hook );
fprintf( stderr, " hook_proc=%p,", req->hook_proc );
fprintf( stderr, " time=%08x,", req->time );
fprintf( stderr, " hw_id=%08x,", req->hw_id );
fprintf( stderr, " active_hooks=%08x,", req->active_hooks );
fprintf( stderr, " total=%u,", req->total );
fprintf( stderr, " data=" );
dump_varargs_bytes( cur_size );
dump_varargs_message_data( cur_size );
}
static void dump_reply_message_request( const struct reply_message_request *req )