From ecf7ed66509b462b7a9cd6e23dbd1b2b43f515d6 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 11 Mar 2015 22:45:51 +0900 Subject: [PATCH] server: Add a request to store the results of an ioctl asynchronously. --- include/wine/server_protocol.h | 20 +++++++++++++++++++- server/device.c | 20 ++++++++++++++++++++ server/protocol.def | 9 +++++++++ server/request.h | 6 ++++++ server/trace.c | 11 +++++++++++ 5 files changed, 65 insertions(+), 1 deletion(-) diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 9d645d7cb81..1b7831e73cc 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -3128,6 +3128,21 @@ struct ioctl_reply +struct set_ioctl_result_request +{ + struct request_header __header; + obj_handle_t manager; + obj_handle_t handle; + unsigned int status; + /* VARARG(data,bytes); */ +}; +struct set_ioctl_result_reply +{ + struct reply_header __header; +}; + + + struct get_ioctl_result_request { struct request_header __header; @@ -5211,6 +5226,7 @@ enum request REQ_register_async, REQ_cancel_async, REQ_ioctl, + REQ_set_ioctl_result, REQ_get_ioctl_result, REQ_create_named_pipe, REQ_get_named_pipe_info, @@ -5473,6 +5489,7 @@ union generic_request struct register_async_request register_async_request; struct cancel_async_request cancel_async_request; struct ioctl_request ioctl_request; + struct set_ioctl_result_request set_ioctl_result_request; struct get_ioctl_result_request get_ioctl_result_request; struct create_named_pipe_request create_named_pipe_request; struct get_named_pipe_info_request get_named_pipe_info_request; @@ -5733,6 +5750,7 @@ union generic_reply struct register_async_reply register_async_reply; struct cancel_async_reply cancel_async_reply; struct ioctl_reply ioctl_reply; + struct set_ioctl_result_reply set_ioctl_result_reply; struct get_ioctl_result_reply get_ioctl_result_reply; struct create_named_pipe_reply create_named_pipe_reply; struct get_named_pipe_info_reply get_named_pipe_info_reply; @@ -5848,6 +5866,6 @@ union generic_reply struct set_suspend_context_reply set_suspend_context_reply; }; -#define SERVER_PROTOCOL_VERSION 459 +#define SERVER_PROTOCOL_VERSION 460 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/device.c b/server/device.c index c5e31076c71..9d1bf3578c7 100644 --- a/server/device.c +++ b/server/device.c @@ -531,6 +531,26 @@ DECL_HANDLER(get_next_device_request) } +/* store results of an async ioctl */ +DECL_HANDLER(set_ioctl_result) +{ + struct ioctl_call *ioctl; + struct device_manager *manager; + + if (!(manager = (struct device_manager *)get_handle_obj( current->process, req->manager, + 0, &device_manager_ops ))) + return; + + if ((ioctl = (struct ioctl_call *)get_handle_obj( current->process, req->handle, 0, &ioctl_call_ops ))) + { + set_ioctl_result( ioctl, req->status, get_req_data(), get_req_data_size() ); + close_handle( current->process, req->handle ); /* avoid an extra round-trip for close */ + release_object( ioctl ); + } + release_object( manager ); +} + + /* retrieve results of an async ioctl */ DECL_HANDLER(get_ioctl_result) { diff --git a/server/protocol.def b/server/protocol.def index 7ec380b5665..2cd82725ef0 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -2262,6 +2262,15 @@ enum message_type @END +/* Store results of an async ioctl */ +@REQ(set_ioctl_result) + obj_handle_t manager; /* handle to the device manager */ + obj_handle_t handle; /* handle to the ioctl */ + unsigned int status; /* status of the ioctl */ + VARARG(data,bytes); /* output data of the ioctl */ +@END + + /* Retrieve results of an async ioctl */ @REQ(get_ioctl_result) obj_handle_t handle; /* handle to the device */ diff --git a/server/request.h b/server/request.h index e28757c44cb..022feff092b 100644 --- a/server/request.h +++ b/server/request.h @@ -248,6 +248,7 @@ DECL_HANDLER(set_serial_info); DECL_HANDLER(register_async); DECL_HANDLER(cancel_async); DECL_HANDLER(ioctl); +DECL_HANDLER(set_ioctl_result); DECL_HANDLER(get_ioctl_result); DECL_HANDLER(create_named_pipe); DECL_HANDLER(get_named_pipe_info); @@ -509,6 +510,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] = (req_handler)req_register_async, (req_handler)req_cancel_async, (req_handler)req_ioctl, + (req_handler)req_set_ioctl_result, (req_handler)req_get_ioctl_result, (req_handler)req_create_named_pipe, (req_handler)req_get_named_pipe_info, @@ -1511,6 +1513,10 @@ C_ASSERT( sizeof(struct ioctl_request) == 64 ); C_ASSERT( FIELD_OFFSET(struct ioctl_reply, wait) == 8 ); C_ASSERT( FIELD_OFFSET(struct ioctl_reply, options) == 12 ); C_ASSERT( sizeof(struct ioctl_reply) == 16 ); +C_ASSERT( FIELD_OFFSET(struct set_ioctl_result_request, manager) == 12 ); +C_ASSERT( FIELD_OFFSET(struct set_ioctl_result_request, handle) == 16 ); +C_ASSERT( FIELD_OFFSET(struct set_ioctl_result_request, status) == 20 ); +C_ASSERT( sizeof(struct set_ioctl_result_request) == 24 ); C_ASSERT( FIELD_OFFSET(struct get_ioctl_result_request, handle) == 12 ); C_ASSERT( FIELD_OFFSET(struct get_ioctl_result_request, user_arg) == 16 ); C_ASSERT( sizeof(struct get_ioctl_result_request) == 24 ); diff --git a/server/trace.c b/server/trace.c index 1bda4cdd64e..c7f49219edc 100644 --- a/server/trace.c +++ b/server/trace.c @@ -2732,6 +2732,14 @@ static void dump_ioctl_reply( const struct ioctl_reply *req ) dump_varargs_bytes( ", out_data=", cur_size ); } +static void dump_set_ioctl_result_request( const struct set_ioctl_result_request *req ) +{ + fprintf( stderr, " manager=%04x", req->manager ); + fprintf( stderr, ", handle=%04x", req->handle ); + fprintf( stderr, ", status=%08x", req->status ); + dump_varargs_bytes( ", data=", cur_size ); +} + static void dump_get_ioctl_result_request( const struct get_ioctl_result_request *req ) { fprintf( stderr, " handle=%04x", req->handle ); @@ -4230,6 +4238,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_register_async_request, (dump_func)dump_cancel_async_request, (dump_func)dump_ioctl_request, + (dump_func)dump_set_ioctl_result_request, (dump_func)dump_get_ioctl_result_request, (dump_func)dump_create_named_pipe_request, (dump_func)dump_get_named_pipe_info_request, @@ -4488,6 +4497,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { NULL, NULL, (dump_func)dump_ioctl_reply, + NULL, (dump_func)dump_get_ioctl_result_reply, (dump_func)dump_create_named_pipe_reply, (dump_func)dump_get_named_pipe_info_reply, @@ -4746,6 +4756,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = { "register_async", "cancel_async", "ioctl", + "set_ioctl_result", "get_ioctl_result", "create_named_pipe", "get_named_pipe_info",