Commit eff83cd4 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

kernelbase: Provide a pseudo console environment for initial CUI processes not tied to a Unix tty.

parent 95202ea4
......@@ -86,6 +86,12 @@ static BOOL console_ioctl( HANDLE handle, DWORD code, void *in_buff, DWORD in_co
IO_STATUS_BLOCK io;
NTSTATUS status;
if (handle == CONSOLE_HANDLE_SHELL_NO_WINDOW)
{
WARN("Incorrect access to Shell-no-window console (ioctl=%lx)\n", code);
SetLastError( ERROR_INVALID_ACCESS );
return FALSE;
}
status = NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io, code, in_buff, in_count,
out_buff, out_count );
switch( status )
......@@ -621,10 +627,13 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
{
RtlEnterCriticalSection( &console_section );
if (RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != CONSOLE_HANDLE_SHELL_NO_WINDOW)
{
NtClose( console_connection );
console_connection = NULL;
NtClose( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle );
}
RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle = NULL;
if (console_flags & CONSOLE_INPUT_HANDLE) NtClose( GetStdHandle( STD_INPUT_HANDLE ));
......@@ -2303,5 +2312,6 @@ void init_console( void )
if (RtlImageNtHeader( mod )->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI)
alloc_console( no_window );
}
else if (params->ConsoleHandle) create_console_connection( params->ConsoleHandle );
else if (params->ConsoleHandle && params->ConsoleHandle != CONSOLE_HANDLE_SHELL_NO_WINDOW)
create_console_connection( params->ConsoleHandle );
}
......@@ -1354,6 +1354,8 @@ static void get_initial_console( RTL_USER_PROCESS_PARAMETERS *params )
params->hStdOutput = (HANDLE)((UINT_PTR)params->hStdOutput | 1);
output_fd = 1;
}
if (!params->ConsoleHandle && main_image_info.SubSystemType == IMAGE_SUBSYSTEM_WINDOWS_CUI)
params->ConsoleHandle = CONSOLE_HANDLE_SHELL_NO_WINDOW;
if (output_fd != -1)
{
......
......@@ -191,5 +191,6 @@ struct condrv_ctrl_event
#define CONSOLE_HANDLE_ALLOC LongToHandle(-1)
#define CONSOLE_HANDLE_ALLOC_NO_WINDOW LongToHandle(-2)
#define CONSOLE_HANDLE_SHELL LongToHandle(-3)
#define CONSOLE_HANDLE_SHELL_NO_WINDOW LongToHandle(-4)
#endif /* _INC_CONDRV */
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