From 29a3ce9f3a455bec5d2d9cba7c709e08a53aa3a3 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 4 Oct 2006 16:29:45 +0200 Subject: [PATCH] server: Return the data for callback results in the varargs part of the get_message request. --- dlls/user/message.c | 8 ++++++-- include/wine/server_protocol.h | 11 ++++++++++- server/protocol.def | 15 ++++++++++++--- server/queue.c | 27 +++++++++++++++++++++------ 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/dlls/user/message.c b/dlls/user/message.c index 7ed5b6eb5ec..0b4da22c960 100644 --- a/dlls/user/message.c +++ b/dlls/user/message.c @@ -1989,8 +1989,12 @@ static BOOL peek_message( MSG *msg, HWND hwnd, UINT first, UINT last, int flags info.flags = ISMEX_CALLBACK; break; case MSG_CALLBACK_RESULT: - call_sendmsg_callback( (SENDASYNCPROC)info.msg.wParam, info.msg.hwnd, - info.msg.message, extra_info, info.msg.lParam ); + if (size >= sizeof(struct callback_msg_data)) + { + const struct callback_msg_data *data = (const struct callback_msg_data *)buffer; + call_sendmsg_callback( data->callback, info.msg.hwnd, + info.msg.message, data->data, data->result ); + } goto next; case MSG_WINEVENT: if (size >= sizeof(struct winevent_msg_data)) diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 3c902e926bf..29aa6b37bfe 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -157,6 +157,14 @@ typedef struct } rectangle_t; + +struct callback_msg_data +{ + void *callback; + unsigned long data; + unsigned long result; +}; + struct winevent_msg_data { user_handle_t hook; @@ -168,6 +176,7 @@ struct winevent_msg_data typedef union { unsigned char bytes[1]; + struct callback_msg_data callback; struct winevent_msg_data winevent; } message_data_t; @@ -4419,6 +4428,6 @@ union generic_reply struct query_symlink_reply query_symlink_reply; }; -#define SERVER_PROTOCOL_VERSION 248 +#define SERVER_PROTOCOL_VERSION 249 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/protocol.def b/server/protocol.def index 02a95c03b45..6358efea205 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -173,6 +173,14 @@ typedef struct } rectangle_t; /* structures for extra message data */ + +struct callback_msg_data +{ + void *callback; /* callback function */ + unsigned long data; /* user data for callback */ + unsigned long result; /* message result */ +}; + struct winevent_msg_data { user_handle_t hook; /* hook handle */ @@ -184,6 +192,7 @@ struct winevent_msg_data typedef union { unsigned char bytes[1]; /* raw data for sent messages */ + struct callback_msg_data callback; struct winevent_msg_data winevent; } message_data_t; @@ -1637,9 +1646,9 @@ enum message_type int type; /* message type */ user_handle_t win; /* window handle */ unsigned int msg; /* message code */ - unsigned long wparam; /* parameters (callback function for MSG_CALLBACK_RESULT) */ - unsigned long lparam; /* parameters (result for MSG_CALLBACK_RESULT) */ - unsigned long info; /* extra info (callback argument for MSG_CALLBACK_RESULT) */ + unsigned long wparam; /* parameters */ + unsigned long lparam; /* parameters */ + unsigned long info; /* extra info */ int x; /* x position */ int y; /* y position */ unsigned int time; /* message time */ diff --git a/server/queue.c b/server/queue.c index a7aa5c86c38..64c29fd0098 100644 --- a/server/queue.c +++ b/server/queue.c @@ -404,7 +404,11 @@ static void free_result( struct message_result *result ) { if (result->timeout) remove_timeout_user( result->timeout ); if (result->data) free( result->data ); - if (result->callback_msg) free( result->callback_msg ); + if (result->callback_msg) + { + free( result->callback_msg->data ); + free( result->callback_msg ); + } free( result ); } @@ -435,7 +439,8 @@ static void store_message_result( struct message_result *res, unsigned int resul if (res->callback_msg) { /* queue the callback message in the sender queue */ - res->callback_msg->lparam = result; + struct callback_msg_data *data = res->callback_msg->data; + data->result = result; list_add_tail( &res->sender->msg_list[SEND_MESSAGE], &res->callback_msg->entry ); set_queue_bits( res->sender, QS_SENDMESSAGE ); res->callback_msg = NULL; @@ -533,24 +538,34 @@ static struct message_result *alloc_message_result( struct msg_queue *send_queue if (msg->type == MSG_CALLBACK) { + struct callback_msg_data *data; struct message *callback_msg = mem_alloc( sizeof(*callback_msg) ); + if (!callback_msg) { free( result ); return NULL; } + if (!(data = mem_alloc( sizeof(*data )))) + { + free( callback_msg ); + free( result ); + return NULL; + } callback_msg->type = MSG_CALLBACK_RESULT; callback_msg->win = msg->win; callback_msg->msg = msg->msg; - callback_msg->wparam = (unsigned long)callback; + callback_msg->wparam = 0; callback_msg->lparam = 0; callback_msg->time = get_tick_count(); callback_msg->x = 0; callback_msg->y = 0; - callback_msg->info = callback_data; + callback_msg->info = 0; callback_msg->result = NULL; - callback_msg->data = NULL; - callback_msg->data_size = 0; + callback_msg->data = data; + callback_msg->data_size = sizeof(*data); + data->callback = callback; + data->data = callback_data; result->callback_msg = callback_msg; list_add_head( &send_queue->callback_result, &result->sender_entry );