Author: hbelusca
Date: Fri Dec 4 00:43:31 2015
New Revision: 70258
URL:
http://svn.reactos.org/svn/reactos?rev=70258&view=rev
Log:
[KERNEL32]
Implement client-side only of console font APIs:
- documented: GetConsoleFontSize, GetCurrentConsoleFont;
- undocumented: GetConsoleFontInfo, GetNumberOfConsoleFonts, SetConsoleFont (see
http://cboard.cprogramming.com/windows-programming/102187-console-font-size… for a
working usage example of these APIs).
(Also related to CORE-7931)
Modified:
trunk/reactos/dll/win32/kernel32/client/console/console.c
trunk/reactos/include/reactos/subsys/win/conmsg.h
Modified: trunk/reactos/dll/win32/kernel32/client/console/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/console/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/console/console.c [iso-8859-1] Fri Dec 4
00:43:31 2015
@@ -553,34 +553,85 @@
/*
- * @unimplemented (Undocumented)
+ * @implemented (Undocumented)
+ * @note See
http://cboard.cprogramming.com/windows-programming/102187-console-font-size…
*/
DWORD
WINAPI
-GetConsoleFontInfo(HANDLE hConsoleOutput,
- BOOL bMaximumWindow,
- DWORD nFontCount,
- PCONSOLE_FONT_INFO lpConsoleFontInfo)
-{
- DPRINT1("GetConsoleFontInfo(0x%p, %d, %lu, 0x%p) UNIMPLEMENTED!\n",
hConsoleOutput, bMaximumWindow, nFontCount, lpConsoleFontInfo);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-
-/*
- * @unimplemented
+GetConsoleFontInfo(IN HANDLE hConsoleOutput,
+ IN BOOL bMaximumWindow,
+ IN DWORD nFontCount,
+ OUT PCONSOLE_FONT_INFO lpConsoleFontInfo)
+{
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GETFONTINFO GetFontInfoRequest = &ApiMessage.Data.GetFontInfoRequest;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
+
+ GetFontInfoRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ GetFontInfoRequest->OutputHandle = hConsoleOutput;
+ GetFontInfoRequest->MaximumWindow = bMaximumWindow;
+ GetFontInfoRequest->NumFonts = nFontCount;
+
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, nFontCount * sizeof(CONSOLE_FONT_INFO));
+ if (CaptureBuffer == NULL)
+ {
+ DPRINT1("CsrAllocateCaptureBuffer failed!\n");
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return 0;
+ }
+
+ CsrAllocateMessagePointer(CaptureBuffer,
+ nFontCount * sizeof(CONSOLE_FONT_INFO),
+ (PVOID*)&GetFontInfoRequest->FontInfo);
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ CaptureBuffer,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetFontInfo),
+ sizeof(*GetFontInfoRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ }
+ else
+ {
+ RtlCopyMemory(lpConsoleFontInfo,
+ GetFontInfoRequest->FontInfo,
+ GetFontInfoRequest->NumFonts * sizeof(CONSOLE_FONT_INFO));
+ }
+
+ CsrFreeCaptureBuffer(CaptureBuffer);
+ return GetFontInfoRequest->NumFonts;
+}
+
+
+/*
+ * @implemented
*/
COORD
WINAPI
DECLSPEC_HOTPATCH
-GetConsoleFontSize(HANDLE hConsoleOutput,
- DWORD nFont)
-{
+GetConsoleFontSize(IN HANDLE hConsoleOutput,
+ IN DWORD nFont)
+{
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GETFONTSIZE GetFontSizeRequest = &ApiMessage.Data.GetFontSizeRequest;
COORD Empty = {0, 0};
- DPRINT1("GetConsoleFontSize(0x%p, 0x%x) UNIMPLEMENTED!\n", hConsoleOutput,
nFont);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return Empty;
+
+ GetFontSizeRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ GetFontSizeRequest->OutputHandle = hConsoleOutput;
+ GetFontSizeRequest->FontIndex = nFont;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetFontSize),
+ sizeof(*GetFontSizeRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return Empty;
+ }
+
+ return GetFontSizeRequest->FontSize;
}
@@ -636,31 +687,63 @@
/*
- * @unimplemented
- */
-BOOL
-WINAPI
-GetCurrentConsoleFont(HANDLE hConsoleOutput,
- BOOL bMaximumWindow,
- PCONSOLE_FONT_INFO lpConsoleCurrentFont)
-{
- DPRINT1("GetCurrentConsoleFont(0x%p, 0x%x, 0x%p) UNIMPLEMENTED!\n",
hConsoleOutput, bMaximumWindow, lpConsoleCurrentFont);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 0;
-}
-
-
-/*
- * @unimplemented (Undocumented)
- */
-ULONG
+ * @implemented
+ */
+BOOL
+WINAPI
+GetCurrentConsoleFont(IN HANDLE hConsoleOutput,
+ IN BOOL bMaximumWindow,
+ OUT PCONSOLE_FONT_INFO lpConsoleCurrentFont)
+{
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GETCURRENTFONT GetCurrentFontRequest =
&ApiMessage.Data.GetCurrentFontRequest;
+
+ GetCurrentFontRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ GetCurrentFontRequest->OutputHandle = hConsoleOutput;
+ GetCurrentFontRequest->MaximumWindow = bMaximumWindow;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetCurrentFont),
+ sizeof(*GetCurrentFontRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return FALSE;
+ }
+
+ lpConsoleCurrentFont->dwFontSize = GetCurrentFontRequest->FontSize;
+ lpConsoleCurrentFont->nFont = GetCurrentFontRequest->FontIndex;
+
+ return TRUE;
+}
+
+
+/*
+ * @implemented (Undocumented)
+ * @note See
http://cboard.cprogramming.com/windows-programming/102187-console-font-size…
+ */
+DWORD
WINAPI
DECLSPEC_HOTPATCH
GetNumberOfConsoleFonts(VOID)
{
- DPRINT1("GetNumberOfConsoleFonts() UNIMPLEMENTED!\n");
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return 1;
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GETNUMFONTS GetNumFontsRequest = &ApiMessage.Data.GetNumFontsRequest;
+
+ GetNumFontsRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetNumberOfFonts),
+ sizeof(*GetNumFontsRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return 0;
+ }
+
+ return GetNumFontsRequest->NumFonts;
}
@@ -823,17 +906,33 @@
/*
- * @unimplemented (Undocumented)
- */
-BOOL
-WINAPI
-DECLSPEC_HOTPATCH
-SetConsoleFont(HANDLE hConsoleOutput,
- DWORD nFont)
-{
- DPRINT1("SetConsoleFont(0x%p, %lu) UNIMPLEMENTED!\n", hConsoleOutput,
nFont);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ * @implemented (Undocumented)
+ * @note See
http://cboard.cprogramming.com/windows-programming/102187-console-font-size…
+ */
+BOOL
+WINAPI
+DECLSPEC_HOTPATCH
+SetConsoleFont(IN HANDLE hConsoleOutput,
+ IN DWORD nFont)
+{
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_SETFONT SetFontRequest = &ApiMessage.Data.SetFontRequest;
+
+ SetFontRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ SetFontRequest->OutputHandle = hConsoleOutput;
+ SetFontRequest->FontIndex = nFont;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetFont),
+ sizeof(*SetFontRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return FALSE;
+ }
+
+ return TRUE;
}
@@ -2102,7 +2201,7 @@
if (dwNumChars > 0)
{
- memcpy(lpConsoleTitle, TitleRequest->Title, TitleRequest->Length);
+ RtlCopyMemory(lpConsoleTitle, TitleRequest->Title, TitleRequest->Length);
if (bUnicode)
((LPWSTR)lpConsoleTitle)[dwNumChars] = UNICODE_NULL;
@@ -2452,7 +2551,7 @@
nProcesses = GetProcessListRequest->ProcessCount;
if (dwProcessCount >= nProcesses)
{
- memcpy(lpdwProcessList, GetProcessListRequest->ProcessIdsList, nProcesses
* sizeof(DWORD));
+ RtlCopyMemory(lpdwProcessList, GetProcessListRequest->ProcessIdsList,
nProcesses * sizeof(DWORD));
}
}
Modified: trunk/reactos/include/reactos/subsys/win/conmsg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/win…
==============================================================================
--- trunk/reactos/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/win/conmsg.h [iso-8859-1] Fri Dec 4 00:43:31
2015
@@ -400,6 +400,46 @@
} CONSOLE_GETSETHWSTATE, *PCONSOLE_GETSETHWSTATE;
+typedef struct _CONSOLE_GETNUMFONTS
+{
+ HANDLE ConsoleHandle;
+ DWORD NumFonts;
+} CONSOLE_GETNUMFONTS, *PCONSOLE_GETNUMFONTS;
+
+typedef struct _CONSOLE_GETFONTINFO
+{
+ HANDLE ConsoleHandle;
+ HANDLE OutputHandle;
+ BOOLEAN MaximumWindow;
+ PCONSOLE_FONT_INFO FontInfo;
+ DWORD NumFonts;
+} CONSOLE_GETFONTINFO, *PCONSOLE_GETFONTINFO;
+
+typedef struct _CONSOLE_GETFONTSIZE
+{
+ HANDLE ConsoleHandle;
+ HANDLE OutputHandle;
+ DWORD FontIndex;
+ COORD FontSize;
+} CONSOLE_GETFONTSIZE, *PCONSOLE_GETFONTSIZE;
+
+typedef struct _CONSOLE_GETCURRENTFONT
+{
+ HANDLE ConsoleHandle;
+ HANDLE OutputHandle;
+ BOOLEAN MaximumWindow;
+ DWORD FontIndex;
+ COORD FontSize;
+} CONSOLE_GETCURRENTFONT, *PCONSOLE_GETCURRENTFONT;
+
+typedef struct _CONSOLE_SETFONT
+{
+ HANDLE ConsoleHandle;
+ HANDLE OutputHandle;
+ DWORD FontIndex;
+} CONSOLE_SETFONT, *PCONSOLE_SETFONT;
+
+
typedef struct _CONSOLE_CREATESCREENBUFFER
{
@@ -899,6 +939,13 @@
CONSOLE_SETDISPLAYMODE SetDisplayModeRequest;
CONSOLE_GETSETHWSTATE HardwareStateRequest;
+ /* Console fonts */
+ CONSOLE_GETNUMFONTS GetNumFontsRequest;
+ CONSOLE_GETFONTINFO GetFontInfoRequest;
+ CONSOLE_GETFONTSIZE GetFontSizeRequest;
+ CONSOLE_GETCURRENTFONT GetCurrentFontRequest;
+ CONSOLE_SETFONT SetFontRequest;
+
/* Console window */
CONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest;
CONSOLE_SETPALETTE SetPaletteRequest;