Author: hbelusca
Date: Tue Jul 29 13:18:59 2014
New Revision: 63766
URL:
http://svn.reactos.org/svn/reactos?rev=63766&view=rev
Log:
[KERNEL32][CONSRV]
- Use a CODE_ELEMENT structure in order to simplify the code.
- Do not do an on-place ansi to unicode conversion.
Modified:
branches/condrv_restructure/dll/win32/kernel32/client/console/readwrite.c
branches/condrv_restructure/include/reactos/subsys/win/conmsg.h
branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c
branches/condrv_restructure/win32ss/user/winsrv/consrv/conoutput.c
Modified: branches/condrv_restructure/dll/win32/kernel32/client/console/readwrite.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/win32/ke…
==============================================================================
--- branches/condrv_restructure/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1]
Tue Jul 29 13:18:59 2014
@@ -771,39 +771,29 @@
BOOL
IntFillConsoleOutputCode(HANDLE hConsoleOutput,
CODE_TYPE CodeType,
- PVOID pCode,
+ CODE_ELEMENT Code,
DWORD nLength,
COORD dwWriteCoord,
LPDWORD lpNumberOfCodesWritten)
{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_FILLOUTPUTCODE FillOutputRequest = &ApiMessage.Data.FillOutputRequest;
+
+ if ( (CodeType != CODE_ASCII ) &&
+ (CodeType != CODE_UNICODE ) &&
+ (CodeType != CODE_ATTRIBUTE) )
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
/* Set up the data to send to the Console Server */
FillOutputRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
FillOutputRequest->OutputHandle = hConsoleOutput;
FillOutputRequest->WriteCoord = dwWriteCoord;
- FillOutputRequest->NumCodes = nLength;
-
FillOutputRequest->CodeType = CodeType;
- switch (CodeType)
- {
- case CODE_ASCII:
- FillOutputRequest->Code.AsciiChar = *(PCHAR)pCode;
- break;
-
- case CODE_UNICODE:
- FillOutputRequest->Code.UnicodeChar = *(PWCHAR)pCode;
- break;
-
- case CODE_ATTRIBUTE:
- FillOutputRequest->Code.Attribute = *(PWORD)pCode;
- break;
-
- default:
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
+ FillOutputRequest->Code = Code;
+ FillOutputRequest->NumCodes = nLength;
/* Call the server */
CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
@@ -1373,9 +1363,11 @@
COORD dwWriteCoord,
LPDWORD lpNumberOfCharsWritten)
{
+ CODE_ELEMENT Code;
+ Code.UnicodeChar = cCharacter;
return IntFillConsoleOutputCode(hConsoleOutput,
CODE_UNICODE,
- &cCharacter,
+ Code,
nLength,
dwWriteCoord,
lpNumberOfCharsWritten);
@@ -1395,9 +1387,11 @@
COORD dwWriteCoord,
LPDWORD lpNumberOfCharsWritten)
{
+ CODE_ELEMENT Code;
+ Code.AsciiChar = cCharacter;
return IntFillConsoleOutputCode(hConsoleOutput,
CODE_ASCII,
- &cCharacter,
+ Code,
nLength,
dwWriteCoord,
lpNumberOfCharsWritten);
@@ -1417,9 +1411,11 @@
COORD dwWriteCoord,
LPDWORD lpNumberOfAttrsWritten)
{
+ CODE_ELEMENT Code;
+ Code.Attribute = wAttribute;
return IntFillConsoleOutputCode(hConsoleOutput,
CODE_ATTRIBUTE,
- &wAttribute,
+ Code,
nLength,
dwWriteCoord,
lpNumberOfAttrsWritten);
Modified: branches/condrv_restructure/include/reactos/subsys/win/conmsg.h
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/include/reac…
==============================================================================
--- branches/condrv_restructure/include/reactos/subsys/win/conmsg.h [iso-8859-1]
(original)
+++ branches/condrv_restructure/include/reactos/subsys/win/conmsg.h [iso-8859-1] Tue Jul
29 13:18:59 2014
@@ -459,6 +459,13 @@
CODE_ATTRIBUTE = 0x03
} CODE_TYPE;
+typedef union _CODE_ELEMENT
+{
+ CHAR AsciiChar;
+ WCHAR UnicodeChar;
+ WORD Attribute;
+} CODE_ELEMENT, *PCODE_ELEMENT;
+
typedef struct
{
HANDLE ConsoleHandle;
@@ -485,13 +492,8 @@
HANDLE OutputHandle;
COORD WriteCoord;
- CODE_TYPE CodeType;
- union
- {
- CHAR AsciiChar;
- WCHAR UnicodeChar;
- WORD Attribute;
- } Code; // Either a character or an attribute.
+ CODE_TYPE CodeType;
+ CODE_ELEMENT Code; // Either a character or an attribute.
ULONG NumCodes;
} CONSOLE_FILLOUTPUTCODE, *PCONSOLE_FILLOUTPUTCODE;
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1] Tue
Jul 29 13:18:59 2014
@@ -1137,7 +1137,7 @@
ConDrvFillConsoleOutput(IN PCONSOLE Console,
IN PTEXTMODE_SCREEN_BUFFER Buffer,
IN CODE_TYPE CodeType,
- IN PVOID Code,
+ IN CODE_ELEMENT Code,
IN ULONG NumCodesToWrite,
IN PCOORD WriteCoord /*,
OUT PULONG CodesWritten */)
@@ -1145,8 +1145,7 @@
DWORD X, Y, Length; // , Written = 0;
PCHAR_INFO Ptr;
- if (Console == NULL || Buffer == NULL || Code == NULL ||
- WriteCoord == NULL /* || CodesWritten == NULL */)
+ if (Console == NULL || Buffer == NULL || WriteCoord == NULL /* || CodesWritten ==
NULL */)
{
return STATUS_INVALID_PARAMETER;
}
@@ -1154,29 +1153,13 @@
/* Validity check */
ASSERT(Console == Buffer->Header.Console);
-#if 0
- switch (CodeType)
- {
- case CODE_ASCII:
- /* On-place conversion from the ASCII char to the UNICODE char */
- ConsoleAnsiCharToUnicodeChar(Console, &Code->UnicodeChar,
&Code->AsciiChar);
- /* Fall through */
- case CODE_UNICODE:
- Code = &Code->UnicodeChar;
- break;
-
- case CODE_ATTRIBUTE:
- Code = &Code->Attribute;
- break;
- }
-#else
if (CodeType == CODE_ASCII)
{
- /* On-place conversion from the ASCII char to the UNICODE char */
- // FIXME: What if Code points to an invalid memory zone ??
- ConsoleAnsiCharToUnicodeChar(Console, (PWCHAR)Code, (PCHAR)Code);
- }
-#endif
+ /* Conversion from the ASCII char to the UNICODE char */
+ CODE_ELEMENT tmp;
+ ConsoleAnsiCharToUnicodeChar(Console, &tmp.UnicodeChar,
&Code.AsciiChar);
+ Code = tmp;
+ }
X = WriteCoord->X;
Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
@@ -1193,11 +1176,11 @@
{
case CODE_ASCII:
case CODE_UNICODE:
- Ptr->Char.UnicodeChar = *(PWCHAR)Code;
+ Ptr->Char.UnicodeChar = Code.UnicodeChar;
break;
case CODE_ATTRIBUTE:
- Ptr->Attributes = *(PWORD)Code;
+ Ptr->Attributes = Code.Attribute;
break;
}
// ++Ptr;
Modified: branches/condrv_restructure/win32ss/user/winsrv/consrv/conoutput.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/win32ss/user…
==============================================================================
--- branches/condrv_restructure/win32ss/user/winsrv/consrv/conoutput.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/win32ss/user/winsrv/consrv/conoutput.c [iso-8859-1] Tue
Jul 29 13:18:59 2014
@@ -691,7 +691,7 @@
ConDrvFillConsoleOutput(IN PCONSOLE Console,
IN PTEXTMODE_SCREEN_BUFFER Buffer,
IN CODE_TYPE CodeType,
- IN PVOID Code,
+ IN CODE_ELEMENT Code,
IN ULONG NumCodesToWrite,
IN PCOORD WriteCoord /*,
OUT PULONG CodesWritten */);
@@ -700,7 +700,7 @@
NTSTATUS Status;
PCONSOLE_FILLOUTPUTCODE FillOutputRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputRequest;
PTEXTMODE_SCREEN_BUFFER Buffer;
- USHORT CodeType = FillOutputRequest->CodeType;
+ CODE_TYPE CodeType = FillOutputRequest->CodeType;
DPRINT("SrvFillConsoleOutput\n");
@@ -719,7 +719,7 @@
Status = ConDrvFillConsoleOutput(Buffer->Header.Console,
Buffer,
CodeType,
- &FillOutputRequest->Code,
+ FillOutputRequest->Code,
FillOutputRequest->NumCodes,
&FillOutputRequest->WriteCoord /*,
&FillOutputRequest->NrCharactersWritten */);