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 ) ...@@ -293,24 +293,23 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid )
RtlEnterCriticalSection( &console_section ); RtlEnterCriticalSection( &console_section );
SERVER_START_REQ( attach_console ) if (RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle)
{ {
req->pid = pid; RtlLeaveCriticalSection( &console_section );
ret = !wine_server_call_err( req ); 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)
{ {
if ((ret = init_console_std_handles())) RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle = create_console_reference( console_connection );
{ ret = RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle && 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();
} }
if (!ret) FreeConsole();
RtlLeaveCriticalSection( &console_section ); RtlLeaveCriticalSection( &console_section );
return ret; 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