From: Jacek Caban Subject: [PATCH 4/7] server: Remove support for creating bare consoles. Message-Id: Date: Tue, 22 Sep 2020 16:47:10 +0200 Signed-off-by: Jacek Caban --- programs/wineconsole/wineconsole.c | 2 - server/console.c | 89 +++++------------------------- server/protocol.def | 2 - 3 files changed, 15 insertions(+), 78 deletions(-) diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index f076eb21e43..415350fb404 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -685,7 +685,6 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna req->access = GENERIC_READ | GENERIC_WRITE; req->attributes = 0; req->pid = pid; - req->input_fd = -1; ret = !wine_server_call_err( req ); con_in = wine_server_ptr_handle( reply->handle_in ); @@ -711,7 +710,6 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna req->access = GENERIC_WRITE|GENERIC_READ; req->attributes = 0; req->share = FILE_SHARE_READ|FILE_SHARE_WRITE; - req->fd = -1; ret = !wine_server_call_err( req ); con_out = wine_server_ptr_handle( reply->handle_out ); } diff --git a/server/console.c b/server/console.c index 2a5d7733fe1..72be542cb96 100644 --- a/server/console.c +++ b/server/console.c @@ -563,15 +563,13 @@ static struct object *create_console_input_events(void) return &evt->obj; } -static struct object *create_console_input( int fd ) +static struct object *create_console_input(void) { struct console_input *console_input; if (!(console_input = alloc_object( &console_input_ops ))) - { - if (fd != -1) close( fd ); return NULL; - } + console_input->renderer = NULL; console_input->mode = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT | ENABLE_INSERT_MODE | @@ -600,21 +598,13 @@ static struct object *create_console_input( int fd ) if (!console_input->history || !console_input->event) { - if (fd != -1) close( fd ); console_input->history_size = 0; release_object( console_input ); return NULL; } - if (fd != -1) /* bare console */ - { - console_input->fd = create_anonymous_fd( &console_input_fd_ops, fd, &console_input->obj, - FILE_SYNCHRONOUS_IO_NONALERT ); - } - else - { - console_input->fd = alloc_pseudo_fd( &console_input_fd_ops, &console_input->obj, - FILE_SYNCHRONOUS_IO_NONALERT ); - } + + console_input->fd = alloc_pseudo_fd( &console_input_fd_ops, &console_input->obj, + FILE_SYNCHRONOUS_IO_NONALERT ); if (!console_input->fd) { release_object( console_input ); @@ -724,7 +714,7 @@ static void set_active_screen_buffer( struct console_input *console_input, struc console_input_events_append( console_input, &evt ); } -static struct object *create_console_output( struct console_input *console_input, int fd ) +static struct object *create_console_output( struct console_input *console_input ) { struct screen_buffer *screen_buffer; int i; @@ -736,10 +726,8 @@ static struct object *create_console_output( struct console_input *console_input } if (!(screen_buffer = alloc_object( &screen_buffer_ops ))) - { - if (fd != -1) close( fd ); return NULL; - } + screen_buffer->id = ++console_input->last_id; screen_buffer->mode = ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT; screen_buffer->input = console_input; @@ -768,12 +756,8 @@ static struct object *create_console_output( struct console_input *console_input init_async_queue( &screen_buffer->ioctl_q ); list_add_head( &screen_buffer_list, &screen_buffer->entry ); - if (fd != -1) - screen_buffer->fd = create_anonymous_fd( &screen_buffer_fd_ops, fd, &screen_buffer->obj, - FILE_SYNCHRONOUS_IO_NONALERT ); - else - screen_buffer->fd = alloc_pseudo_fd( &screen_buffer_fd_ops, &screen_buffer->obj, - FILE_SYNCHRONOUS_IO_NONALERT ); + screen_buffer->fd = alloc_pseudo_fd( &screen_buffer_fd_ops, &screen_buffer->obj, + FILE_SYNCHRONOUS_IO_NONALERT ); if (!screen_buffer->fd) { release_object( screen_buffer ); @@ -1740,8 +1724,8 @@ static struct object *console_server_lookup_name( struct object *obj, struct uni set_error( STATUS_INVALID_HANDLE ); return 0; } - if (!(server->console = (struct console_input *)create_console_input( -1 ))) return NULL; - if (!(screen_buffer = (struct screen_buffer *)create_console_output( server->console, -1 ))) + if (!(server->console = (struct console_input *)create_console_input())) return NULL; + if (!(screen_buffer = (struct screen_buffer *)create_console_output( server->console ))) { release_object( server->console ); server->console = NULL; @@ -2513,7 +2497,7 @@ static struct object *console_device_lookup_name( struct object *obj, struct uni return NULL; } name->len = 0; - return create_console_output( current->process->console, -1 ); + return create_console_output( current->process->console ); } if (name->len == sizeof(serverW) && !memcmp( name->str, serverW, name->len )) @@ -2560,52 +2544,29 @@ DECL_HANDLER(alloc_console) { struct process *process; struct console_input *console; - int fd; int attach = 0; - if (req->input_fd != -1) - { - if ((fd = thread_get_inflight_fd( current, req->input_fd )) == -1) - { - set_error( STATUS_INVALID_PARAMETER ); - return; - } - } - else fd = -1; - switch (req->pid) { case 0: /* console to be attached to parent process */ if (!(process = get_process_from_id( current->process->parent_id ))) { - if (fd != -1) close( fd ); set_error( STATUS_ACCESS_DENIED ); return; } attach = 1; break; - case 0xffffffff: - /* console to be attached to current process */ - process = current->process; - grab_object( process ); - attach = 1; - break; default: /* console to be attached to req->pid */ - if (!(process = get_process_from_id( req->pid ))) - { - if (fd != -1) close( fd ); - return; - } + if (!(process = get_process_from_id( req->pid ))) return; } if (attach && process->console) { - if (fd != -1) close( fd ); set_error( STATUS_ACCESS_DENIED ); } - else if ((console = (struct console_input*)create_console_input( fd ))) + else if ((console = (struct console_input*)create_console_input())) { if ((reply->handle_in = alloc_handle( current->process, console, req->access, req->attributes )) && attach) @@ -2649,31 +2610,11 @@ DECL_HANDLER(create_console_output) { struct console_input *console; struct object *screen_buffer; - int fd; - if (req->fd != -1) - { - if ((fd = thread_get_inflight_fd( current, req->fd )) == -1) - { - set_error( STATUS_INVALID_HANDLE ); - return; - } - } - else fd = -1; if (!(console = console_input_get( req->handle_in, FILE_WRITE_PROPERTIES ))) - { - if (fd != -1) close( fd ); return; - } - if (console_input_is_bare( console ) ^ (fd != -1)) - { - if (fd != -1) close( fd ); - release_object( console ); - set_error( STATUS_INVALID_HANDLE ); - return; - } - screen_buffer = create_console_output( console, fd ); + screen_buffer = create_console_output( console ); if (screen_buffer) { /* FIXME: should store sharing and test it when opening the CONOUT$ device diff --git a/server/protocol.def b/server/protocol.def index fd9b721d693..74be47e538f 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1461,7 +1461,6 @@ enum server_fd_type unsigned int access; /* wanted access rights */ unsigned int attributes; /* object attributes */ process_id_t pid; /* pid of process which shall be attached to the console */ - int input_fd; /* if pid=-1 (bare console to current process), fd for input */ @REPLY obj_handle_t handle_in; /* handle to console input */ @END @@ -1503,7 +1502,6 @@ enum server_fd_type unsigned int access; /* wanted access rights */ unsigned int attributes; /* object attributes */ unsigned int share; /* sharing credentials */ - int fd; /* for bare consoles, fd the screen-buffer is attached to */ @REPLY obj_handle_t handle_out; /* handle to the screen buffer */ @END