Commit 1f478ea3 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

ntdll: Don't inherit std console handles for non CUI child process.

parent a7c5e241
......@@ -4986,7 +4986,6 @@ static void test_CreateProcessCUI(void)
DWORD cp_flags;
enum inheritance_model inherit;
DWORD expected;
BOOL is_todo;
DWORD is_broken;
}
no_console_tests[] =
......@@ -5021,12 +5020,12 @@ static void test_CreateProcessCUI(void)
/*10*/ {FALSE, DETACHED_PROCESS | CREATE_NO_WINDOW, CONSOLE_STD, 0},
{FALSE, CREATE_NEW_CONSOLE | CREATE_NO_WINDOW, CONSOLE_STD, 0},
{FALSE, 0, STARTUPINFO_STD, 0, TRUE},
{FALSE, DETACHED_PROCESS, STARTUPINFO_STD, 0, TRUE},
{FALSE, CREATE_NEW_CONSOLE, STARTUPINFO_STD, 0, TRUE},
/*15*/ {FALSE, CREATE_NO_WINDOW, STARTUPINFO_STD, 0, TRUE},
{FALSE, DETACHED_PROCESS | CREATE_NO_WINDOW, STARTUPINFO_STD, 0, TRUE},
{FALSE, CREATE_NEW_CONSOLE | CREATE_NO_WINDOW, STARTUPINFO_STD, 0, TRUE},
{FALSE, 0, STARTUPINFO_STD, 0},
{FALSE, DETACHED_PROCESS, STARTUPINFO_STD, 0},
{FALSE, CREATE_NEW_CONSOLE, STARTUPINFO_STD, 0},
/*15*/ {FALSE, CREATE_NO_WINDOW, STARTUPINFO_STD, 0},
{FALSE, DETACHED_PROCESS | CREATE_NO_WINDOW, STARTUPINFO_STD, 0},
{FALSE, CREATE_NEW_CONSOLE | CREATE_NO_WINDOW, STARTUPINFO_STD, 0},
{TRUE, 0, NULL_STD, CP_WITH_CONSOLE | CP_WITH_HANDLE | CP_WITH_WINDOW},
{TRUE, DETACHED_PROCESS, NULL_STD, 0},
......@@ -5058,7 +5057,6 @@ static void test_CreateProcessCUI(void)
BOOL noctrl_flag;
/* output */
DWORD expected;
BOOL is_todo;
}
group_flags_tests[] =
{
......@@ -5074,10 +5072,10 @@ static void test_CreateProcessCUI(void)
{FALSE, CREATE_NEW_PROCESS_GROUP, CONSOLE_STD, TRUE, CP_GROUP_LEADER},
/* 10 */ {FALSE, 0, CONSOLE_STD, FALSE, CP_ENABLED_CTRLC},
{FALSE, CREATE_NEW_PROCESS_GROUP, CONSOLE_STD, FALSE, CP_GROUP_LEADER},
{FALSE, 0, STARTUPINFO_STD, TRUE, 0, .is_todo = TRUE},
{FALSE, CREATE_NEW_PROCESS_GROUP, STARTUPINFO_STD, TRUE, CP_GROUP_LEADER, .is_todo = TRUE},
{FALSE, 0, STARTUPINFO_STD, FALSE, CP_ENABLED_CTRLC, .is_todo = TRUE},
/* 15 */ {FALSE, CREATE_NEW_PROCESS_GROUP, STARTUPINFO_STD, FALSE, CP_GROUP_LEADER, .is_todo = TRUE},
{FALSE, 0, STARTUPINFO_STD, TRUE, 0},
{FALSE, CREATE_NEW_PROCESS_GROUP, STARTUPINFO_STD, TRUE, CP_GROUP_LEADER},
{FALSE, 0, STARTUPINFO_STD, FALSE, CP_ENABLED_CTRLC},
/* 15 */ {FALSE, CREATE_NEW_PROCESS_GROUP, STARTUPINFO_STD, FALSE, CP_GROUP_LEADER},
{TRUE, CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE, CONSOLE_STD, TRUE, CP_INH_CONSOLE | CP_WITH_WINDOW | CP_GROUP_LEADER | CP_ALONE},
{FALSE, CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE, CONSOLE_STD, TRUE, CP_GROUP_LEADER},
{TRUE, CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE, CONSOLE_STD, FALSE, CP_INH_CONSOLE | CP_WITH_WINDOW | CP_GROUP_LEADER | CP_ALONE | CP_ENABLED_CTRLC},
......@@ -5107,7 +5105,6 @@ static void test_CreateProcessCUI(void)
res = check_child_console_bits(no_console_tests[i].use_cui ? cuiexec : guiexec,
no_console_tests[i].cp_flags,
no_console_tests[i].inherit);
todo_wine_if(no_console_tests[i].is_todo)
ok(res == no_console_tests[i].expected, "[%d] Unexpected result %x (%lx)\n",
i, res, no_console_tests[i].expected);
}
......@@ -5119,7 +5116,6 @@ static void test_CreateProcessCUI(void)
res = check_child_console_bits(with_console_tests[i].use_cui ? cuiexec : guiexec,
with_console_tests[i].cp_flags,
with_console_tests[i].inherit);
todo_wine_if(with_console_tests[i].is_todo)
ok(res == with_console_tests[i].expected ||
broken(with_console_tests[i].is_broken && res == (with_console_tests[i].is_broken & 0xff)),
"[%d] Unexpected result %x (%lx)\n",
......@@ -5135,7 +5131,6 @@ static void test_CreateProcessCUI(void)
res = check_child_console_bits(group_flags_tests[i].use_cui ? cuiexec : guiexec,
group_flags_tests[i].cp_flags,
group_flags_tests[i].inherit);
todo_wine_if(group_flags_tests[i].is_todo)
ok(res == group_flags_tests[i].expected ||
/* Win7 doesn't report group id */
broken(res == (group_flags_tests[i].expected & ~CP_GROUP_LEADER)),
......
......@@ -3269,8 +3269,8 @@ static void test_StdHandleInheritance(void)
{ARG_STD | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_PIPE, HATTR_TYPE | HATTR_INHERIT | FILE_TYPE_PIPE},
{ARG_STARTUPINFO | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CHAR, HATTR_TYPE | HATTR_INHERIT | FILE_TYPE_CHAR},
/* 5*/ {ARG_STD | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CHAR, HATTR_TYPE | HATTR_INHERIT | FILE_TYPE_CHAR},
{ARG_STARTUPINFO | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CONSOLE, HATTR_NULL, .is_todo = 7, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
{ARG_STD | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CONSOLE, HATTR_NULL, .is_todo = 1, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
{ARG_STARTUPINFO | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CONSOLE, HATTR_NULL, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
{ARG_STD | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CONSOLE, HATTR_NULL, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
/* all others handles type behave as H_DISK */
{ARG_STARTUPINFO | ARG_HANDLE_INHERIT | H_DISK, HATTR_NULL, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
......@@ -3287,7 +3287,7 @@ static void test_StdHandleInheritance(void)
detached_gui[] =
{
{ARG_STD | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CONSOLE, HATTR_NULL},
{ARG_STARTUPINFO | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CONSOLE, HATTR_NULL, .is_todo = 7, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
{ARG_STARTUPINFO | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_CONSOLE, HATTR_NULL, .is_broken = HATTR_TYPE | FILE_TYPE_UNKNOWN},
/* all others handles type behave as H_DISK */
{ARG_STD | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_DISK, HATTR_NULL},
{ARG_STARTUPINFO | ARG_CP_INHERIT | ARG_HANDLE_INHERIT | H_DISK, HATTR_TYPE | HATTR_INHERIT | FILE_TYPE_DISK},
......
......@@ -2139,6 +2139,16 @@ void init_startup_info(void)
}
/* helper for create_startup_info */
static BOOL is_console_handle( HANDLE handle )
{
IO_STATUS_BLOCK io;
DWORD mode;
return NtDeviceIoControlFile( handle, NULL, NULL, NULL, &io, IOCTL_CONDRV_GET_MODE, NULL, 0,
&mode, sizeof(mode) ) == STATUS_SUCCESS;
}
/***********************************************************************
* create_startup_info
*/
......@@ -2175,9 +2185,12 @@ void *create_startup_info( const UNICODE_STRING *nt_image, ULONG process_flags,
if ((process_flags & PROCESS_CREATE_FLAGS_INHERIT_HANDLES) ||
(pe_info->subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI && !(params->dwFlags & STARTF_USESTDHANDLES)))
{
info->hstdin = wine_server_obj_handle( params->hStdInput );
info->hstdout = wine_server_obj_handle( params->hStdOutput );
info->hstderr = wine_server_obj_handle( params->hStdError );
if (pe_info->subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI || !is_console_handle( params->hStdInput ))
info->hstdin = wine_server_obj_handle( params->hStdInput );
if (pe_info->subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI || !is_console_handle( params->hStdOutput ))
info->hstdout = wine_server_obj_handle( params->hStdOutput );
if (pe_info->subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI || !is_console_handle( params->hStdError ))
info->hstderr = wine_server_obj_handle( params->hStdError );
}
info->x = params->dwX;
info->y = params->dwY;
......
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