kernelbase: Use IOCTL_CONDRV_GET_TITLE in GetConsoleTitleW.

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:10 +02:00 committed by Alexandre Julliard
parent 3576258402
commit 7444aa4230
2 changed files with 17 additions and 13 deletions

View File

@ -3589,7 +3589,9 @@ static void test_GetConsoleScreenBufferInfoEx(HANDLE std_output)
static void test_FreeConsole(void)
{
WCHAR title[16];
HANDLE handle;
DWORD size;
UINT cp;
BOOL ret;
@ -3637,6 +3639,13 @@ static void test_FreeConsole(void)
ok(!cp, "cp = %x\n", cp);
ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %u\n", GetLastError());
SetLastError(0xdeadbeef);
memset( title, 0xc0, sizeof(title) );
size = GetConsoleTitleW( title, ARRAY_SIZE(title) );
ok(!size, "GetConsoleTitleW returned %u\n", size);
ok(title[0] == 0xc0c0, "title byffer changed\n");
ok(GetLastError() == ERROR_INVALID_HANDLE, "last error %u\n", GetLastError());
if (!skip_nt)
{
SetStdHandle( STD_INPUT_HANDLE, (HANDLE)0xdeadbeef );

View File

@ -739,20 +739,15 @@ BOOL WINAPI DECLSPEC_HOTPATCH GetConsoleScreenBufferInfoEx( HANDLE handle,
*/
DWORD WINAPI DECLSPEC_HOTPATCH GetConsoleTitleW( LPWSTR title, DWORD size )
{
DWORD ret = 0;
if (!size) return 0;
SERVER_START_REQ( get_console_input_info )
{
req->handle = 0;
wine_server_set_reply( req, title, (size - 1) * sizeof(WCHAR) );
if (!wine_server_call_err( req ))
{
ret = wine_server_reply_size(reply) / sizeof(WCHAR);
title[ret] = 0;
}
}
SERVER_END_REQ;
return ret;
if (!console_ioctl( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, IOCTL_CONDRV_GET_TITLE,
NULL, 0, title, (size - 1) * sizeof(WCHAR), &size ))
return 0;
size /= sizeof(WCHAR);
title[size] = 0;
return size + 1;
}