Commit 1d65e474 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

kernelbase: Use PEB ConsoleHandle to check for console connection in AllocConsole.

parent 43ce4292
......@@ -150,6 +150,7 @@ static BOOL process_attach( HMODULE module )
if (params->ConsoleHandle == KERNEL32_CONSOLE_ALLOC)
{
HMODULE mod = GetModuleHandleA(0);
params->ConsoleHandle = NULL;
if (RtlImageNtHeader(mod)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
AllocConsole();
}
......
......@@ -275,20 +275,18 @@ BOOL WINAPI AllocConsole(void)
STARTUPINFOW app_si, console_si;
WCHAR buffer[1024], cmd[256];
PROCESS_INFORMATION pi;
HANDLE event, std_in, console;
DWORD mode;
HANDLE event, console;
BOOL ret;
TRACE("()\n");
RtlEnterCriticalSection( &console_section );
std_in = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 0, NULL, OPEN_EXISTING, 0, 0 );
if (GetConsoleMode( std_in, &mode ))
if (RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle)
{
/* we already have a console opened on this process, don't create a new one */
CloseHandle( std_in );
RtlLeaveCriticalSection( &console_section );
SetLastError( ERROR_ACCESS_DENIED );
return FALSE;
}
......
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