server: Introduce console_connection object.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-09-16 20:38:37 +02:00 committed by Alexandre Julliard
parent a6223249b4
commit 7364a4b075
1 changed files with 85 additions and 1 deletions

View File

@ -80,6 +80,7 @@ struct console_input
static void console_input_dump( struct object *obj, int verbose ); static void console_input_dump( struct object *obj, int verbose );
static void console_input_destroy( struct object *obj ); static void console_input_destroy( struct object *obj );
static struct fd *console_input_get_fd( struct object *obj ); static struct fd *console_input_get_fd( struct object *obj );
static struct object *console_input_lookup_name( struct object *obj, struct unicode_str *name, unsigned int attr );
static struct object *console_input_open_file( struct object *obj, unsigned int access, static struct object *console_input_open_file( struct object *obj, unsigned int access,
unsigned int sharing, unsigned int options ); unsigned int sharing, unsigned int options );
@ -97,7 +98,7 @@ static const struct object_ops console_input_ops =
default_fd_map_access, /* map_access */ default_fd_map_access, /* map_access */
default_get_sd, /* get_sd */ default_get_sd, /* get_sd */
default_set_sd, /* set_sd */ default_set_sd, /* set_sd */
no_lookup_name, /* lookup_name */ console_input_lookup_name, /* lookup_name */
no_link_name, /* link_name */ no_link_name, /* link_name */
NULL, /* unlink_name */ NULL, /* unlink_name */
console_input_open_file, /* open_file */ console_input_open_file, /* open_file */
@ -358,6 +359,39 @@ static const struct object_ops console_device_ops =
no_destroy /* destroy */ no_destroy /* destroy */
}; };
struct console_connection
{
struct object obj; /* object header */
};
static void console_connection_dump( struct object *obj, int verbose );
static struct object *console_connection_open_file( struct object *obj, unsigned int access,
unsigned int sharing, unsigned int options );
static int console_connection_close_handle( struct object *obj, struct process *process, obj_handle_t handle );
static const struct object_ops console_connection_ops =
{
sizeof(struct console_connection),/* size */
console_connection_dump, /* dump */
console_device_get_type, /* get_type */
no_add_queue, /* add_queue */
NULL, /* remove_queue */
NULL, /* signaled */
no_satisfied, /* satisfied */
no_signal, /* signal */
no_get_fd, /* get_fd */
no_map_access, /* map_access */
default_get_sd, /* get_sd */
default_set_sd, /* set_sd */
no_lookup_name, /* lookup_name */
directory_link_name, /* link_name */
default_unlink_name, /* unlink_name */
console_connection_open_file, /* open_file */
no_kernel_obj_list, /* get_kernel_obj_list */
console_connection_close_handle, /* close_handle */
no_destroy /* destroy */
};
static struct list screen_buffer_list = LIST_INIT(screen_buffer_list); static struct list screen_buffer_list = LIST_INIT(screen_buffer_list);
static const char_info_t empty_char_info = { ' ', 0x000f }; /* white on black space */ static const char_info_t empty_char_info = { ' ', 0x000f }; /* white on black space */
@ -1286,6 +1320,39 @@ static void console_input_destroy( struct object *obj )
free( console_in->history ); free( console_in->history );
} }
static struct object *create_console_connection( struct console_input *console )
{
struct console_connection *connection;
if (current->process->console)
{
set_error( STATUS_ACCESS_DENIED );
return NULL;
}
if (!(connection = alloc_object( &console_connection_ops ))) return NULL;
current->process->console = (struct console_input *)grab_object( console );
console->num_proc++;
return &connection->obj;
}
static struct object *console_input_lookup_name( struct object *obj, struct unicode_str *name, unsigned int attr )
{
struct console_input *console = (struct console_input *)obj;
static const WCHAR connectionW[] = {'C','o','n','n','e','c','t','i','o','n'};
assert( obj->ops == &console_input_ops );
if (name->len == sizeof(connectionW) && !memcmp( name->str, connectionW, name->len ))
{
name->len = 0;
return create_console_connection( console );
}
return NULL;
}
static struct object *console_input_open_file( struct object *obj, unsigned int access, static struct object *console_input_open_file( struct object *obj, unsigned int access,
unsigned int sharing, unsigned int options ) unsigned int sharing, unsigned int options )
{ {
@ -2209,6 +2276,23 @@ static int console_server_ioctl( struct fd *fd, ioctl_code_t code, struct async
} }
} }
static void console_connection_dump( struct object *obj, int verbose )
{
fputs( "console connection\n", stderr );
}
static struct object *console_connection_open_file( struct object *obj, unsigned int access,
unsigned int sharing, unsigned int options )
{
return grab_object( obj );
}
static int console_connection_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
{
free_console( process );
return 1;
}
static struct object_type *console_device_get_type( struct object *obj ) static struct object_type *console_device_get_type( struct object *obj )
{ {
static const WCHAR name[] = {'D','e','v','i','c','e'}; static const WCHAR name[] = {'D','e','v','i','c','e'};