kernel32: Use IOCTL_CONDRV_GET_INPUT_INFO in GetConsoleWindow.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2020-08-14 13:27:20 +02:00 committed by Alexandre Julliard
parent 7444aa4230
commit 36fc962f5c
2 changed files with 12 additions and 10 deletions

View File

@ -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;
struct condrv_input_info info;
BOOL ret;
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;
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;
}

View File

@ -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 );