Visual studio 6 build fix.

Rein Klazes wijn at wanadoo.nl
Thu Dec 9 11:42:23 CST 2004


Hi,

MS Visual C++ v6, when invoking the compiler and other build tools does
the following:

 create anonymous pipe;
 duplicate the pipes write handle;
 open's the file NUL

 calls CreateProcess starting vcspawn.exe with:
    startup info iohandles set to the 3 handles obtained above;
    the startup info flag STARTF_USESTDHANDLES set;
    create flag CREATE_NEW_CONSOLE set.  

the parent process reads from the pipe, and analyses the compiler and
other messages that are obtained that way.

Wine's console startup code is not really expecting this and insists on
creating new stdio handles instead of inheriting them.

The attached patch makes this work properly.

Changelog:
	server	: process.c
	dlls/kernel	: console.c
	A starting process must obey the STARTF_USESTDHANDLES flag, even
	it is starting a new console.

Rein.
-- 
Rein Klazes
rklazes at xs4all.nl
-------------- next part --------------
--- wine/server/process.c	2004-06-15 07:41:59.000000000 +0200
+++ mywine/server/process.c	2004-12-09 17:34:45.000000000 +0100
@@ -45,6 +45,8 @@
 #include "request.h"
 #include "console.h"
 #include "user.h"
+#include "winreg.h"
+#include "winternl.h"
 
 /* process structure */
 
@@ -210,7 +212,12 @@ static int set_process_console( struct p
     if (process->create_flags & CREATE_NEW_CONSOLE)
     {
         /* let the process init do the allocation */
-        return 1;
+        /* unless the startup info specifies to use */
+        /* the io handles in the startup info */
+        if( !info || !info->data ||
+                !((((RTL_USER_PROCESS_PARAMETERS *)info->data)->dwFlags) &
+                    STARTF_USESTDHANDLES))
+            return 1;
     }
     else if (info && !(process->create_flags & DETACHED_PROCESS))
     {
--- wine/dlls/kernel/console.c	2004-09-15 09:51:46.000000000 +0200
+++ mywine/dlls/kernel/console.c	2004-12-07 21:30:26.000000000 +0100
@@ -1142,22 +1142,28 @@ BOOL WINAPI AllocConsole(void)
     if (!start_console_renderer(&siConsole))
 	goto the_end;
 
-    /* all std I/O handles are inheritable by default */
-    sa.nLength = sizeof(sa);
-    sa.lpSecurityDescriptor = NULL;
-    sa.bInheritHandle = TRUE;
-
-    handle_in = CreateFileA( "CONIN$", GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE,
-                             0, &sa, OPEN_EXISTING, 0, 0 );
-    if (handle_in == INVALID_HANDLE_VALUE) goto the_end;
-
-    handle_out = CreateFileA( "CONOUT$", GENERIC_READ|GENERIC_WRITE,
-                              0, &sa, OPEN_EXISTING, 0, 0 );
-    if (handle_out == INVALID_HANDLE_VALUE) goto the_end;
-
-    if (!DuplicateHandle(GetCurrentProcess(), handle_out, GetCurrentProcess(), &handle_err,
-			 0, TRUE, DUPLICATE_SAME_ACCESS))
-	goto the_end;
+    if( !(siCurrent.dwFlags & STARTF_USESTDHANDLES) ) {
+        /* all std I/O handles are inheritable by default */
+        sa.nLength = sizeof(sa);
+        sa.lpSecurityDescriptor = NULL;
+        sa.bInheritHandle = TRUE;
+  
+        handle_in = CreateFileA( "CONIN$", GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE,
+                0, &sa, OPEN_EXISTING, 0, 0 );
+        if (handle_in == INVALID_HANDLE_VALUE) goto the_end;
+  
+        handle_out = CreateFileA( "CONOUT$", GENERIC_READ|GENERIC_WRITE,
+                                  0, &sa, OPEN_EXISTING, 0, 0 );
+        if (handle_out == INVALID_HANDLE_VALUE) goto the_end;
+  
+        if (!DuplicateHandle(GetCurrentProcess(), handle_out, GetCurrentProcess(),
+                    &handle_err, 0, TRUE, DUPLICATE_SAME_ACCESS))
+            goto the_end;
+    } else {
+        handle_in =  siCurrent.hStdInput;
+        handle_out =  siCurrent.hStdOutput;
+        handle_err =  siCurrent.hStdError;
+    }
 
     /* NT resets the STD_*_HANDLEs on console alloc */
     SetStdHandle(STD_INPUT_HANDLE,  handle_in);


More information about the wine-devel mailing list