Author: hbelusca
Date: Sun Nov 18 17:06:48 2012
New Revision: 57734
URL:
http://svn.reactos.org/svn/reactos?rev=57734&view=rev
Log:
[KERNEL32/CONSRV]
- Merge IntFillConsoleOutputCharacter and FillConsoleOutputAttribute functions into
IntFillConsoleOutputCode helper and make it used by
FillConsoleOutputAttribute/CharacterW/A.
- In server-side, CsrFillOutputChar and CsrFillOutputAttrib are merged into
SrvFillConsoleOutput.
- Merge CSRSS_FILL_OUTPUT and CSRSS_FILL_OUTPUT_ATTRIB structures into CSRSS_FILL_OUTPUT.
Modified:
branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c
branches/ros-csrss/include/reactos/subsys/win/conmsg.h
branches/ros-csrss/win32ss/user/consrv/conoutput.c
Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
==============================================================================
--- branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1]
(original)
+++ branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] Sun Nov
18 17:06:48 2012
@@ -328,7 +328,7 @@
static
BOOL
IntReadConsoleOutputCode(HANDLE hConsoleOutput,
- USHORT CodeType,
+ CODE_TYPE CodeType,
PVOID pCode,
DWORD nLength,
COORD dwReadCoord,
@@ -721,42 +721,55 @@
static
BOOL
-IntFillConsoleOutputCharacter(HANDLE hConsoleOutput,
- PVOID cCharacter,
- DWORD nLength,
- COORD dwWriteCoord,
- LPDWORD lpNumberOfCharsWritten,
- BOOL bUnicode)
-{
- CSR_API_MESSAGE Request;
+IntFillConsoleOutputCode(HANDLE hConsoleOutput,
+ CODE_TYPE CodeType,
+ PVOID pCode,
+ DWORD nLength,
+ COORD dwWriteCoord,
+ LPDWORD lpNumberOfCodesWritten)
+{
NTSTATUS Status;
-
- Request.Data.FillOutputRequest.ConsoleHandle = hConsoleOutput;
- Request.Data.FillOutputRequest.Unicode = bUnicode;
-
- if(bUnicode)
- Request.Data.FillOutputRequest.Char.UnicodeChar = *((WCHAR*)cCharacter);
- else
- Request.Data.FillOutputRequest.Char.AsciiChar = *((CHAR*)cCharacter);
-
- Request.Data.FillOutputRequest.Position = dwWriteCoord;
- Request.Data.FillOutputRequest.Length = (WORD)nLength;
-
- Status = CsrClientCallServer(&Request,
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCSRSS_FILL_OUTPUT FillOutputRequest = &ApiMessage.Data.FillOutputRequest;
+
+ FillOutputRequest->ConsoleHandle = hConsoleOutput;
+ 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->Coord = dwWriteCoord;
+ FillOutputRequest->Length = nLength;
+
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, FILL_OUTPUT),
- sizeof(CSR_API_MESSAGE));
-
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepFillConsoleOutput),
+ sizeof(CSRSS_FILL_OUTPUT));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status))
{
BaseSetLastNTError(Status);
return FALSE;
}
- if(lpNumberOfCharsWritten != NULL)
- {
- *lpNumberOfCharsWritten = Request.Data.FillOutputRequest.NrCharactersWritten;
- }
+ if (lpNumberOfCodesWritten)
+ *lpNumberOfCodesWritten = FillOutputRequest->Length;
+ // *lpNumberOfCharsWritten = Request.Data.FillOutputRequest.NrCharactersWritten;
return TRUE;
}
@@ -1277,12 +1290,12 @@
COORD dwWriteCoord,
LPDWORD lpNumberOfCharsWritten)
{
- return IntFillConsoleOutputCharacter(hConsoleOutput,
- &cCharacter,
- nLength,
- dwWriteCoord,
- lpNumberOfCharsWritten,
- TRUE);
+ return IntFillConsoleOutputCode(hConsoleOutput,
+ CODE_UNICODE,
+ &cCharacter,
+ nLength,
+ dwWriteCoord,
+ lpNumberOfCharsWritten);
}
@@ -1299,12 +1312,12 @@
COORD dwWriteCoord,
LPDWORD lpNumberOfCharsWritten)
{
- return IntFillConsoleOutputCharacter(hConsoleOutput,
- &cCharacter,
- nLength,
- dwWriteCoord,
- lpNumberOfCharsWritten,
- FALSE);
+ return IntFillConsoleOutputCode(hConsoleOutput,
+ CODE_ASCII,
+ &cCharacter,
+ nLength,
+ dwWriteCoord,
+ lpNumberOfCharsWritten);
}
@@ -1321,28 +1334,12 @@
COORD dwWriteCoord,
LPDWORD lpNumberOfAttrsWritten)
{
- CSR_API_MESSAGE Request;
- NTSTATUS Status;
-
- Request.Data.FillOutputAttribRequest.ConsoleHandle = hConsoleOutput;
- Request.Data.FillOutputAttribRequest.Attribute = (CHAR)wAttribute;
- Request.Data.FillOutputAttribRequest.Coord = dwWriteCoord;
- Request.Data.FillOutputAttribRequest.Length = (WORD)nLength;
-
- Status = CsrClientCallServer(&Request,
- NULL,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, FILL_OUTPUT_ATTRIB),
- sizeof(CSR_API_MESSAGE));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
- {
- BaseSetLastNTError ( Status );
- return FALSE;
- }
-
- if (lpNumberOfAttrsWritten)
- *lpNumberOfAttrsWritten = nLength;
-
- return TRUE;
+ return IntFillConsoleOutputCode(hConsoleOutput,
+ CODE_ATTRIBUTE,
+ &wAttribute,
+ nLength,
+ dwWriteCoord,
+ lpNumberOfAttrsWritten);
}
/* EOF */
Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
==============================================================================
--- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original)
+++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sun Nov 18
17:06:48 2012
@@ -27,7 +27,7 @@
ConsolepWriteConsoleOutput,
ConsolepReadConsoleOutputString,
// ConsolepWriteConsoleOutputString,
- // ConsolepFillConsoleOutput,
+ ConsolepFillConsoleOutput,
ConsolepGetMode,
// ConsolepGetNumberOfFonts,
ConsolepGetNumberOfInputEvents,
@@ -187,28 +187,6 @@
{
HANDLE ConsoleHandle;
BOOL Unicode;
- union
- {
- CHAR AsciiChar;
- WCHAR UnicodeChar;
- } Char;
- COORD Position;
- WORD Length;
- ULONG NrCharactersWritten;
-} CSRSS_FILL_OUTPUT, *PCSRSS_FILL_OUTPUT;
-
-typedef struct
-{
- HANDLE ConsoleHandle;
- CHAR Attribute;
- COORD Coord;
- WORD Length;
-} CSRSS_FILL_OUTPUT_ATTRIB, *PCSRSS_FILL_OUTPUT_ATTRIB;
-
-typedef struct
-{
- HANDLE ConsoleHandle;
- BOOL Unicode;
WORD Length;
COORD Coord;
COORD EndCoord;
@@ -303,8 +281,7 @@
typedef struct
{
- HANDLE ConsoleHandle;
- CODE_TYPE CodeType;
+ HANDLE ConsoleHandle;
DWORD NumCodesToRead;
COORD ReadCoord;
@@ -312,6 +289,7 @@
DWORD CodesRead;
+ CODE_TYPE CodeType;
union
{
PVOID pCode;
@@ -321,6 +299,23 @@
} pCode; // Either a pointer to a character or to an attribute.
} CSRSS_READ_CONSOLE_OUTPUT_CODE, *PCSRSS_READ_CONSOLE_OUTPUT_CODE;
+typedef struct
+{
+ HANDLE ConsoleHandle;
+
+ CODE_TYPE CodeType;
+ union
+ {
+ CHAR AsciiChar;
+ WCHAR UnicodeChar;
+ WORD Attribute;
+ } Code; // Either a character or an attribute.
+
+ COORD Coord;
+ ULONG Length;
+
+ ULONG NrCharactersWritten; // FIXME: Only for chars, is it removable ?
+} CSRSS_FILL_OUTPUT, *PCSRSS_FILL_OUTPUT;
typedef struct
{
@@ -595,7 +590,6 @@
CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest;
CSRSS_FILL_OUTPUT FillOutputRequest;
- CSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest;
CSRSS_SET_ATTRIB SetAttribRequest;
/* Aliases */
Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Sun Nov 18 17:06:48
2012
@@ -991,45 +991,63 @@
return STATUS_SUCCESS;
}
-CSR_API(CsrFillOutputChar)
+CSR_API(SrvFillConsoleOutput)
{
NTSTATUS Status;
PCSRSS_FILL_OUTPUT FillOutputRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputRequest;
PCSRSS_CONSOLE Console;
PCSRSS_SCREEN_BUFFER Buff;
- DWORD X, Y, Length, Written = 0;
- CHAR Char;
+ DWORD X, Y, Length, Start; // , Written = 0;
+ USHORT CodeType;
+ BYTE Code;
PBYTE Buffer;
SMALL_RECT UpdateRect;
- DPRINT("CsrFillOutputChar\n");
-
- Status = ConioLockScreenBuffer(CsrGetClientThread()->Process,
FillOutputRequest->ConsoleHandle, &Buff, GENERIC_WRITE);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
+ DPRINT("SrvFillConsoleOutput\n");
+
+ Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
FillOutputRequest->ConsoleHandle, &Buff, GENERIC_WRITE);
+ if (!NT_SUCCESS(Status)) return Status;
+
Console = Buff->Header.Console;
- X = FillOutputRequest->Position.X;
- Y = (FillOutputRequest->Position.Y + Buff->VirtualY) % Buff->MaxY;
- Buffer = &Buff->Buffer[2 * (Y * Buff->MaxX + X)];
- if(FillOutputRequest->Unicode)
- ConsoleUnicodeCharToAnsiChar(Console, &Char,
&FillOutputRequest->Char.UnicodeChar);
- else
- Char = FillOutputRequest->Char.AsciiChar;
+ CodeType = FillOutputRequest->CodeType;
+
+ X = FillOutputRequest->Coord.X;
+ Y = (FillOutputRequest->Coord.Y + Buff->VirtualY) % Buff->MaxY;
Length = FillOutputRequest->Length;
+ Start = 2 * (Y * Buff->MaxX + X) + (CodeType == CODE_ATTRIBUTE ? 1 : 0);
+ Buffer = &Buff->Buffer[Start];
+
+ switch (CodeType)
+ {
+ case CODE_ASCII:
+ Code = (BYTE)FillOutputRequest->Code.AsciiChar;
+ break;
+
+ case CODE_UNICODE:
+ ConsoleUnicodeCharToAnsiChar(Console, (PCHAR)&Code,
&FillOutputRequest->Code.UnicodeChar);
+ break;
+
+ case CODE_ATTRIBUTE:
+ Code = (BYTE)FillOutputRequest->Code.Attribute;
+ break;
+
+ default:
+ ConioUnlockScreenBuffer(Buff);
+ return STATUS_INVALID_PARAMETER;
+ }
+
while (Length--)
{
- *Buffer = Char;
+ *Buffer = Code;
Buffer += 2;
- Written++;
+ // Written++;
if (++X == Buff->MaxX)
{
if (++Y == Buff->MaxY)
{
Y = 0;
- Buffer = Buff->Buffer;
+ Buffer = Buff->Buffer + (CodeType == CODE_ATTRIBUTE ? 1 : 0);
}
X = 0;
}
@@ -1037,66 +1055,16 @@
if (Buff == Console->ActiveBuffer)
{
- ConioComputeUpdateRect(Buff, &UpdateRect,
&FillOutputRequest->Position,
+ ConioComputeUpdateRect(Buff, &UpdateRect, &FillOutputRequest->Coord,
FillOutputRequest->Length);
ConioDrawRegion(Console, &UpdateRect);
}
ConioUnlockScreenBuffer(Buff);
+/*
Length = FillOutputRequest->Length;
FillOutputRequest->NrCharactersWritten = Length;
- return STATUS_SUCCESS;
-}
-
-CSR_API(CsrFillOutputAttrib)
-{
- PCSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputAttribRequest;
- PCSRSS_SCREEN_BUFFER Buff;
- PUCHAR Buffer;
- NTSTATUS Status;
- int X, Y, Length;
- UCHAR Attr;
- SMALL_RECT UpdateRect;
- PCSRSS_CONSOLE Console;
-
- DPRINT("CsrFillOutputAttrib\n");
-
- Status = ConioLockScreenBuffer(CsrGetClientThread()->Process,
FillOutputAttribRequest->ConsoleHandle, &Buff, GENERIC_WRITE);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
- Console = Buff->Header.Console;
-
- X = FillOutputAttribRequest->Coord.X;
- Y = (FillOutputAttribRequest->Coord.Y + Buff->VirtualY) % Buff->MaxY;
- Length = FillOutputAttribRequest->Length;
- Attr = FillOutputAttribRequest->Attribute;
- Buffer = &Buff->Buffer[(Y * Buff->MaxX * 2) + (X * 2) + 1];
- while (Length--)
- {
- *Buffer = Attr;
- Buffer += 2;
- if (++X == Buff->MaxX)
- {
- if (++Y == Buff->MaxY)
- {
- Y = 0;
- Buffer = Buff->Buffer + 1;
- }
- X = 0;
- }
- }
-
- if (Buff == Console->ActiveBuffer)
- {
- ConioComputeUpdateRect(Buff, &UpdateRect,
&FillOutputAttribRequest->Coord,
- FillOutputAttribRequest->Length);
- ConioDrawRegion(Console, &UpdateRect);
- }
-
- ConioUnlockScreenBuffer(Buff);
-
+*/
return STATUS_SUCCESS;
}