From d6565b083251427e0b64efa279c314316aa20dee Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 16 Sep 2020 20:39:35 +0200 Subject: [PATCH] server: Support creating console reference from console connection object. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- server/console.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/server/console.c b/server/console.c index b9fb0fb4487..5346c7cb8f1 100644 --- a/server/console.c +++ b/server/console.c @@ -367,6 +367,7 @@ struct console_connection static void console_connection_dump( struct object *obj, int verbose ); static struct fd *console_connection_get_fd( struct object *obj ); +static struct object *console_connection_lookup_name( struct object *obj, struct unicode_str *name, unsigned int attr ); 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 ); @@ -386,7 +387,7 @@ static const struct object_ops console_connection_ops = no_map_access, /* map_access */ default_get_sd, /* get_sd */ default_set_sd, /* set_sd */ - no_lookup_name, /* lookup_name */ + console_connection_lookup_name, /* lookup_name */ directory_link_name, /* link_name */ default_unlink_name, /* unlink_name */ console_connection_open_file, /* open_file */ @@ -2353,6 +2354,24 @@ static struct fd *console_connection_get_fd( struct object *obj ) return (struct fd *)grab_object( connection->fd ); } +static struct object *console_connection_lookup_name( struct object *obj, struct unicode_str *name, unsigned int attr ) +{ + static const WCHAR referenceW[] = {'R','e','f','e','r','e','n','c','e'}; + + if (name->len == sizeof(referenceW) && !memcmp( name->str, referenceW, name->len )) + { + if (!current->process->console) + { + set_error( STATUS_INVALID_HANDLE ); + return NULL; + } + name->len = 0; + return grab_object( current->process->console ); + } + + return NULL; +} + static struct object *console_connection_open_file( struct object *obj, unsigned int access, unsigned int sharing, unsigned int options ) {