Commit ca95afd3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

kernelbase: Use console connection object in AttachConsole.

parent d6565b08
......@@ -293,24 +293,23 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid )
RtlEnterCriticalSection( &console_section );
SERVER_START_REQ( attach_console )
if (RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle)
{
req->pid = pid;
ret = !wine_server_call_err( req );
RtlLeaveCriticalSection( &console_section );
WARN( "console already attached\n" );
SetLastError( ERROR_ACCESS_DENIED );
return FALSE;
}
SERVER_END_REQ;
ret = create_console_connection( NULL ) &&
console_ioctl( console_connection, IOCTL_CONDRV_BIND_PID, &pid, sizeof(pid), NULL, 0, NULL );
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();
RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle = create_console_reference( console_connection );
ret = RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle && init_console_std_handles();
}
if (!ret) FreeConsole();
RtlLeaveCriticalSection( &console_section );
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment