CreateProcess regression

Eric Pouech pouech-eric at wanadoo.fr
Fri Aug 15 03:28:55 CDT 2003


as reported on wine-devel, there's a regression in CreateProcess while 
inheriting the standard I/O handles.
This patch should take care of it. It also gets rid of unneeded 
information in the server.

A+
-- 
Eric Pouech
-------------- next part --------------
Name:          cp_ioinh
ChangeLog:     fixed regression in process creation (std handle inheritance)
License:       X11
GenDate:       2003/08/15 08:15:40 UTC
ModifiedFiles: scheduler/process.c server/protocol.def server/console.c server/process.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/scheduler/process.c,v
retrieving revision 1.225
diff -u -u -r1.225 process.c
--- scheduler/process.c	3 Jul 2003 18:23:10 -0000	1.225
+++ scheduler/process.c	15 Aug 2003 07:02:38 -0000
@@ -341,6 +341,10 @@
     }
     else
     {
+        /* convert value from server:
+         * + 0 => INVALID_HANDLE_VALUE
+         * + console handle need to be mapped
+         */
         if (!process_pmts.hStdInput)
             process_pmts.hStdInput = INVALID_HANDLE_VALUE;
         else if (VerifyConsoleIoHandle(console_handle_map(process_pmts.hStdInput)))
@@ -944,7 +948,6 @@
 
         req->inherit_all  = inherit;
         req->create_flags = flags;
-        req->use_handles  = (startup->dwFlags & STARTF_USESTDHANDLES) != 0;
         req->unix_pid     = pid;
         req->exe_file     = hFile;
         if (startup->dwFlags & STARTF_USESTDHANDLES)
Index: server/protocol.def
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/protocol.def,v
retrieving revision 1.78
diff -u -u -r1.78 protocol.def
--- server/protocol.def	26 Jul 2003 20:36:43 -0000	1.78
+++ server/protocol.def	15 Aug 2003 06:59:53 -0000
@@ -204,7 +204,6 @@
 /* Create a new process from the context of the parent */
 @REQ(new_process)
     int          inherit_all;  /* inherit all handles from parent */
-    int          use_handles;  /* use stdio handles */
     int          create_flags; /* creation flags */
     int          unix_pid;     /* Unix pid of new process */
     obj_handle_t exe_file;     /* file handle for main exe */
Index: server/console.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/console.c,v
retrieving revision 1.51
diff -u -u -r1.51 console.c
--- server/console.c	23 Jun 2003 03:37:14 -0000	1.51
+++ server/console.c	15 Aug 2003 07:45:22 -0000
@@ -347,9 +347,11 @@
     {
 	struct console_input* console;
 
-        if ((console = (struct console_input*)get_handle_obj( parent, hconin, 0, NULL )))
+        /* FIXME: should we check some access rights ? */
+        if ((console = (struct console_input*)get_handle_obj( parent, hconin,
+                                                              0, &console_input_ops )))
 	{
-	    if (console->renderer == parent_thread)
+            if (console->renderer == parent_thread)
 	    {
 		process->console = (struct console_input*)grab_object( console );
 		process->console->num_proc++;
Index: server/process.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/server/process.c,v
retrieving revision 1.106
diff -u -u -r1.106 process.c
--- server/process.c	24 Jul 2003 00:07:00 -0000	1.106
+++ server/process.c	15 Aug 2003 07:44:38 -0000
@@ -83,7 +83,6 @@
     struct object       obj;          /* object header */
     struct list         entry;        /* entry in list of startup infos */
     int                 inherit_all;  /* inherit all handles from parent */
-    int                 use_handles;  /* use stdio handles */
     int                 create_flags; /* creation flags */
     int                 unix_pid;     /* Unix pid of new process */
     obj_handle_t        hstdin;       /* handle for stdin */
@@ -216,14 +215,25 @@
          * like if hConOut and hConIn are console handles, then they should be on the same
          * physical console
          */
-        inherit_console( parent_thread, process,
-                         (info->inherit_all || info->use_handles) ? info->hstdin : 0 );
+        inherit_console( parent_thread, process, info->inherit_all ? info->hstdin : 0 );
     }
     if (info)
     {
-        reply->hstdin  = info->hstdin;
-        reply->hstdout = info->hstdout;
-        reply->hstderr = info->hstderr;
+        if (!info->inherit_all)
+        {
+            reply->hstdin  = duplicate_handle( parent_thread->process, info->hstdin, process,
+                                               0, TRUE, DUPLICATE_SAME_ACCESS );
+            reply->hstdout = duplicate_handle( parent_thread->process, info->hstdout, process,
+                                               0, TRUE, DUPLICATE_SAME_ACCESS );
+            reply->hstderr = duplicate_handle( parent_thread->process, info->hstderr, process,
+                                               0, TRUE, DUPLICATE_SAME_ACCESS );
+        }
+        else
+        {
+            reply->hstdin  = info->hstdin;
+            reply->hstdout = info->hstdout;
+            reply->hstderr = info->hstderr;
+        }
     }
     else reply->hstdin = reply->hstdout = reply->hstderr = 0;
     /* some handles above may have been invalid; this is not an error */
@@ -870,7 +882,6 @@
     if (!(info = alloc_object( &startup_info_ops ))) return;
     list_add_head( &startup_info_list, &info->entry );
     info->inherit_all  = req->inherit_all;
-    info->use_handles  = req->use_handles;
     info->create_flags = req->create_flags;
     info->unix_pid     = req->unix_pid;
     info->hstdin       = req->hstdin;


More information about the wine-patches mailing list