Jacek Caban : kernel32: Use IOCTL_CONDRV_GET_INPUT_INFO in GetConsoleWindow.

Alexandre Julliard julliard at winehq.org
Fri Aug 14 16:39:32 CDT 2020


Module: wine
Branch: master
Commit: 36fc962f5c0f2fd33cfd09c816017655104c4201
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=36fc962f5c0f2fd33cfd09c816017655104c4201

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Aug 14 13:27:20 2020 +0200

kernel32: Use IOCTL_CONDRV_GET_INPUT_INFO in GetConsoleWindow.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/console.c       | 16 ++++++----------
 dlls/kernel32/tests/console.c |  6 ++++++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index c38fa5d0c2..032f938a12 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -187,18 +187,14 @@ static BOOL restore_console_mode(HANDLE hin)
  *   Success: hwnd of the console window.
  *   Failure: NULL
  */
-HWND WINAPI GetConsoleWindow(VOID)
+HWND WINAPI GetConsoleWindow(void)
 {
-    HWND hWnd = NULL;
-
-    SERVER_START_REQ(get_console_input_info)
-    {
-        req->handle = 0;
-        if (!wine_server_call_err(req)) hWnd = wine_server_ptr_handle( reply->win );
-    }
-    SERVER_END_REQ;
+    struct condrv_input_info info;
+    BOOL ret;
 
-    return hWnd;
+    ret = DeviceIoControl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle,
+                           IOCTL_CONDRV_GET_INPUT_INFO, NULL, 0, &info, sizeof(info), NULL, NULL );
+    return ret ? (HWND)info.win : NULL;
 }
 
 
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 1fc23992ba..1702369d7a 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -3592,6 +3592,7 @@ static void test_FreeConsole(void)
     WCHAR title[16];
     HANDLE handle;
     DWORD size;
+    HWND hwnd;
     UINT cp;
     BOOL ret;
 
@@ -3646,6 +3647,11 @@ static void test_FreeConsole(void)
     ok(title[0] == 0xc0c0, "title byffer changed\n");
     ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %u\n", GetLastError());
 
+    SetLastError(0xdeadbeef);
+    hwnd = GetConsoleWindow();
+    ok(!hwnd, "hwnd = %p\n", hwnd);
+    ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %u\n", GetLastError());
+
     if (!skip_nt)
     {
         SetStdHandle( STD_INPUT_HANDLE, (HANDLE)0xdeadbeef );




More information about the wine-cvs mailing list