From: Hugh McMaster hugh.mcmaster@outlook.com
conhost.exe needs to know the ID of the connected console process to be able to load and save application-specific console settings to and from the registry. --- server/console.c | 12 ++++++++++++ server/protocol.def | 1 + 2 files changed, 13 insertions(+)
diff --git a/server/console.c b/server/console.c index 5f3f50d006f..9320c473dab 100644 --- a/server/console.c +++ b/server/console.c @@ -57,6 +57,7 @@ struct console struct thread *renderer; /* console renderer thread */ struct screen_buffer *active; /* active screen buffer */ struct console_server *server; /* console server object */ + unsigned int pid; /* console process ID */ unsigned int last_id; /* id of last created console buffer */ struct fd *fd; /* for bare console, attached input fd */ struct async_queue ioctl_q; /* ioctl queue */ @@ -538,6 +539,7 @@ static struct object *create_console(void) console->active = NULL; console->server = NULL; console->fd = NULL; + console->pid = 0; console->last_id = 0; init_async_queue( &console->ioctl_q ); init_async_queue( &console->read_q ); @@ -1565,6 +1567,14 @@ DECL_HANDLER(get_next_console_request) if (status == STATUS_PENDING) status = STATUS_INVALID_PARAMETER; if (async) { + if (!server->console->pid) + { + struct process *process = async_get_thread( async )->process; + + if (process->console && process->parent_id == current->process->parent_id) + server->console->pid = process->id; + } + iosb = async_get_iosb( async ); if (iosb->status == STATUS_PENDING) { @@ -1586,6 +1596,8 @@ DECL_HANDLER(get_next_console_request) server->busy = 0; }
+ reply->pid = server->console->pid; + /* if we have a blocking read ioctl in queue head and previous blocking read is still waiting, * move it to read queue for execution after current read is complete. move all blocking * ioctl at the same time to preserve their order. */ diff --git a/server/protocol.def b/server/protocol.def index 8c2fbeb4afe..038c9a4d82f 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1514,6 +1514,7 @@ enum server_fd_type unsigned int status; /* status of previous ioctl */ VARARG(out_data,bytes); /* out_data of previous ioctl */ @REPLY + unsigned int pid; /* console process ID */ unsigned int code; /* ioctl code */ unsigned int output; /* output id or 0 for input */ data_size_t out_size; /* ioctl output size */