Author: hbelusca
Date: Tue Jul 29 13:49:03 2014
New Revision: 63768
URL:
http://svn.reactos.org/svn/reactos?rev=63768&view=rev
Log:
Simplify code.
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:49:03 2014
@@ -319,6 +319,14 @@
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 @@
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 @@
*/
if (SizeBytes <= sizeof(ReadOutputCodeRequest->CodeStaticBuffer))
{
- ReadOutputCodeRequest->pCode.pCode =
ReadOutputCodeRequest->CodeStaticBuffer;
+ ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer;
// CaptureBuffer = NULL;
}
else
@@ -372,7 +376,7 @@
/* Allocate space in the Buffer */
CsrAllocateMessagePointer(CaptureBuffer,
SizeBytes,
- (PVOID*)&ReadOutputCodeRequest->pCode.pCode);
+ (PVOID*)&ReadOutputCodeRequest->pCode);
}
/* Call the server */
@@ -386,7 +390,7 @@
{
DWORD NumCodes = ReadOutputCodeRequest->NumCodes;
RtlCopyMemory(pCode,
- ReadOutputCodeRequest->pCode.pCode,
+ ReadOutputCodeRequest->pCode,
NumCodes * CodeSize);
if (lpNumberOfCodesRead != NULL)
@@ -675,6 +679,14 @@
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 @@
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 @@
*/
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 @@
CsrCaptureMessageBuffer(CaptureBuffer,
(PVOID)pCode,
SizeBytes,
- (PVOID*)&WriteOutputCodeRequest->pCode.pCode);
+ (PVOID*)&WriteOutputCodeRequest->pCode);
}
/* Call the server */
@@ -778,6 +786,8 @@
{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_FILLOUTPUTCODE FillOutputRequest = &ApiMessage.Data.FillOutputRequest;
+
+ DPRINT("IntFillConsoleOutputCode\n");
if ( (CodeType != CODE_ASCII ) &&
(CodeType != CODE_UNICODE ) &&
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:49:03 2014
@@ -464,7 +464,7 @@
CHAR AsciiChar;
WCHAR UnicodeChar;
WORD Attribute;
-} CODE_ELEMENT, *PCODE_ELEMENT;
+} CODE_ELEMENT;
typedef struct
{
@@ -473,14 +473,15 @@
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,
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:49:03 2014
@@ -913,15 +913,15 @@
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 @@
}
}
- // 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 @@
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:
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:49:03 2014
@@ -540,15 +540,15 @@
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 @@
* 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 @@
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 @@
* 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),