[RESENT] MSVCRT: Use DuplicateHandle for CONOUT too
Eric Pouech
pouech-eric at wanadoo.fr
Sat May 28 03:46:59 CDT 2005
Uwe Bonnes a écrit :
>>>>>>"Eric" == Eric Pouech <pouech-eric at wanadoo.fr> writes:
>
>
> Eric> Uwe Bonnes a écrit :
> >> Changelog: dlls/msvcrt/console.c: msvcrt_init_console Use
> >> DuplicateHandle for STDOUT too ( CreateFileA("CONOUT$" failed) Bump
> >> up error reporting of missing console handles
>
> Eric> that's that's not a correct fix... this handles must be to the
> Eric> console itself, whatever the input / output handles are (from
> Eric> process inheritance) the issue you have is that you run your
> Eric> program without being attached to a (wine) console... you're
> Eric> facing the corner cases of running wine with the "fake" console as
> Eric> being inherited from the unix stdin/stdout streams the correct fix
> Eric> would be to let OpenConsoleW work in those cases A+ -- Eric Pouech
>
> Would it be right to first try to open the console and and on failure to use
> DuplicateHandle?
>
that would be a better fix IMO (you should also change the opening of CONIN$ in
msvcrt:msvcrt_init_console)
Index: console.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/dlls/kernel/console.c,v
retrieving revision 1.40
diff -u -u -r1.40 console.c
--- console.c 14 Apr 2005 11:30:10 -0000 1.40
+++ console.c 28 May 2005 08:45:36 -0000
@@ -212,7 +212,7 @@
static const WCHAR coninW[] = {'C','O','N','I','N','$',0};
static const WCHAR conoutW[] = {'C','O','N','O','U','T','$',0};
BOOL output;
- HANDLE ret;
+ HANDLE ret;
if (strcmpiW(coninW, name) == 0)
output = FALSE;
@@ -240,7 +240,27 @@
ret = reply->handle;
}
SERVER_END_REQ;
- return ret ? console_handle_map(ret) : INVALID_HANDLE_VALUE;
+ if (ret)
+ ret = console_handle_map(ret);
+ else
+ {
+ int fd;
+ DWORD attr;
+
+ /* likely, we're not attached to a windows-console
+ * let's try to return a handle to the unix-console
+ */
+ fd = open("/dev/tty", output ? O_WRONLY : O_RDONLY);
+ ret = INVALID_HANDLE_VALUE;
+ if (fd != -1)
+ {
+ attr = (output ? GENERIC_WRITE : GENERIC_READ) | SYNCHRONIZE;
+ if (wine_server_fd_to_handle(fd, attr, inherit, &ret))
+ ret = INVALID_HANDLE_VALUE;
+ close(fd);
+ }
+ }
+ return ret;
}
/******************************************************************
--
Eric Pouech
More information about the wine-devel
mailing list