I get an error when running a windows console program on wine. It appears that in wine, GetStdHandle(STD_INPUT_HANDLE) doesn't return a handle to a console so GetConsoleMode() on that handle fails. The actual programs that fail are at: http://simh.trailing-edge.com/
Here is a simple patch to kernel32/tests/console.c to demonstrate the problem:
diff -p -u -r1.2 console.c --- dlls/kernel32/tests/console.c 10 Oct 2006 18:19:57 -0000 1.2 +++ dlls/kernel32/tests/console.c 20 Dec 2006 07:20:06 -0000 @@ -552,12 +552,31 @@ static void testCtrlHandler(void) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Bad error %u\n", GetLastError()); }
+static void test(void) +{ + HANDLE std_input; + DWORD saved_mode; + + std_input = GetStdHandle(STD_INPUT_HANDLE); + ok(std_input != INVALID_HANDLE_VALUE, + "GetStdHandle(STD_INPUT_HANDLE) returned INVALID_HANDLE_VALUE\n"); + + if (std_input != INVALID_HANDLE_VALUE) + { + BOOL status; + status = GetConsoleMode(std_input, &saved_mode); + ok(status != FALSE, "GetConsoleMode() failed: %08x\n", GetLastError()); + } +} + START_TEST(console) { HANDLE hConIn, hConOut; BOOL ret; CONSOLE_SCREEN_BUFFER_INFO sbi;
+ test(); + /* be sure we have a clean console (and that's our own) * FIXME: this will make the test fail (currently) if we don't run * under X11
if you move the test() call a couple of lines below, when the console is actually created, it should work. for the actual program to run, you should use wineconsole. A+
2006/12/20, Robert Reif reif@earthlink.net:
I get an error when running a windows console program on wine. It appears that in wine, GetStdHandle(STD_INPUT_HANDLE) doesn't return a handle to a console so GetConsoleMode() on that handle fails. The actual programs that fail are at: http://simh.trailing-edge.com/
Here is a simple patch to kernel32/tests/console.c to demonstrate the problem:
diff -p -u -r1.2 console.c --- dlls/kernel32/tests/console.c 10 Oct 2006 18:19:57 -0000 1.2 +++ dlls/kernel32/tests/console.c 20 Dec 2006 07:20:06 -0000 @@ -552,12 +552,31 @@ static void testCtrlHandler(void) ok(GetLastError() == ERROR_INVALID_PARAMETER, "Bad error %u\n", GetLastError()); }
+static void test(void) +{
- HANDLE std_input;
- DWORD saved_mode;
- std_input = GetStdHandle(STD_INPUT_HANDLE);
- ok(std_input != INVALID_HANDLE_VALUE,
"GetStdHandle(STD_INPUT_HANDLE) returned INVALID_HANDLE_VALUE\n");
- if (std_input != INVALID_HANDLE_VALUE)
- {
BOOL status;
status = GetConsoleMode(std_input, &saved_mode);
ok(status != FALSE, "GetConsoleMode() failed: %08x\n",
GetLastError());
- }
+}
START_TEST(console) { HANDLE hConIn, hConOut; BOOL ret; CONSOLE_SCREEN_BUFFER_INFO sbi;
- test();
- /* be sure we have a clean console (and that's our own)
- FIXME: this will make the test fail (currently) if we don't run
- under X11
Eric Pouech wrote:
if you move the test() call a couple of lines below, when the console is actually created, it should work. for the actual program to run, you should use wineconsole. A+
2006/12/20, Robert Reif <reif@earthlink.net mailto:reif@earthlink.net>:
I get an error when running a windows console program on wine. It appears that in wine, GetStdHandle(STD_INPUT_HANDLE) doesn't return a handle to a console so GetConsoleMode() on that handle fails. The actual programs that fail are at: http://simh.trailing-edge.com/
-- Eric Pouech
Would it be possible for wine to output a warning that this type of program must be run using wineconsole?
Robert Reif a écrit :
Eric Pouech wrote:
if you move the test() call a couple of lines below, when the console is actually created, it should work. for the actual program to run, you should use wineconsole. A+
2006/12/20, Robert Reif <reif@earthlink.net mailto:reif@earthlink.net>:
I get an error when running a windows console program on wine. It appears that in wine, GetStdHandle(STD_INPUT_HANDLE) doesn't
return a handle to a console so GetConsoleMode() on that handle fails. The actual programs that fail are at: http://simh.trailing-edge.com/
-- Eric Pouech
Would it be possible for wine to output a warning that this type of program must be run using wineconsole?
that may not be straightforward as lots of console APIs would require this kind of fix A+
Eric Pouech wrote:
if you move the test() call a couple of lines below, when the console is actually created, it should work. for the actual program to run, you should use wineconsole. A+
2006/12/20, Robert Reif <reif@earthlink.net mailto:reif@earthlink.net>:
I get an error when running a windows console program on wine. It appears that in wine, GetStdHandle(STD_INPUT_HANDLE) doesn't return a handle to a console so GetConsoleMode() on that handle fails. The actual programs that fail are at: http://simh.trailing-edge.com/
I just launched these .exes on xp in explorer and they created a console window.
Doing the same thing in wine using winefile produces the same failure as in wine. The program quits when GetConsoleMode fails. The programs do work using wineconsole.
Somehow windows knows to run these .exes in a console window but wine doesn't.
Robert Reif a écrit :
Eric Pouech wrote:
if you move the test() call a couple of lines below, when the console is actually created, it should work. for the actual program to run, you should use wineconsole. A+
2006/12/20, Robert Reif <reif@earthlink.net mailto:reif@earthlink.net>:
I get an error when running a windows console program on wine. It appears that in wine, GetStdHandle(STD_INPUT_HANDLE) doesn't
return a handle to a console so GetConsoleMode() on that handle fails. The actual programs that fail are at: http://simh.trailing-edge.com/
I just launched these .exes on xp in explorer and they created a console window.
Doing the same thing in wine using winefile produces the same failure as in wine. The program quits when GetConsoleMode fails. The programs do work using wineconsole.
Somehow windows knows to run these .exes in a console window but wine doesn't.
perhaps ShellExecute is supposed to create a console when calling CreateProcess for CUI subprocesses (this should be tested)
A+
On 21.12.2006 21:28, Eric Pouech wrote:
perhaps ShellExecute is supposed to create a console when calling CreateProcess for CUI subprocesses (this should be tested)
Or CreateProcess() itself creates the console window.
-f.r.