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