mirror of
https://github.com/reactos/reactos.git
synced 2025-02-21 16:04:57 +00:00
Simplify code.
svn path=/branches/condrv_restructure/; revision=63768
This commit is contained in:
parent
2d9a888371
commit
5ce6a6c12b
4 changed files with 58 additions and 62 deletions
|
@ -319,6 +319,14 @@ IntReadConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
|
||||
DPRINT("IntReadConsoleOutputCode\n");
|
||||
|
||||
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 */
|
||||
ReadOutputCodeRequest->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
|
||||
ReadOutputCodeRequest->OutputHandle = hConsoleOutput;
|
||||
|
@ -330,20 +338,16 @@ IntReadConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
switch (CodeType)
|
||||
{
|
||||
case CODE_ASCII:
|
||||
CodeSize = sizeof(CHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
|
||||
break;
|
||||
|
||||
case CODE_UNICODE:
|
||||
CodeSize = sizeof(WCHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
|
||||
break;
|
||||
|
||||
case CODE_ATTRIBUTE:
|
||||
CodeSize = sizeof(WORD);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
|
||||
break;
|
||||
|
||||
default:
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
SizeBytes = nLength * CodeSize;
|
||||
|
||||
|
@ -355,7 +359,7 @@ IntReadConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
*/
|
||||
if (SizeBytes <= sizeof(ReadOutputCodeRequest->CodeStaticBuffer))
|
||||
{
|
||||
ReadOutputCodeRequest->pCode.pCode = ReadOutputCodeRequest->CodeStaticBuffer;
|
||||
ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer;
|
||||
// CaptureBuffer = NULL;
|
||||
}
|
||||
else
|
||||
|
@ -372,7 +376,7 @@ IntReadConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
/* Allocate space in the Buffer */
|
||||
CsrAllocateMessagePointer(CaptureBuffer,
|
||||
SizeBytes,
|
||||
(PVOID*)&ReadOutputCodeRequest->pCode.pCode);
|
||||
(PVOID*)&ReadOutputCodeRequest->pCode);
|
||||
}
|
||||
|
||||
/* Call the server */
|
||||
|
@ -386,7 +390,7 @@ IntReadConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
{
|
||||
DWORD NumCodes = ReadOutputCodeRequest->NumCodes;
|
||||
RtlCopyMemory(pCode,
|
||||
ReadOutputCodeRequest->pCode.pCode,
|
||||
ReadOutputCodeRequest->pCode,
|
||||
NumCodes * CodeSize);
|
||||
|
||||
if (lpNumberOfCodesRead != NULL)
|
||||
|
@ -675,6 +679,14 @@ IntWriteConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if ( (CodeType != CODE_ASCII ) &&
|
||||
(CodeType != CODE_UNICODE ) &&
|
||||
(CodeType != CODE_ATTRIBUTE) )
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DPRINT("IntWriteConsoleOutputCode\n");
|
||||
|
||||
/* Set up the data to send to the Console Server */
|
||||
|
@ -688,20 +700,16 @@ IntWriteConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
switch (CodeType)
|
||||
{
|
||||
case CODE_ASCII:
|
||||
CodeSize = sizeof(CHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
|
||||
break;
|
||||
|
||||
case CODE_UNICODE:
|
||||
CodeSize = sizeof(WCHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
|
||||
break;
|
||||
|
||||
case CODE_ATTRIBUTE:
|
||||
CodeSize = sizeof(WORD);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
|
||||
break;
|
||||
|
||||
default:
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
SizeBytes = nLength * CodeSize;
|
||||
|
||||
|
@ -713,10 +721,10 @@ IntWriteConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
*/
|
||||
if (SizeBytes <= sizeof(WriteOutputCodeRequest->CodeStaticBuffer))
|
||||
{
|
||||
WriteOutputCodeRequest->pCode.pCode = WriteOutputCodeRequest->CodeStaticBuffer;
|
||||
WriteOutputCodeRequest->pCode = WriteOutputCodeRequest->CodeStaticBuffer;
|
||||
// CaptureBuffer = NULL;
|
||||
|
||||
RtlCopyMemory(WriteOutputCodeRequest->pCode.pCode,
|
||||
RtlCopyMemory(WriteOutputCodeRequest->pCode,
|
||||
pCode,
|
||||
SizeBytes);
|
||||
}
|
||||
|
@ -735,7 +743,7 @@ IntWriteConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
CsrCaptureMessageBuffer(CaptureBuffer,
|
||||
(PVOID)pCode,
|
||||
SizeBytes,
|
||||
(PVOID*)&WriteOutputCodeRequest->pCode.pCode);
|
||||
(PVOID*)&WriteOutputCodeRequest->pCode);
|
||||
}
|
||||
|
||||
/* Call the server */
|
||||
|
@ -779,6 +787,8 @@ IntFillConsoleOutputCode(HANDLE hConsoleOutput,
|
|||
CONSOLE_API_MESSAGE ApiMessage;
|
||||
PCONSOLE_FILLOUTPUTCODE FillOutputRequest = &ApiMessage.Data.FillOutputRequest;
|
||||
|
||||
DPRINT("IntFillConsoleOutputCode\n");
|
||||
|
||||
if ( (CodeType != CODE_ASCII ) &&
|
||||
(CodeType != CODE_UNICODE ) &&
|
||||
(CodeType != CODE_ATTRIBUTE) )
|
||||
|
|
|
@ -464,7 +464,7 @@ typedef union _CODE_ELEMENT
|
|||
CHAR AsciiChar;
|
||||
WCHAR UnicodeChar;
|
||||
WORD Attribute;
|
||||
} CODE_ELEMENT, *PCODE_ELEMENT;
|
||||
} CODE_ELEMENT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -473,14 +473,15 @@ typedef struct
|
|||
COORD Coord;
|
||||
|
||||
CODE_TYPE CodeType;
|
||||
CHAR CodeStaticBuffer[80];
|
||||
union
|
||||
{
|
||||
PVOID pCode;
|
||||
PCHAR AsciiChar;
|
||||
PWCHAR UnicodeChar;
|
||||
PWORD Attribute;
|
||||
} pCode; // Either a pointer to a character or to an attribute.
|
||||
CHAR CodeStaticBuffer[80]; // == 40 * sizeof(CODE_ELEMENT)
|
||||
PVOID pCode; // Either a pointer to a character or to an attribute.
|
||||
// union
|
||||
// {
|
||||
// PVOID pCode;
|
||||
// PCHAR AsciiChar;
|
||||
// PWCHAR UnicodeChar;
|
||||
// PWORD Attribute;
|
||||
// } pCode; // Either a pointer to a character or to an attribute.
|
||||
|
||||
ULONG NumCodes;
|
||||
} CONSOLE_READOUTPUTCODE , *PCONSOLE_READOUTPUTCODE,
|
||||
|
|
|
@ -913,15 +913,15 @@ ConDrvReadConsoleOutputString(IN PCONSOLE Console,
|
|||
switch (CodeType)
|
||||
{
|
||||
case CODE_ASCII:
|
||||
CodeSize = sizeof(CHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
|
||||
break;
|
||||
|
||||
case CODE_UNICODE:
|
||||
CodeSize = sizeof(WCHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
|
||||
break;
|
||||
|
||||
case CODE_ATTRIBUTE:
|
||||
CodeSize = sizeof(WORD);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -982,21 +982,6 @@ ConDrvReadConsoleOutputString(IN PCONSOLE Console,
|
|||
}
|
||||
}
|
||||
|
||||
// switch (CodeType)
|
||||
// {
|
||||
// case CODE_UNICODE:
|
||||
// *(PWCHAR)ReadBuffer = 0;
|
||||
// break;
|
||||
|
||||
// case CODE_ASCII:
|
||||
// *(PCHAR)ReadBuffer = 0;
|
||||
// break;
|
||||
|
||||
// case CODE_ATTRIBUTE:
|
||||
// *(PWORD)ReadBuffer = 0;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// EndCoord->X = Xpos;
|
||||
// EndCoord->Y = (Ypos - Buffer->VirtualY + Buffer->ScreenBufferSize.Y) % Buffer->ScreenBufferSize.Y;
|
||||
|
||||
|
@ -1036,15 +1021,15 @@ ConDrvWriteConsoleOutputString(IN PCONSOLE Console,
|
|||
switch (CodeType)
|
||||
{
|
||||
case CODE_ASCII:
|
||||
CodeSize = sizeof(CHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
|
||||
break;
|
||||
|
||||
case CODE_UNICODE:
|
||||
CodeSize = sizeof(WCHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
|
||||
break;
|
||||
|
||||
case CODE_ATTRIBUTE:
|
||||
CodeSize = sizeof(WORD);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -540,15 +540,15 @@ CSR_API(SrvReadConsoleOutputString)
|
|||
switch (ReadOutputCodeRequest->CodeType)
|
||||
{
|
||||
case CODE_ASCII:
|
||||
CodeSize = sizeof(CHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
|
||||
break;
|
||||
|
||||
case CODE_UNICODE:
|
||||
CodeSize = sizeof(WCHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
|
||||
break;
|
||||
|
||||
case CODE_ATTRIBUTE:
|
||||
CodeSize = sizeof(WORD);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -567,20 +567,20 @@ CSR_API(SrvReadConsoleOutputString)
|
|||
* Adjust the internal pointer, because its old value points to
|
||||
* the static buffer in the original ApiMessage structure.
|
||||
*/
|
||||
// ReadOutputCodeRequest->pCode.pCode = ReadOutputCodeRequest->CodeStaticBuffer;
|
||||
// ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer;
|
||||
pCode = ReadOutputCodeRequest->CodeStaticBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&ReadOutputCodeRequest->pCode.pCode,
|
||||
(PVOID*)&ReadOutputCodeRequest->pCode,
|
||||
ReadOutputCodeRequest->NumCodes,
|
||||
CodeSize))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
pCode = ReadOutputCodeRequest->pCode.pCode;
|
||||
pCode = ReadOutputCodeRequest->pCode;
|
||||
}
|
||||
|
||||
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
|
@ -624,15 +624,15 @@ CSR_API(SrvWriteConsoleOutputString)
|
|||
switch (WriteOutputCodeRequest->CodeType)
|
||||
{
|
||||
case CODE_ASCII:
|
||||
CodeSize = sizeof(CHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
|
||||
break;
|
||||
|
||||
case CODE_UNICODE:
|
||||
CodeSize = sizeof(WCHAR);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
|
||||
break;
|
||||
|
||||
case CODE_ATTRIBUTE:
|
||||
CodeSize = sizeof(WORD);
|
||||
CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -651,20 +651,20 @@ CSR_API(SrvWriteConsoleOutputString)
|
|||
* Adjust the internal pointer, because its old value points to
|
||||
* the static buffer in the original ApiMessage structure.
|
||||
*/
|
||||
// WriteOutputCodeRequest->pCode.pCode = WriteOutputCodeRequest->CodeStaticBuffer;
|
||||
// WriteOutputCodeRequest->pCode = WriteOutputCodeRequest->CodeStaticBuffer;
|
||||
pCode = WriteOutputCodeRequest->CodeStaticBuffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&WriteOutputCodeRequest->pCode.pCode,
|
||||
(PVOID*)&WriteOutputCodeRequest->pCode,
|
||||
WriteOutputCodeRequest->NumCodes,
|
||||
CodeSize))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
pCode = WriteOutputCodeRequest->pCode.pCode;
|
||||
pCode = WriteOutputCodeRequest->pCode;
|
||||
}
|
||||
|
||||
Status = ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
|
||||
|
|
Loading…
Reference in a new issue