kernelbase: Close PEB ConsoleHandle in AttachConsole.

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:00:50 +02:00 committed by Alexandre Julliard
parent 57a222356c
commit 06c3e7e44c
2 changed files with 10 additions and 2 deletions

View File

@ -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);

View File

@ -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;