Eric Pouech : kernelbase: Handle corner case in CreateProcess.

Alexandre Julliard julliard at winehq.org
Thu Mar 17 17:18:31 CDT 2022


Module: wine
Branch: master
Commit: f034084d49b354811096524d472ae5172ac1cebf
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=f034084d49b354811096524d472ae5172ac1cebf

Author: Eric Pouech <eric.pouech at gmail.com>
Date:   Thu Mar 17 08:27:28 2022 +0100

kernelbase: Handle corner case in CreateProcess.

In CreateProcess, if:
- parent isn't attached to a console
- CreateProcess's flag isn't set with DETACHED_PROCESS nor
  CREATE_NEW_CONSOLE
- child is a CUI program
then a console must be allocated for the child.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52048
Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/console.c | 2 +-
 dlls/kernelbase/process.c     | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 3622687c6a4..98692760acf 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -4735,7 +4735,7 @@ static void test_CreateProcessCUI(void)
     res = check_whether_child_attached(cuiexec, DETACHED_PROCESS);
     ok(!res, "Don't expecting child to be attached to a console\n");
     res = check_whether_child_attached(cuiexec, 0);
-    todo_wine ok(res, "Expecting child to be attached to a console\n");
+    ok(res, "Expecting child to be attached to a console\n");
 
     DeleteFileA(guiexec);
     DeleteFileA(cuiexec);
diff --git a/dlls/kernelbase/process.c b/dlls/kernelbase/process.c
index 35381f409e9..1cecbce9321 100644
--- a/dlls/kernelbase/process.c
+++ b/dlls/kernelbase/process.c
@@ -191,7 +191,11 @@ static RTL_USER_PROCESS_PARAMETERS *create_process_params( const WCHAR *filename
 
     if (flags & CREATE_NEW_PROCESS_GROUP) params->ConsoleFlags = 1;
     if (flags & CREATE_NEW_CONSOLE) params->ConsoleHandle = CONSOLE_HANDLE_ALLOC;
-    else if (!(flags & DETACHED_PROCESS)) params->ConsoleHandle = NtCurrentTeb()->Peb->ProcessParameters->ConsoleHandle;
+    else if (!(flags & DETACHED_PROCESS))
+    {
+        params->ConsoleHandle = NtCurrentTeb()->Peb->ProcessParameters->ConsoleHandle;
+        if (!params->ConsoleHandle) params->ConsoleHandle = CONSOLE_HANDLE_ALLOC;
+    }
 
     if (startup->dwFlags & STARTF_USESTDHANDLES)
     {




More information about the wine-cvs mailing list