[PATCH] GetConsoleWindow() implementation

tim tim at krasnogorsk.ru
Sat Feb 19 20:56:42 CST 2005


This implements GetConsoleWindow() function, which is required for Far Manager 
(www.farmanager.com) to work. Tested against the latest version of Far Manager 
and wine.

Changelog entry:
        * dlls/kernel/console.c:
        Georgy Yunaev <tim at krasnogorsk.ru>
        - Implement GetConsoleWindow().

The patch:
--- wine-20050211/dlls/kernel/console.c 2004-12-23 21:48:47.000000000 +0300
+++ wine-20050211-mod/dlls/kernel/console.c     2005-02-20 05:53:04.224968648 
+0300
@@ -26,6 +26,7 @@
 /* Reference applications:
  * -  IDA (interactive disassembler) full version 3.75. Works.
  * -  LYNX/W32. Works mostly, some keys crash it.
+ * -  Far Manager. Partially works, need to fix UTF8 console output.
  */

 #include "config.h"
@@ -120,10 +121,38 @@

 /******************************************************************************
  * GetConsoleWindow [KERNEL32.@]
+ *
+ * RETURNS
+ *    Handle of the console window
  */
 HWND WINAPI GetConsoleWindow(VOID)
 {
-    FIXME("stub\n");
+    HANDLE             handle = INVALID_HANDLE_VALUE;
+
+    TRACE("()");
+
+    /*
+     * Under Windows, a console program usually allocates
+     * its console when program is loaded. It is not the Wine
+     * case; Wine assumes that the console should always be
+     * allocate by AllocConsole(), which is not Win2k/XP case.
+     * To workaround this, we create a console on this call,
+     * and return its handle.
+     *
+     * AllocConsole() won't open a console if there is an
+     * existing one, but it will create a new console if
+     * there is no one. So it is safe to call it this way.
+     */
+    AllocConsole();
+
+    handle = CreateFileA( "CONIN$", GENERIC_READ|
+                             GENERIC_WRITE|SYNCHRONIZE,
+                            0, NULL, OPEN_EXISTING, 0, 0 );
+
+    if (handle != INVALID_HANDLE_VALUE)
+       return handle;
+
+    ERR ("Could not get console window handle!");
     return NULL;
 }


-------------------
With best regards, Tim.
http://libircclient.sourceforge.net - create your own IRC bot!



More information about the wine-patches mailing list