diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index d66a2af6684..2b70c2ffc4c 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -3724,7 +3724,6 @@ static void test_AttachConsole_child(DWORD console_pid) ok(!res && GetLastError() == ERROR_ACCESS_DENIED, "AttachConsole returned: %x(%u)\n", res, GetLastError()); - todo_wine ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n"); res = FreeConsole(); ok(res, "FreeConsole failed: %u\n", GetLastError()); diff --git a/server/console.c b/server/console.c index 53910b3f46e..890ea609c2b 100644 --- a/server/console.c +++ b/server/console.c @@ -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 * rendered by parent */ -void inherit_console( struct thread *parent_thread, struct process *parent, struct process *process, - obj_handle_t hconin ) +obj_handle_t inherit_console( struct thread *parent_thread, struct process *parent, struct process *process, + obj_handle_t hconin ) { 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->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 ) diff --git a/server/process.c b/server/process.c index 5e587b28cbe..61ba1549e9a 100644 --- a/server/process.c +++ b/server/process.c @@ -1224,7 +1224,8 @@ DECL_HANDLER(new_process) * like if hConOut and hConIn are console handles, then they should be on the same * 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)) diff --git a/server/process.h b/server/process.h index fb29f21cb12..3944a67d571 100644 --- a/server/process.h +++ b/server/process.h @@ -131,8 +131,8 @@ extern void detach_debugged_processes( struct thread *debugger ); extern void enum_processes( int (*cb)(struct process*, void*), void *user); /* console functions */ -extern void inherit_console( struct thread *parent_thread, struct process *parent, - struct process *process, obj_handle_t hconin ); +extern obj_handle_t inherit_console( struct thread *parent_thread, struct process *parent, + struct process *process, obj_handle_t hconin ); extern int free_console( struct process *process ); extern struct thread *console_get_renderer( struct console_input *console );