[PATCH 4/4] kernel32: Implement GetCurrentConsoleFont semi-stub

Hugh McMaster hugh.mcmaster at outlook.com
Tue Oct 20 03:51:30 CDT 2015


Implements error handling and the FALSE pathway.

Signed-off-by: Hugh McMaster <hugh.mcmaster at outlook.com>
---
 dlls/kernel32/console.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)

diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 14f1189..c893d33 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -3236,9 +3236,49 @@ BOOL WINAPI SetConsoleIcon(HICON icon)
 
 BOOL WINAPI GetCurrentConsoleFont(HANDLE hConsole, BOOL maxwindow, LPCONSOLE_FONT_INFO fontinfo)
 {
-    FIXME(": (%p, %d, %p) stub!\n", hConsole, maxwindow, fontinfo);
-    SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-    return FALSE;
+    BOOL ret;
+    DWORD version, major_version;
+
+    if (!hConsole || hConsole == GetStdHandle(STD_INPUT_HANDLE))
+    {
+        SetLastError(ERROR_INVALID_HANDLE);
+        if (fontinfo)
+        {
+            fontinfo->nFont = 0;
+            fontinfo->dwFontSize.X = 0;
+            fontinfo->dwFontSize.Y = 0;
+        }
+        return FALSE;
+    }
+
+    version = GetVersion();
+    major_version = (DWORD)(LOBYTE(LOWORD(version)));
+
+    if (maxwindow)
+    {
+        FIXME(": (%p, %d, %p) stub!\n", hConsole, maxwindow, fontinfo);
+        SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+        return FALSE;
+    }
+
+    SERVER_START_REQ(get_console_output_info)
+    {
+        req->handle = wine_server_obj_handle(hConsole);
+        ret = !wine_server_call_err(req);
+        fontinfo->nFont = reply->font_index;
+        if (major_version >= 6) /* Windows Vista or higher */
+        {
+            fontinfo->dwFontSize.X = reply->font_width;
+            fontinfo->dwFontSize.Y = reply->font_height;
+        }
+        else
+        {
+            fontinfo->dwFontSize.X = reply->win_right - reply->win_left + 1;
+            fontinfo->dwFontSize.Y = reply->win_bottom - reply->win_top + 1;
+        }
+    }
+    SERVER_END_REQ;
+    return ret;
 }
 
 #ifdef __i386__
-- 
1.9.1




More information about the wine-patches mailing list