Jacek Caban : server: Pass console handle to the child process.

Alexandre Julliard julliard at winehq.org
Thu Aug 13 15:11:52 CDT 2020


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Aug 13 16:01:08 2020 +0200

server: Pass console handle to the child process.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/console.c | 1 -
 server/console.c              | 8 ++++++--
 server/process.c              | 3 ++-
 server/process.h              | 4 ++--
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index d66a2af668..2b70c2ffc4 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -3724,7 +3724,6 @@ static void test_AttachConsole_child(DWORD console_pid)
     ok(!res && GetLastError() == ERROR_ACCESS_DENIED,
        "AttachConsole returned: %x(%u)\n", res, GetLastError());
 
-    todo_wine
     ok(RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle != NULL, "ConsoleHandle is NULL\n");
     res = FreeConsole();
     ok(res, "FreeConsole failed: %u\n", GetLastError());
diff --git a/server/console.c b/server/console.c
index 53910b3f46..890ea609c2 100644
--- a/server/console.c
+++ b/server/console.c
@@ -620,8 +620,8 @@ int free_console( struct process *process )
  *	2/ parent is a renderer which launches process, and process should attach to the console
  *	   rendered by parent
  */
-void inherit_console( struct thread *parent_thread, struct process *parent, struct process *process,
-                      obj_handle_t hconin )
+obj_handle_t inherit_console( struct thread *parent_thread, struct process *parent, struct process *process,
+                              obj_handle_t hconin )
 {
     int done = 0;
 
@@ -652,6 +652,10 @@ void inherit_console( struct thread *parent_thread, struct process *parent, stru
         process->console = (struct console_input *)grab_object( parent->console );
         process->console->num_proc++;
     }
+
+    if (!process->console) return 0;
+    return alloc_handle( process, process->console,
+                         SYNCHRONIZE | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, 0 );
 }
 
 struct thread *console_get_renderer( struct console_input *console )
diff --git a/server/process.c b/server/process.c
index 5e587b28cb..61ba1549e9 100644
--- a/server/process.c
+++ b/server/process.c
@@ -1224,7 +1224,8 @@ DECL_HANDLER(new_process)
          * like if hConOut and hConIn are console handles, then they should be on the same
          * physical console
          */
-        inherit_console( parent_thread, parent, process, req->inherit_all ? info->data->hstdin : 0 );
+        info->data->console = inherit_console( parent_thread, parent,
+                                               process, req->inherit_all ? info->data->hstdin : 0 );
     }
 
     if (!req->inherit_all && !(req->create_flags & CREATE_NEW_CONSOLE))
diff --git a/server/process.h b/server/process.h
index fb29f21cb1..3944a67d57 100644
--- a/server/process.h
+++ b/server/process.h
@@ -131,8 +131,8 @@ extern void detach_debugged_processes( struct thread *debugger );
 extern void enum_processes( int (*cb)(struct process*, void*), void *user);
 
 /* console functions */
-extern void inherit_console( struct thread *parent_thread, struct process *parent,
-                             struct process *process, obj_handle_t hconin );
+extern obj_handle_t inherit_console( struct thread *parent_thread, struct process *parent,
+                                     struct process *process, obj_handle_t hconin );
 extern int free_console( struct process *process );
 extern struct thread *console_get_renderer( struct console_input *console );
 




More information about the wine-cvs mailing list