Added patch to properly implement GetLargestConsoleWindowSize.

This commit is contained in:
Sebastian Lackner 2015-12-05 19:38:43 +01:00
parent 07a42a496d
commit ce6a5b015d
10 changed files with 386 additions and 1 deletions

View File

@ -34,9 +34,10 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
-----------------------------------
**Bug fixes and features included in the next upcoming release [2]:**
**Bug fixes and features included in the next upcoming release [3]:**
* Fix possible leak of explorer.exe processes and implement proper desktop refcounting
* Properly implement GetLargestConsoleWindowSize ([Wine Bug #10919](https://bugs.winehq.org/show_bug.cgi?id=10919))
* Set LastError to 0 in GetSidIdentifierAuthority

View File

@ -0,0 +1,54 @@
From 621d31b627bd14ab424e20f76c9dc2d786e5ec9e Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Fri, 4 Dec 2015 15:47:42 +1100
Subject: wineconsole: Send the largest console window size information to the
server
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
programs/wineconsole/wineconsole.c | 6 +++++-
server/console.c | 7 -------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c
index 7a89eeb..729416f 100644
--- a/programs/wineconsole/wineconsole.c
+++ b/programs/wineconsole/wineconsole.c
@@ -424,11 +424,15 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf
if (strcmpiW(data->curcfg.face_name, cfg->face_name) || data->curcfg.cell_width != cfg->cell_width ||
data->curcfg.cell_height != cfg->cell_height || data->curcfg.font_weight != cfg->font_weight)
{
+ RECT r;
data->fnSetFont(data, cfg->face_name, cfg->cell_height, cfg->font_weight);
+ SystemParametersInfoW(SPI_GETWORKAREA, 0, &r, 0);
SERVER_START_REQ(set_console_output_info)
{
req->handle = wine_server_obj_handle( data->hConOut );
- req->mask = SET_CONSOLE_OUTPUT_INFO_FONT;
+ req->mask = SET_CONSOLE_OUTPUT_INFO_MAX_SIZE | SET_CONSOLE_OUTPUT_INFO_FONT;
+ req->max_width = (r.right - r.left) / cfg->cell_width;
+ req->max_height = (r.bottom - r.top - GetSystemMetrics(SM_CYCAPTION)) / cfg->cell_height;
req->font_width = cfg->cell_width;
req->font_height = cfg->cell_height;
wine_server_call( req );
diff --git a/server/console.c b/server/console.c
index a57b2fe..9b01614 100644
--- a/server/console.c
+++ b/server/console.c
@@ -1018,13 +1018,6 @@ static int set_console_output_info( struct screen_buffer *screen_buffer,
}
if (req->mask & SET_CONSOLE_OUTPUT_INFO_MAX_SIZE)
{
- /* can only be done by renderer */
- if (current->process->console != screen_buffer->input)
- {
- set_error( STATUS_INVALID_PARAMETER );
- return 0;
- }
-
screen_buffer->max_width = req->max_width;
screen_buffer->max_height = req->max_height;
}
--
2.6.2

View File

@ -0,0 +1,65 @@
From 56d5cc64d9047dc5f9866ff2542eb0f07f9ad75d Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Fri, 4 Dec 2015 15:48:12 +1100
Subject: kernel32: Implement GetLargestConsoleWindowSize
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
dlls/kernel32/console.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 51d6e60..f48bca7 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -1360,6 +1360,22 @@ DWORD WINAPI GetConsoleTitleW(LPWSTR title, DWORD size)
return ret;
}
+static COORD get_largest_console_window_size(HANDLE hConsole)
+{
+ COORD c = {0,0};
+
+ SERVER_START_REQ(get_console_output_info)
+ {
+ req->handle = console_handle_unmap(hConsole);
+ if (!wine_server_call_err(req))
+ {
+ c.X = reply->max_width;
+ c.Y = reply->max_height;
+ }
+ }
+ SERVER_END_REQ;
+ return c;
+}
/***********************************************************************
* GetLargestConsoleWindowSize (KERNEL32.@)
@@ -1378,8 +1394,7 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
COORD c;
DWORD w;
} x;
- x.c.X = 80;
- x.c.Y = 24;
+ x.c = get_largest_console_window_size(hConsoleOutput);
TRACE("(%p), returning %dx%d (%x)\n", hConsoleOutput, x.c.X, x.c.Y, x.w);
return x.w;
}
@@ -1399,12 +1414,11 @@ DWORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
COORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
{
COORD c;
- c.X = 80;
- c.Y = 24;
+ c = get_largest_console_window_size(hConsoleOutput);
TRACE("(%p), returning %dx%d\n", hConsoleOutput, c.X, c.Y);
return c;
}
-#endif /* defined(__i386__) */
+#endif /* !defined(__i386__) */
static WCHAR* S_EditString /* = NULL */;
static unsigned S_EditStrPos /* = 0 */;
--
2.6.2

View File

@ -0,0 +1,44 @@
From 0042b3a28cc7fbe462850eb600df0424a8dfb1e5 Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Fri, 4 Dec 2015 16:00:27 +1100
Subject: kernel32: Add a stub for SetConsoleFont
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
dlls/kernel32/console.c | 6 ++++++
dlls/kernel32/kernel32.spec | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index f48bca7..3c53b52 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -3256,6 +3256,12 @@ DWORD WINAPI GetNumberOfConsoleFonts(void)
return 1;
}
+BOOL WINAPI SetConsoleFont(HANDLE hConsole, DWORD index)
+{
+ FIXME("(%p, %u): stub!\n", hConsole, index);
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+ return FALSE;
+}
BOOL WINAPI SetConsoleKeyShortcuts(BOOL set, BYTE keys, VOID *a, DWORD b)
{
diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec
index ff67e54..d10e6bb 100644
--- a/dlls/kernel32/kernel32.spec
+++ b/dlls/kernel32/kernel32.spec
@@ -1345,7 +1345,7 @@
@ stub SetConsoleCursorMode
@ stdcall SetConsoleCursorPosition(long long)
@ stdcall SetConsoleDisplayMode(long long ptr)
-@ stub SetConsoleFont
+@ stdcall SetConsoleFont(long long)
@ stub SetConsoleHardwareState
@ stdcall SetConsoleIcon(ptr)
@ stdcall SetConsoleInputExeNameA(ptr)
--
2.6.2

View File

@ -0,0 +1,38 @@
From 3935a3728751863c959f1f45e8e1866ed98c3ce4 Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Fri, 4 Dec 2015 16:02:38 +1100
Subject: kernel32/tests: Refresh the console to clear the console font table
The testScreenBuffer function unintentionally causes the console
font table to duplicate. This patch clears the font table.
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
dlls/kernel32/tests/console.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 240d9d8..3ba1da5 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -2787,6 +2787,17 @@ START_TEST(console)
testScroll(hConOut, sbi.dwSize);
/* will test sb creation / modification / codepage handling */
testScreenBuffer(hConOut);
+
+ /* clear duplicated console font table */
+ CloseHandle(hConIn);
+ CloseHandle(hConOut);
+ FreeConsole();
+ ok(AllocConsole(), "Couldn't alloc console\n");
+ hConIn = CreateFileA("CONIN$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
+ hConOut = CreateFileA("CONOUT$", GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0);
+ ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n");
+ ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n");
+
testCtrlHandler();
/* still to be done: access rights & access on objects */
--
2.6.2

View File

@ -0,0 +1,93 @@
From cea4e680a6e23edcbbba8d0457834ee15c2f7c3a Mon Sep 17 00:00:00 2001
From: Hugh McMaster <hugh.mcmaster@outlook.com>
Date: Fri, 4 Dec 2015 16:07:24 +1100
Subject: kernel32/tests: Add tests for GetLargestConsoleWindowSize
Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
---
dlls/kernel32/tests/console.c | 64 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 64 insertions(+)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 3ba1da5..f362415 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -2681,6 +2681,69 @@ static void test_GetConsoleFontSize(HANDLE std_output)
ok(!c.Y, "got %d, expected 0\n", c.Y);
}
+static void test_GetLargestConsoleWindowSize(HANDLE std_output)
+{
+ COORD c, font;
+ RECT r;
+ LONG workarea_w, workarea_h, maxcon_w, maxcon_h;
+ CONSOLE_FONT_INFO cfi;
+ DWORD index, i;
+ HMODULE hmod;
+ DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
+ BOOL (WINAPI *pSetConsoleFont)(HANDLE, DWORD);
+
+ memset(&c, 10, sizeof(COORD));
+ SetLastError(0xdeadbeef);
+ c = GetLargestConsoleWindowSize(NULL);
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+ ok(!c.X, "got %d, expected 0\n", c.X);
+ ok(!c.Y, "got %d, expected 0\n", c.Y);
+
+ memset(&c, 10, sizeof(COORD));
+ SetLastError(0xdeadbeef);
+ c = GetLargestConsoleWindowSize(GetStdHandle(STD_INPUT_HANDLE));
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "got %u, expected 6\n", GetLastError());
+ ok(!c.X, "got %d, expected 0\n", c.X);
+ ok(!c.Y, "got %d, expected 0\n", c.Y);
+
+ SystemParametersInfoW(SPI_GETWORKAREA, 0, &r, 0);
+ workarea_w = r.right - r.left;
+ workarea_h = r.bottom - r.top - GetSystemMetrics(SM_CYCAPTION);
+
+ GetCurrentConsoleFont(std_output, FALSE, &cfi);
+ index = cfi.nFont; /* save current font index */
+
+ hmod = GetModuleHandleA("kernel32.dll");
+ pGetNumberOfConsoleFonts = (void *)GetProcAddress(hmod, "GetNumberOfConsoleFonts");
+ if (!pGetNumberOfConsoleFonts)
+ {
+ win_skip("GetNumberOfConsoleFonts is not available\n");
+ return;
+ }
+ pSetConsoleFont = (void *)GetProcAddress(hmod, "SetConsoleFont");
+ if (!pSetConsoleFont)
+ {
+ win_skip("SetConsoleFont is not available\n");
+ return;
+ }
+
+ for (i = 0; i < pGetNumberOfConsoleFonts(); i++)
+ {
+ pSetConsoleFont(std_output, i);
+ memset(&c, 10, sizeof(COORD));
+ SetLastError(0xdeadbeef);
+ c = GetLargestConsoleWindowSize(std_output);
+ ok(GetLastError() == 0xdeadbeef, "got %u, expected 0xdeadbeef\n", GetLastError());
+ GetCurrentConsoleFont(std_output, FALSE, &cfi);
+ font = GetConsoleFontSize(std_output, cfi.nFont);
+ maxcon_w = workarea_w / font.X;
+ maxcon_h = workarea_h / font.Y;
+ ok(c.X == maxcon_w || c.X == maxcon_w - 1 /* Win10 */, "got %d, expected %d\n", c.X, maxcon_w);
+ ok(c.Y == maxcon_h || c.Y == maxcon_h - 1 /* Win10 */, "got %d, expected %d\n", c.Y, maxcon_h);
+ }
+ pSetConsoleFont(std_output, index); /* restore original font size */
+}
+
START_TEST(console)
{
static const char font_name[] = "Lucida Console";
@@ -2826,4 +2889,5 @@ START_TEST(console)
test_ReadConsoleOutputAttribute(hConOut);
test_GetCurrentConsoleFont(hConOut);
test_GetConsoleFontSize(hConOut);
+ test_GetLargestConsoleWindowSize(hConOut);
}
--
2.6.2

View File

@ -0,0 +1,58 @@
From d3a6fb5dc0a0494627c0980ca8d5e5ee89df4fbc Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 5 Dec 2015 19:36:20 +0100
Subject: kernel32: Clamp maximum window size to screen buffer size.
---
dlls/kernel32/console.c | 4 ++--
dlls/kernel32/tests/console.c | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 3c53b52..85e4ba8 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -2160,8 +2160,8 @@ BOOL WINAPI GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, LPCONSOLE_SCREEN_B
csbi->srWindow.Right = reply->win_right;
csbi->srWindow.Top = reply->win_top;
csbi->srWindow.Bottom = reply->win_bottom;
- csbi->dwMaximumWindowSize.X = reply->max_width;
- csbi->dwMaximumWindowSize.Y = reply->max_height;
+ csbi->dwMaximumWindowSize.X = min(reply->width, reply->max_width);
+ csbi->dwMaximumWindowSize.Y = min(reply->height, reply->max_height);
}
}
SERVER_END_REQ;
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index f362415..43a4b75 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -2686,9 +2686,11 @@ static void test_GetLargestConsoleWindowSize(HANDLE std_output)
COORD c, font;
RECT r;
LONG workarea_w, workarea_h, maxcon_w, maxcon_h;
+ CONSOLE_SCREEN_BUFFER_INFO sbi;
CONSOLE_FONT_INFO cfi;
DWORD index, i;
HMODULE hmod;
+ BOOL ret;
DWORD (WINAPI *pGetNumberOfConsoleFonts)(void);
BOOL (WINAPI *pSetConsoleFont)(HANDLE, DWORD);
@@ -2740,6 +2742,13 @@ static void test_GetLargestConsoleWindowSize(HANDLE std_output)
maxcon_h = workarea_h / font.Y;
ok(c.X == maxcon_w || c.X == maxcon_w - 1 /* Win10 */, "got %d, expected %d\n", c.X, maxcon_w);
ok(c.Y == maxcon_h || c.Y == maxcon_h - 1 /* Win10 */, "got %d, expected %d\n", c.Y, maxcon_h);
+
+ ret = GetConsoleScreenBufferInfo(std_output, &sbi);
+ ok(ret, "GetConsoleScreenBufferInfo failed %u\n", GetLastError());
+ ok(sbi.dwMaximumWindowSize.X == min(c.X, sbi.dwSize.X), "got %d, expected %d\n",
+ sbi.dwMaximumWindowSize.X, min(c.X, sbi.dwSize.X));
+ ok(sbi.dwMaximumWindowSize.Y == min(c.Y, sbi.dwSize.Y), "got %d, expected %d\n",
+ sbi.dwMaximumWindowSize.Y, min(c.Y, sbi.dwSize.Y));
}
pSetConsoleFont(std_output, index); /* restore original font size */
}
--
2.6.2

View File

@ -0,0 +1 @@
Fixes: [10919] Properly implement GetLargestConsoleWindowSize

View File

@ -158,6 +158,7 @@ patch_enable_all ()
enable_kernel32_Cwd_Startup_Info="$1"
enable_kernel32_FreeUserPhysicalPages="$1"
enable_kernel32_GetFinalPathNameByHandle="$1"
enable_kernel32_GetLargestConsoleWindowSize="$1"
enable_kernel32_GetLogicalProcessorInformationEx="$1"
enable_kernel32_LocaleNameToLCID="$1"
enable_kernel32_Named_Pipe="$1"
@ -586,6 +587,9 @@ patch_enable ()
kernel32-GetFinalPathNameByHandle)
enable_kernel32_GetFinalPathNameByHandle="$2"
;;
kernel32-GetLargestConsoleWindowSize)
enable_kernel32_GetLargestConsoleWindowSize="$2"
;;
kernel32-GetLogicalProcessorInformationEx)
enable_kernel32_GetLogicalProcessorInformationEx="$2"
;;
@ -3510,6 +3514,32 @@ if test "$enable_kernel32_GetFinalPathNameByHandle" -eq 1; then
) >> "$patchlist"
fi
# Patchset kernel32-GetLargestConsoleWindowSize
# |
# | This patchset fixes the following Wine bugs:
# | * [#10919] Properly implement GetLargestConsoleWindowSize
# |
# | Modified files:
# | * dlls/kernel32/console.c, dlls/kernel32/kernel32.spec, dlls/kernel32/tests/console.c, programs/wineconsole/wineconsole.c,
# | server/console.c
# |
if test "$enable_kernel32_GetLargestConsoleWindowSize" -eq 1; then
patch_apply kernel32-GetLargestConsoleWindowSize/0001-wineconsole-Send-the-largest-console-window-size-inf.patch
patch_apply kernel32-GetLargestConsoleWindowSize/0002-kernel32-Implement-GetLargestConsoleWindowSize.patch
patch_apply kernel32-GetLargestConsoleWindowSize/0003-kernel32-Add-a-stub-for-SetConsoleFont.patch
patch_apply kernel32-GetLargestConsoleWindowSize/0004-kernel32-tests-Refresh-the-console-to-clear-the-cons.patch
patch_apply kernel32-GetLargestConsoleWindowSize/0005-kernel32-tests-Add-tests-for-GetLargestConsoleWindow.patch
patch_apply kernel32-GetLargestConsoleWindowSize/0006-kernel32-Clamp-maximum-window-size-to-screen-buffer-.patch
(
echo '+ { "Hugh McMaster", "wineconsole: Send the largest console window size information to the server.", 1 },';
echo '+ { "Hugh McMaster", "kernel32: Implement GetLargestConsoleWindowSize.", 1 },';
echo '+ { "Hugh McMaster", "kernel32: Add a stub for SetConsoleFont.", 1 },';
echo '+ { "Hugh McMaster", "kernel32/tests: Refresh the console to clear the console font table.", 1 },';
echo '+ { "Hugh McMaster", "kernel32/tests: Add tests for GetLargestConsoleWindowSize.", 1 },';
echo '+ { "Sebastian Lackner", "kernel32: Clamp maximum window size to screen buffer size.", 1 },';
) >> "$patchlist"
fi
# Patchset kernel32-GetLogicalProcessorInformationEx
# |
# | Modified files:

View File

@ -11,6 +11,7 @@ wine-staging (1.8~rc3) UNRELEASED; urgency=low
* Added patch to fix possible leak of explorer.exe processes and implement
proper desktop refcounting.
* Added patch to set LastError to 0 in GetSidIdentifierAuthority.
* Added patch to properly implement GetLargestConsoleWindowSize.
-- Sebastian Lackner <sebastian@fds-team.de> Tue, 01 Dec 2015 02:35:10 +0100
wine-staging (1.8~rc2) unstable; urgency=low