diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 01c2361396f..d66a2af6684 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -3737,7 +3737,6 @@ static void test_AttachConsole_child(DWORD console_pid) ok(res, "AttachConsole failed: %u\n", GetLastError()); ok(pipe_out != GetStdHandle(STD_ERROR_HANDLE), "std handle not set to console\n"); - todo_wine ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n"); console = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0); diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index 7b84fc8f735..c7513601f88 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -250,7 +250,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid ) } SERVER_END_REQ; - if (ret && !(ret = init_console_std_handles())) FreeConsole(); + if (ret) + { + if ((ret = init_console_std_handles())) + { + HANDLE console = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 0, NULL, OPEN_EXISTING, 0, 0 ); + if (console != INVALID_HANDLE_VALUE) RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle = console; + else ret = FALSE; + } + if (!ret) FreeConsole(); + } RtlLeaveCriticalSection( &console_section ); return ret;