From 4118697829d55768528b44f217d118a2352fb64a Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 12 Dec 2019 11:46:39 +0100 Subject: [PATCH] server: Support passing a handle to get_console_wait_event. Signed-off-by: Alexandre Julliard --- dlls/kernel32/console.c | 2 +- include/wine/server_protocol.h | 6 +++--- server/console.c | 18 +++++++++++++++--- server/protocol.def | 3 ++- server/request.h | 3 ++- server/trace.c | 3 ++- 6 files changed, 25 insertions(+), 10 deletions(-) diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 0842bb71a63..86fdae0ecb8 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -310,7 +310,7 @@ HANDLE WINAPI GetConsoleInputWaitHandle(void) SERVER_START_REQ(get_console_wait_event) { if (!wine_server_call_err( req )) - console_wait_event = wine_server_ptr_handle( reply->handle ); + console_wait_event = wine_server_ptr_handle( reply->event ); } SERVER_END_REQ; } diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index aaa5fd2e33e..c5d6ce1796a 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -1922,12 +1922,12 @@ struct attach_console_reply struct get_console_wait_event_request { struct request_header __header; - char __pad_12[4]; + obj_handle_t handle; }; struct get_console_wait_event_reply { struct reply_header __header; - obj_handle_t handle; + obj_handle_t event; char __pad_12[4]; }; @@ -6702,6 +6702,6 @@ union generic_reply struct resume_process_reply resume_process_reply; }; -#define SERVER_PROTOCOL_VERSION 593 +#define SERVER_PROTOCOL_VERSION 594 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */ diff --git a/server/console.c b/server/console.c index 59f8843a75f..b5f8992b8df 100644 --- a/server/console.c +++ b/server/console.c @@ -1905,14 +1905,26 @@ static int cgwe_enum( struct process* process, void* user) DECL_HANDLER(get_console_wait_event) { struct console_input* console = NULL; + struct object *obj; - if (current->process->console) - console = (struct console_input*)grab_object( (struct object*)current->process->console ); + if (req->handle) + { + if (!(obj = get_handle_obj( current->process, req->handle, FILE_READ_PROPERTIES, NULL ))) return; + if (obj->ops == &console_input_ops) + console = (struct console_input *)grab_object( obj ); + else if (obj->ops == &screen_buffer_ops) + console = (struct console_input *)grab_object( ((struct screen_buffer *)obj)->input ); + else + set_error( STATUS_OBJECT_TYPE_MISMATCH ); + release_object( obj ); + } + else if (current->process->console) + console = (struct console_input *)grab_object( current->process->console ); else enum_processes(cgwe_enum, &console); if (console) { - reply->handle = alloc_handle( current->process, console->event, EVENT_ALL_ACCESS, 0 ); + reply->event = alloc_handle( current->process, console->event, EVENT_ALL_ACCESS, 0 ); release_object( console ); } else set_error( STATUS_INVALID_PARAMETER ); diff --git a/server/protocol.def b/server/protocol.def index 1cb1fea6023..34fa38976d8 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1532,8 +1532,9 @@ struct console_renderer_event /* Get the input queue wait event */ @REQ(get_console_wait_event) + obj_handle_t handle; /* handle to the console */ @REPLY - obj_handle_t handle; + obj_handle_t event; @END /* Get a console mode (input or output) */ diff --git a/server/request.h b/server/request.h index 90a3180a6c5..cc00cbdeb3d 100644 --- a/server/request.h +++ b/server/request.h @@ -1144,8 +1144,9 @@ C_ASSERT( FIELD_OFFSET(struct attach_console_reply, std_in) == 8 ); C_ASSERT( FIELD_OFFSET(struct attach_console_reply, std_out) == 12 ); C_ASSERT( FIELD_OFFSET(struct attach_console_reply, std_err) == 16 ); C_ASSERT( sizeof(struct attach_console_reply) == 24 ); +C_ASSERT( FIELD_OFFSET(struct get_console_wait_event_request, handle) == 12 ); C_ASSERT( sizeof(struct get_console_wait_event_request) == 16 ); -C_ASSERT( FIELD_OFFSET(struct get_console_wait_event_reply, handle) == 8 ); +C_ASSERT( FIELD_OFFSET(struct get_console_wait_event_reply, event) == 8 ); C_ASSERT( sizeof(struct get_console_wait_event_reply) == 16 ); C_ASSERT( FIELD_OFFSET(struct get_console_mode_request, handle) == 12 ); C_ASSERT( sizeof(struct get_console_mode_request) == 16 ); diff --git a/server/trace.c b/server/trace.c index 5b1d3ddea98..f15ed8b37ab 100644 --- a/server/trace.c +++ b/server/trace.c @@ -2031,11 +2031,12 @@ static void dump_attach_console_reply( const struct attach_console_reply *req ) static void dump_get_console_wait_event_request( const struct get_console_wait_event_request *req ) { + fprintf( stderr, " handle=%04x", req->handle ); } static void dump_get_console_wait_event_reply( const struct get_console_wait_event_reply *req ) { - fprintf( stderr, " handle=%04x", req->handle ); + fprintf( stderr, " event=%04x", req->event ); } static void dump_get_console_mode_request( const struct get_console_mode_request *req )