mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 06:15:26 +00:00
[KERNEL32][CONSRV]
- Use a CODE_ELEMENT structure in order to simplify the code. - Do not do an on-place ansi to unicode conversion. svn path=/branches/condrv_restructure/; revision=63766
This commit is contained in:
parent
6f772ac651
commit
2d9a888371
4 changed files with 40 additions and 59 deletions
|
@ -771,7 +771,7 @@ static
|
|||
BOOL
|
||||
IntFillConsoleOutputCode(HANDLE hConsoleOutput,
|
||||
CODE_TYPE CodeType,
|
||||
PVOID pCode,
|
||||
CODE_ELEMENT Code,
|
||||
DWORD nLength,
|
||||
COORD dwWriteCoord,
|
||||
LPDWORD lpNumberOfCodesWritten)
|
||||
|
@ -779,31 +779,21 @@ IntFillConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
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 @@ FillConsoleOutputCharacterW(HANDLE hConsoleOutput,
|
|||
COORD dwWriteCoord,
|
||||
LPDWORD lpNumberOfCharsWritten)
|
||||
{
|
||||
CODE_ELEMENT Code;
|
||||
Code.UnicodeChar = cCharacter;
|
||||
return IntFillConsoleOutputCode(hConsoleOutput,
|
||||
CODE_UNICODE,
|
||||
&cCharacter,
|
||||
Code,
|
||||
nLength,
|
||||
dwWriteCoord,
|
||||
lpNumberOfCharsWritten);
|
||||
|
@ -1395,9 +1387,11 @@ FillConsoleOutputCharacterA(HANDLE hConsoleOutput,
|
|||
COORD dwWriteCoord,
|
||||
LPDWORD lpNumberOfCharsWritten)
|
||||
{
|
||||
CODE_ELEMENT Code;
|
||||
Code.AsciiChar = cCharacter;
|
||||
return IntFillConsoleOutputCode(hConsoleOutput,
|
||||
CODE_ASCII,
|
||||
&cCharacter,
|
||||
Code,
|
||||
nLength,
|
||||
dwWriteCoord,
|
||||
lpNumberOfCharsWritten);
|
||||
|
@ -1417,9 +1411,11 @@ FillConsoleOutputAttribute(HANDLE hConsoleOutput,
|
|||
COORD dwWriteCoord,
|
||||
LPDWORD lpNumberOfAttrsWritten)
|
||||
{
|
||||
CODE_ELEMENT Code;
|
||||
Code.Attribute = wAttribute;
|
||||
return IntFillConsoleOutputCode(hConsoleOutput,
|
||||
CODE_ATTRIBUTE,
|
||||
&wAttribute,
|
||||
Code,
|
||||
nLength,
|
||||
dwWriteCoord,
|
||||
lpNumberOfAttrsWritten);
|
||||
|
|
|
@ -459,6 +459,13 @@ typedef enum _CODE_TYPE
|
|||
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 @@ typedef struct
|
|||
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;
|
||||
|
|
|
@ -1137,7 +1137,7 @@ NTSTATUS NTAPI
|
|||
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 @@ ConDrvFillConsoleOutput(IN PCONSOLE Console,
|
|||
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 @@ ConDrvFillConsoleOutput(IN PCONSOLE Console,
|
|||
/* 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);
|
||||
/* Conversion from the ASCII char to the UNICODE char */
|
||||
CODE_ELEMENT tmp;
|
||||
ConsoleAnsiCharToUnicodeChar(Console, &tmp.UnicodeChar, &Code.AsciiChar);
|
||||
Code = tmp;
|
||||
}
|
||||
#endif
|
||||
|
||||
X = WriteCoord->X;
|
||||
Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
|
||||
|
@ -1193,11 +1176,11 @@ ConDrvFillConsoleOutput(IN PCONSOLE Console,
|
|||
{
|
||||
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;
|
||||
|
|
|
@ -691,7 +691,7 @@ NTSTATUS NTAPI
|
|||
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 @@ CSR_API(SrvFillConsoleOutput)
|
|||
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 @@ CSR_API(SrvFillConsoleOutput)
|
|||
Status = ConDrvFillConsoleOutput(Buffer->Header.Console,
|
||||
Buffer,
|
||||
CodeType,
|
||||
&FillOutputRequest->Code,
|
||||
FillOutputRequest->Code,
|
||||
FillOutputRequest->NumCodes,
|
||||
&FillOutputRequest->WriteCoord /*,
|
||||
&FillOutputRequest->NrCharactersWritten */);
|
||||
|
|
Loading…
Reference in a new issue