server: Pass console handle to the child process.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-08-13 16:01:08 +02:00 committed by Alexandre Julliard
parent 06c3e7e44c
commit 09ff2436c4
4 changed files with 10 additions and 6 deletions

View File

@ -3724,7 +3724,6 @@ static void test_AttachConsole_child(DWORD console_pid)
ok(!res && GetLastError() == ERROR_ACCESS_DENIED, ok(!res && GetLastError() == ERROR_ACCESS_DENIED,
"AttachConsole returned: %x(%u)\n", res, GetLastError()); "AttachConsole returned: %x(%u)\n", res, GetLastError());
todo_wine
ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n"); ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n");
res = FreeConsole(); res = FreeConsole();
ok(res, "FreeConsole failed: %u\n", GetLastError()); ok(res, "FreeConsole failed: %u\n", GetLastError());

View File

@ -620,8 +620,8 @@ int free_console( struct process *process )
* 2/ parent is a renderer which launches process, and process should attach to the console * 2/ parent is a renderer which launches process, and process should attach to the console
* rendered by parent * rendered by parent
*/ */
void inherit_console( struct thread *parent_thread, struct process *parent, struct process *process, obj_handle_t inherit_console( struct thread *parent_thread, struct process *parent, struct process *process,
obj_handle_t hconin ) obj_handle_t hconin )
{ {
int done = 0; int done = 0;
@ -652,6 +652,10 @@ void inherit_console( struct thread *parent_thread, struct process *parent, stru
process->console = (struct console_input *)grab_object( parent->console ); process->console = (struct console_input *)grab_object( parent->console );
process->console->num_proc++; process->console->num_proc++;
} }
if (!process->console) return 0;
return alloc_handle( process, process->console,
SYNCHRONIZE | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, 0 );
} }
struct thread *console_get_renderer( struct console_input *console ) struct thread *console_get_renderer( struct console_input *console )

View File

@ -1224,7 +1224,8 @@ DECL_HANDLER(new_process)
* like if hConOut and hConIn are console handles, then they should be on the same * like if hConOut and hConIn are console handles, then they should be on the same
* physical console * physical console
*/ */
inherit_console( parent_thread, parent, process, req->inherit_all ? info->data->hstdin : 0 ); info->data->console = inherit_console( parent_thread, parent,
process, req->inherit_all ? info->data->hstdin : 0 );
} }
if (!req->inherit_all && !(req->create_flags & CREATE_NEW_CONSOLE)) if (!req->inherit_all && !(req->create_flags & CREATE_NEW_CONSOLE))

View File

@ -131,8 +131,8 @@ extern void detach_debugged_processes( struct thread *debugger );
extern void enum_processes( int (*cb)(struct process*, void*), void *user); extern void enum_processes( int (*cb)(struct process*, void*), void *user);
/* console functions */ /* console functions */
extern void inherit_console( struct thread *parent_thread, struct process *parent, extern obj_handle_t inherit_console( struct thread *parent_thread, struct process *parent,
struct process *process, obj_handle_t hconin ); struct process *process, obj_handle_t hconin );
extern int free_console( struct process *process ); extern int free_console( struct process *process );
extern struct thread *console_get_renderer( struct console_input *console ); extern struct thread *console_get_renderer( struct console_input *console );