Author: hbelusca
Date: Sun Jun 23 17:19:08 2013
New Revision: 59321
URL:
http://svn.reactos.org/svn/reactos?rev=59321&view=rev
Log:
[CONSRV]
Continue to move some (text) functions to condrv.
Modified:
trunk/reactos/win32ss/user/consrv/condrv/text.c
trunk/reactos/win32ss/user/consrv/conoutput.c
Modified: trunk/reactos/win32ss/user/consrv/condrv/text.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/condrv…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/condrv/text.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/condrv/text.c [iso-8859-1] Sun Jun 23 17:19:08 2013
@@ -756,22 +756,33 @@
return STATUS_NOT_IMPLEMENTED;
}
-CSR_API(SrvReadConsoleOutputString)
-{
- NTSTATUS Status;
- PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadOutputCodeRequest;
- PCONSOLE Console;
- PTEXTMODE_SCREEN_BUFFER Buff;
- USHORT CodeType;
+NTSTATUS NTAPI
+ConDrvReadConsoleOutputString(IN PCONSOLE Console,
+ IN PTEXTMODE_SCREEN_BUFFER Buffer,
+ IN CODE_TYPE CodeType,
+ OUT PVOID StringBuffer,
+ IN ULONG NumCodesToRead,
+ IN PCOORD ReadCoord,
+ OUT PCOORD EndCoord,
+ OUT PULONG CodesRead)
+{
SHORT Xpos, Ypos;
PVOID ReadBuffer;
- DWORD i;
+ ULONG i;
ULONG CodeSize;
PCHAR_INFO Ptr;
- DPRINT("SrvReadConsoleOutputString\n");
-
- CodeType = ReadOutputCodeRequest->CodeType;
+ if (Console == NULL || Buffer == NULL ||
+ ReadCoord == NULL || EndCoord == NULL || CodesRead == NULL)
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Validity checks */
+ ASSERT(Console == Buffer->Header.Console);
+ ASSERT( (StringBuffer != NULL && NumCodesToRead >= 0) ||
+ (StringBuffer == NULL && NumCodesToRead == 0) );
+
switch (CodeType)
{
case CODE_ASCII:
@@ -790,26 +801,9 @@
return STATUS_INVALID_PARAMETER;
}
- if (!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&ReadOutputCodeRequest->pCode.pCode,
- ReadOutputCodeRequest->NumCodesToRead,
- CodeSize))
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- Status =
ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- ReadOutputCodeRequest->OutputHandle,
- &Buff,
- GENERIC_READ,
- TRUE);
- if (!NT_SUCCESS(Status)) return Status;
-
- Console = Buff->Header.Console;
-
- ReadBuffer = ReadOutputCodeRequest->pCode.pCode;
- Xpos = ReadOutputCodeRequest->ReadCoord.X;
- Ypos = (ReadOutputCodeRequest->ReadCoord.Y + Buff->VirtualY) %
Buff->ScreenBufferSize.Y;
+ ReadBuffer = StringBuffer;
+ Xpos = ReadCoord->X;
+ Ypos = (ReadCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
/*
* MSDN (ReadConsoleOutputAttribute and ReadConsoleOutputCharacter) :
@@ -824,11 +818,11 @@
* TODO: Do NOT loop up to NumCodesToRead, but stop before
* if we are going to overflow...
*/
- // Ptr = ConioCoordToPointer(Buff, Xpos, Ypos); // Doesn't work
- for (i = 0; i < min(ReadOutputCodeRequest->NumCodesToRead,
Buff->ScreenBufferSize.X * Buff->ScreenBufferSize.Y); ++i)
- {
- // Ptr = ConioCoordToPointer(Buff, Xpos, Ypos); // Doesn't work either
- Ptr = &Buff->Buffer[Xpos + Ypos * Buff->ScreenBufferSize.X];
+ // Ptr = ConioCoordToPointer(Buffer, Xpos, Ypos); // Doesn't work
+ for (i = 0; i < min(NumCodesToRead, Buffer->ScreenBufferSize.X *
Buffer->ScreenBufferSize.Y); ++i)
+ {
+ // Ptr = ConioCoordToPointer(Buffer, Xpos, Ypos); // Doesn't work either
+ Ptr = &Buffer->Buffer[Xpos + Ypos * Buffer->ScreenBufferSize.X];
switch (CodeType)
{
@@ -849,12 +843,12 @@
Xpos++;
- if (Xpos == Buff->ScreenBufferSize.X)
+ if (Xpos == Buffer->ScreenBufferSize.X)
{
Xpos = 0;
Ypos++;
- if (Ypos == Buff->ScreenBufferSize.Y)
+ if (Ypos == Buffer->ScreenBufferSize.Y)
{
Ypos = 0;
}
@@ -876,34 +870,44 @@
// break;
// }
- ReadOutputCodeRequest->EndCoord.X = Xpos;
- ReadOutputCodeRequest->EndCoord.Y = (Ypos - Buff->VirtualY +
Buff->ScreenBufferSize.Y) % Buff->ScreenBufferSize.Y;
-
- ConSrvReleaseScreenBuffer(Buff, TRUE);
-
- ReadOutputCodeRequest->CodesRead = (DWORD)((ULONG_PTR)ReadBuffer -
(ULONG_PTR)ReadOutputCodeRequest->pCode.pCode) / CodeSize;
- // <= ReadOutputCodeRequest->NumCodesToRead
+ EndCoord->X = Xpos;
+ EndCoord->Y = (Ypos - Buffer->VirtualY + Buffer->ScreenBufferSize.Y) %
Buffer->ScreenBufferSize.Y;
+
+ *CodesRead = (ULONG)((ULONG_PTR)ReadBuffer - (ULONG_PTR)StringBuffer) / CodeSize;
+ // <= NumCodesToRead
return STATUS_SUCCESS;
}
-CSR_API(SrvWriteConsoleOutputString)
-{
- NTSTATUS Status;
- PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteOutputCodeRequest;
- PCONSOLE Console;
- PTEXTMODE_SCREEN_BUFFER Buff;
- USHORT CodeType;
- PVOID ReadBuffer = NULL;
+NTSTATUS NTAPI
+ConDrvWriteConsoleOutputString(IN PCONSOLE Console,
+ IN PTEXTMODE_SCREEN_BUFFER Buffer,
+ IN CODE_TYPE CodeType,
+ IN PVOID StringBuffer,
+ IN ULONG NumCodesToWrite,
+ IN PCOORD WriteCoord /*,
+ OUT PCOORD EndCoord,
+ OUT PULONG CodesWritten */)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ PVOID WriteBuffer = NULL;
PWCHAR tmpString = NULL;
DWORD X, Y, Length; // , Written = 0;
ULONG CodeSize;
SMALL_RECT UpdateRect;
PCHAR_INFO Ptr;
- DPRINT("SrvWriteConsoleOutputString\n");
-
- CodeType = WriteOutputCodeRequest->CodeType;
+ if (Console == NULL || Buffer == NULL ||
+ WriteCoord == NULL /* || EndCoord == NULL || CodesWritten == NULL */)
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* Validity checks */
+ ASSERT(Console == Buffer->Header.Console);
+ ASSERT( (StringBuffer != NULL && NumCodesToWrite >= 0) ||
+ (StringBuffer == NULL && NumCodesToWrite == 0) );
+
switch (CodeType)
{
case CODE_ASCII:
@@ -922,37 +926,20 @@
return STATUS_INVALID_PARAMETER;
}
- if (!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&WriteOutputCodeRequest->pCode.pCode,
- WriteOutputCodeRequest->Length,
- CodeSize))
- {
- return STATUS_INVALID_PARAMETER;
- }
-
- Status =
ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- WriteOutputCodeRequest->OutputHandle,
- &Buff,
- GENERIC_WRITE,
- TRUE);
- if (!NT_SUCCESS(Status)) return Status;
-
- Console = Buff->Header.Console;
-
if (CodeType == CODE_ASCII)
{
/* Convert the ASCII string into Unicode before writing it to the console */
Length = MultiByteToWideChar(Console->OutputCodePage, 0,
- WriteOutputCodeRequest->pCode.AsciiChar,
- WriteOutputCodeRequest->Length,
+ (PCHAR)StringBuffer,
+ NumCodesToWrite,
NULL, 0);
- tmpString = ReadBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length *
sizeof(WCHAR));
- if (ReadBuffer)
+ tmpString = WriteBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length *
sizeof(WCHAR));
+ if (WriteBuffer)
{
MultiByteToWideChar(Console->OutputCodePage, 0,
- WriteOutputCodeRequest->pCode.AsciiChar,
- WriteOutputCodeRequest->Length,
- (PWCHAR)ReadBuffer, Length);
+ (PCHAR)StringBuffer,
+ NumCodesToWrite,
+ (PWCHAR)WriteBuffer, Length);
}
else
{
@@ -962,124 +949,120 @@
else
{
/* For CODE_UNICODE or CODE_ATTRIBUTE, we are already OK */
- ReadBuffer = WriteOutputCodeRequest->pCode.pCode;
- }
-
- if (ReadBuffer == NULL || !NT_SUCCESS(Status)) goto Cleanup;
-
- X = WriteOutputCodeRequest->Coord.X;
- Y = (WriteOutputCodeRequest->Coord.Y + Buff->VirtualY) %
Buff->ScreenBufferSize.Y;
- Length = WriteOutputCodeRequest->Length;
- // Ptr = ConioCoordToPointer(Buff, X, Y); // Doesn't work
- // Ptr = &Buff->Buffer[X + Y * Buff->ScreenBufferSize.X]; // May work
+ WriteBuffer = StringBuffer;
+ }
+
+ if (WriteBuffer == NULL || !NT_SUCCESS(Status)) goto Cleanup;
+
+ X = WriteCoord->X;
+ Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
+ Length = NumCodesToWrite;
+ // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
+ // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
while (Length--)
{
- // Ptr = ConioCoordToPointer(Buff, X, Y); // Doesn't work either
- Ptr = &Buff->Buffer[X + Y * Buff->ScreenBufferSize.X];
+ // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
+ Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
switch (CodeType)
{
case CODE_ASCII:
case CODE_UNICODE:
- Ptr->Char.UnicodeChar = *(PWCHAR)ReadBuffer;
+ Ptr->Char.UnicodeChar = *(PWCHAR)WriteBuffer;
break;
case CODE_ATTRIBUTE:
- Ptr->Attributes = *(PWORD)ReadBuffer;
+ Ptr->Attributes = *(PWORD)WriteBuffer;
break;
}
- ReadBuffer = (PVOID)((ULONG_PTR)ReadBuffer + CodeSize);
+ WriteBuffer = (PVOID)((ULONG_PTR)WriteBuffer + CodeSize);
// ++Ptr;
// Written++;
- if (++X == Buff->ScreenBufferSize.X)
+ if (++X == Buffer->ScreenBufferSize.X)
{
X = 0;
- if (++Y == Buff->ScreenBufferSize.Y)
+ if (++Y == Buffer->ScreenBufferSize.Y)
{
Y = 0;
}
}
}
- if ((PCONSOLE_SCREEN_BUFFER)Buff == Console->ActiveBuffer)
- {
- ConioComputeUpdateRect(Buff, &UpdateRect,
&WriteOutputCodeRequest->Coord,
- WriteOutputCodeRequest->Length);
+ if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
+ {
+ ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
ConioDrawRegion(Console, &UpdateRect);
}
- // WriteOutputCodeRequest->EndCoord.X = X;
- // WriteOutputCodeRequest->EndCoord.Y = (Y + Buff->ScreenBufferSize.Y -
Buff->VirtualY) % Buff->ScreenBufferSize.Y;
+ // EndCoord->X = X;
+ // EndCoord->Y = (Y + Buffer->ScreenBufferSize.Y - Buffer->VirtualY) %
Buffer->ScreenBufferSize.Y;
Cleanup:
- if (tmpString)
- RtlFreeHeap(RtlGetProcessHeap(), 0, tmpString);
-
- ConSrvReleaseScreenBuffer(Buff, TRUE);
-
- // WriteOutputCodeRequest->NrCharactersWritten = Written;
+ if (tmpString) RtlFreeHeap(RtlGetProcessHeap(), 0, tmpString);
+
+ // CodesWritten = Written;
return Status;
}
-CSR_API(SrvFillConsoleOutput)
-{
- NTSTATUS Status;
- PCONSOLE_FILLOUTPUTCODE FillOutputRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputRequest;
- PCONSOLE Console;
- PTEXTMODE_SCREEN_BUFFER Buff;
+NTSTATUS NTAPI
+ConDrvFillConsoleOutput(IN PCONSOLE Console,
+ IN PTEXTMODE_SCREEN_BUFFER Buffer,
+ IN CODE_TYPE CodeType,
+ IN PVOID Code,
+ IN ULONG NumCodesToWrite,
+ IN PCOORD WriteCoord /*,
+ OUT PULONG CodesWritten */)
+{
DWORD X, Y, Length; // , Written = 0;
- USHORT CodeType;
- PVOID Code = NULL;
PCHAR_INFO Ptr;
SMALL_RECT UpdateRect;
- DPRINT("SrvFillConsoleOutput\n");
-
- CodeType = FillOutputRequest->CodeType;
- if ( (CodeType != CODE_ASCII ) &&
- (CodeType != CODE_UNICODE ) &&
- (CodeType != CODE_ATTRIBUTE) )
+ if (Console == NULL || Buffer == NULL || Code == NULL ||
+ WriteCoord == NULL /* || CodesWritten == NULL */)
{
return STATUS_INVALID_PARAMETER;
}
- Status =
ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- FillOutputRequest->OutputHandle,
- &Buff,
- GENERIC_WRITE,
- TRUE);
- if (!NT_SUCCESS(Status)) return Status;
-
- Console = Buff->Header.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,
&FillOutputRequest->Code.UnicodeChar, &FillOutputRequest->Code.AsciiChar);
+ ConsoleAnsiCharToUnicodeChar(Console, &Code->UnicodeChar,
&Code->AsciiChar);
/* Fall through */
case CODE_UNICODE:
- Code = &FillOutputRequest->Code.UnicodeChar;
+ Code = &Code->UnicodeChar;
break;
case CODE_ATTRIBUTE:
- Code = &FillOutputRequest->Code.Attribute;
+ Code = &Code->Attribute;
break;
}
-
- X = FillOutputRequest->Coord.X;
- Y = (FillOutputRequest->Coord.Y + Buff->VirtualY) %
Buff->ScreenBufferSize.Y;
- Length = FillOutputRequest->Length;
- // Ptr = ConioCoordToPointer(Buff, X, Y); // Doesn't work
- // Ptr = &Buff->Buffer[X + Y * Buff->ScreenBufferSize.X]; // May work
+#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);
+ }
+#endif
+
+ X = WriteCoord->X;
+ Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
+ Length = NumCodesToWrite;
+ // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
+ // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
while (Length--)
{
- // Ptr = ConioCoordToPointer(Buff, X, Y); // Doesn't work either
- Ptr = &Buff->Buffer[X + Y * Buff->ScreenBufferSize.X];
+ // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
+ Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
switch (CodeType)
{
@@ -1095,31 +1078,28 @@
// ++Ptr;
// Written++;
- if (++X == Buff->ScreenBufferSize.X)
+ if (++X == Buffer->ScreenBufferSize.X)
{
X = 0;
- if (++Y == Buff->ScreenBufferSize.Y)
+ if (++Y == Buffer->ScreenBufferSize.Y)
{
Y = 0;
}
}
}
- if ((PCONSOLE_SCREEN_BUFFER)Buff == Console->ActiveBuffer)
- {
- ConioComputeUpdateRect(Buff, &UpdateRect, &FillOutputRequest->Coord,
- FillOutputRequest->Length);
+ if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
+ {
+ ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
ConioDrawRegion(Console, &UpdateRect);
}
- ConSrvReleaseScreenBuffer(Buff, TRUE);
-/*
- Length = FillOutputRequest->Length;
- FillOutputRequest->NrCharactersWritten = Length;
-*/
+ // CodesWritten = Written; // NumCodesToWrite;
return STATUS_SUCCESS;
}
+
+
CSR_API(SrvGetConsoleScreenBufferInfo)
{
Modified: trunk/reactos/win32ss/user/consrv/conoutput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/consrv/conout…
==============================================================================
--- trunk/reactos/win32ss/user/consrv/conoutput.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/consrv/conoutput.c [iso-8859-1] Sun Jun 23 17:19:08 2013
@@ -515,25 +515,25 @@
return Status;
}
-#if 0000
-
+NTSTATUS NTAPI
+ConDrvReadConsoleOutputString(IN PCONSOLE Console,
+ IN PTEXTMODE_SCREEN_BUFFER Buffer,
+ IN CODE_TYPE CodeType,
+ OUT PVOID StringBuffer,
+ IN ULONG NumCodesToRead,
+ IN PCOORD ReadCoord,
+ OUT PCOORD EndCoord,
+ OUT PULONG CodesRead);
CSR_API(SrvReadConsoleOutputString)
{
NTSTATUS Status;
PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadOutputCodeRequest;
- PCONSOLE Console;
- PTEXTMODE_SCREEN_BUFFER Buff;
- USHORT CodeType;
- SHORT Xpos, Ypos;
- PVOID ReadBuffer;
- DWORD i;
+ PTEXTMODE_SCREEN_BUFFER Buffer;
ULONG CodeSize;
- PCHAR_INFO Ptr;
DPRINT("SrvReadConsoleOutputString\n");
- CodeType = ReadOutputCodeRequest->CodeType;
- switch (CodeType)
+ switch (ReadOutputCodeRequest->CodeType)
{
case CODE_ASCII:
CodeSize = sizeof(CHAR);
@@ -561,111 +561,41 @@
Status =
ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ReadOutputCodeRequest->OutputHandle,
- &Buff,
- GENERIC_READ,
- TRUE);
- if (!NT_SUCCESS(Status)) return Status;
-
- Console = Buff->Header.Console;
-
- ReadBuffer = ReadOutputCodeRequest->pCode.pCode;
- Xpos = ReadOutputCodeRequest->ReadCoord.X;
- Ypos = (ReadOutputCodeRequest->ReadCoord.Y + Buff->VirtualY) %
Buff->ScreenBufferSize.Y;
-
- /*
- * MSDN (ReadConsoleOutputAttribute and ReadConsoleOutputCharacter) :
- *
- * If the number of attributes (resp. characters) to be read from extends
- * beyond the end of the specified screen buffer row, attributes (resp.
- * characters) are read from the next row. If the number of attributes
- * (resp. characters) to be read from extends beyond the end of the console
- * screen buffer, attributes (resp. characters) up to the end of the console
- * screen buffer are read.
- *
- * TODO: Do NOT loop up to NumCodesToRead, but stop before
- * if we are going to overflow...
- */
- // Ptr = ConioCoordToPointer(Buff, Xpos, Ypos); // Doesn't work
- for (i = 0; i < min(ReadOutputCodeRequest->NumCodesToRead,
Buff->ScreenBufferSize.X * Buff->ScreenBufferSize.Y); ++i)
- {
- // Ptr = ConioCoordToPointer(Buff, Xpos, Ypos); // Doesn't work either
- Ptr = &Buff->Buffer[Xpos + Ypos * Buff->ScreenBufferSize.X];
-
- switch (CodeType)
- {
- case CODE_ASCII:
- ConsoleUnicodeCharToAnsiChar(Console, (PCHAR)ReadBuffer,
&Ptr->Char.UnicodeChar);
- break;
-
- case CODE_UNICODE:
- *(PWCHAR)ReadBuffer = Ptr->Char.UnicodeChar;
- break;
-
- case CODE_ATTRIBUTE:
- *(PWORD)ReadBuffer = Ptr->Attributes;
- break;
- }
- ReadBuffer = (PVOID)((ULONG_PTR)ReadBuffer + CodeSize);
- // ++Ptr;
-
- Xpos++;
-
- if (Xpos == Buff->ScreenBufferSize.X)
- {
- Xpos = 0;
- Ypos++;
-
- if (Ypos == Buff->ScreenBufferSize.Y)
- {
- Ypos = 0;
- }
- }
- }
-
- // switch (CodeType)
- // {
- // case CODE_UNICODE:
- // *(PWCHAR)ReadBuffer = 0;
- // break;
-
- // case CODE_ASCII:
- // *(PCHAR)ReadBuffer = 0;
- // break;
-
- // case CODE_ATTRIBUTE:
- // *(PWORD)ReadBuffer = 0;
- // break;
- // }
-
- ReadOutputCodeRequest->EndCoord.X = Xpos;
- ReadOutputCodeRequest->EndCoord.Y = (Ypos - Buff->VirtualY +
Buff->ScreenBufferSize.Y) % Buff->ScreenBufferSize.Y;
-
- ConSrvReleaseScreenBuffer(Buff, TRUE);
-
- ReadOutputCodeRequest->CodesRead = (DWORD)((ULONG_PTR)ReadBuffer -
(ULONG_PTR)ReadOutputCodeRequest->pCode.pCode) / CodeSize;
- // <= ReadOutputCodeRequest->NumCodesToRead
-
- return STATUS_SUCCESS;
-}
-
+ &Buffer, GENERIC_READ, TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Status = ConDrvReadConsoleOutputString(Buffer->Header.Console,
+ Buffer,
+ ReadOutputCodeRequest->CodeType,
+ ReadOutputCodeRequest->pCode.pCode,
+ ReadOutputCodeRequest->NumCodesToRead,
+ &ReadOutputCodeRequest->ReadCoord,
+ &ReadOutputCodeRequest->EndCoord,
+ &ReadOutputCodeRequest->CodesRead);
+
+ ConSrvReleaseScreenBuffer(Buffer, TRUE);
+ return Status;
+}
+
+NTSTATUS NTAPI
+ConDrvWriteConsoleOutputString(IN PCONSOLE Console,
+ IN PTEXTMODE_SCREEN_BUFFER Buffer,
+ IN CODE_TYPE CodeType,
+ IN PVOID StringBuffer,
+ IN ULONG NumCodesToWrite,
+ IN PCOORD WriteCoord /*,
+ OUT PCOORD EndCoord,
+ OUT PULONG CodesWritten */);
CSR_API(SrvWriteConsoleOutputString)
{
NTSTATUS Status;
PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteOutputCodeRequest;
- PCONSOLE Console;
- PTEXTMODE_SCREEN_BUFFER Buff;
- USHORT CodeType;
- PVOID ReadBuffer = NULL;
- PWCHAR tmpString = NULL;
- DWORD X, Y, Length; // , Written = 0;
+ PTEXTMODE_SCREEN_BUFFER Buffer;
ULONG CodeSize;
- SMALL_RECT UpdateRect;
- PCHAR_INFO Ptr;
DPRINT("SrvWriteConsoleOutputString\n");
- CodeType = WriteOutputCodeRequest->CodeType;
- switch (CodeType)
+ switch (WriteOutputCodeRequest->CodeType)
{
case CODE_ASCII:
CodeSize = sizeof(CHAR);
@@ -693,113 +623,41 @@
Status =
ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
WriteOutputCodeRequest->OutputHandle,
- &Buff,
- GENERIC_WRITE,
- TRUE);
- if (!NT_SUCCESS(Status)) return Status;
-
- Console = Buff->Header.Console;
-
- if (CodeType == CODE_ASCII)
- {
- /* Convert the ASCII string into Unicode before writing it to the console */
- Length = MultiByteToWideChar(Console->OutputCodePage, 0,
- WriteOutputCodeRequest->pCode.AsciiChar,
- WriteOutputCodeRequest->Length,
- NULL, 0);
- tmpString = ReadBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length *
sizeof(WCHAR));
- if (ReadBuffer)
- {
- MultiByteToWideChar(Console->OutputCodePage, 0,
- WriteOutputCodeRequest->pCode.AsciiChar,
- WriteOutputCodeRequest->Length,
- (PWCHAR)ReadBuffer, Length);
- }
- else
- {
- Status = STATUS_NO_MEMORY;
- }
- }
- else
- {
- /* For CODE_UNICODE or CODE_ATTRIBUTE, we are already OK */
- ReadBuffer = WriteOutputCodeRequest->pCode.pCode;
- }
-
- if (ReadBuffer == NULL || !NT_SUCCESS(Status)) goto Cleanup;
-
- X = WriteOutputCodeRequest->Coord.X;
- Y = (WriteOutputCodeRequest->Coord.Y + Buff->VirtualY) %
Buff->ScreenBufferSize.Y;
- Length = WriteOutputCodeRequest->Length;
- // Ptr = ConioCoordToPointer(Buff, X, Y); // Doesn't work
- // Ptr = &Buff->Buffer[X + Y * Buff->ScreenBufferSize.X]; // May work
-
- while (Length--)
- {
- // Ptr = ConioCoordToPointer(Buff, X, Y); // Doesn't work either
- Ptr = &Buff->Buffer[X + Y * Buff->ScreenBufferSize.X];
-
- switch (CodeType)
- {
- case CODE_ASCII:
- case CODE_UNICODE:
- Ptr->Char.UnicodeChar = *(PWCHAR)ReadBuffer;
- break;
-
- case CODE_ATTRIBUTE:
- Ptr->Attributes = *(PWORD)ReadBuffer;
- break;
- }
- ReadBuffer = (PVOID)((ULONG_PTR)ReadBuffer + CodeSize);
- // ++Ptr;
-
- // Written++;
- if (++X == Buff->ScreenBufferSize.X)
- {
- X = 0;
-
- if (++Y == Buff->ScreenBufferSize.Y)
- {
- Y = 0;
- }
- }
- }
-
- if ((PCONSOLE_SCREEN_BUFFER)Buff == Console->ActiveBuffer)
- {
- ConioComputeUpdateRect(Buff, &UpdateRect,
&WriteOutputCodeRequest->Coord,
- WriteOutputCodeRequest->Length);
- ConioDrawRegion(Console, &UpdateRect);
- }
-
- // WriteOutputCodeRequest->EndCoord.X = X;
- // WriteOutputCodeRequest->EndCoord.Y = (Y + Buff->ScreenBufferSize.Y -
Buff->VirtualY) % Buff->ScreenBufferSize.Y;
-
-Cleanup:
- if (tmpString)
- RtlFreeHeap(RtlGetProcessHeap(), 0, tmpString);
-
- ConSrvReleaseScreenBuffer(Buff, TRUE);
+ &Buffer, GENERIC_WRITE, TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Status = ConDrvWriteConsoleOutputString(Buffer->Header.Console,
+ Buffer,
+ WriteOutputCodeRequest->CodeType,
+ WriteOutputCodeRequest->pCode.pCode,
+ WriteOutputCodeRequest->Length, //
NumCodesToWrite,
+ &WriteOutputCodeRequest->Coord /*, //
WriteCoord,
+ &WriteOutputCodeRequest->EndCoord,
+
&WriteOutputCodeRequest->NrCharactersWritten */);
// WriteOutputCodeRequest->NrCharactersWritten = Written;
- return Status;
-}
-
+
+ ConSrvReleaseScreenBuffer(Buffer, TRUE);
+ return Status;
+}
+
+NTSTATUS NTAPI
+ConDrvFillConsoleOutput(IN PCONSOLE Console,
+ IN PTEXTMODE_SCREEN_BUFFER Buffer,
+ IN CODE_TYPE CodeType,
+ IN PVOID Code,
+ IN ULONG NumCodesToWrite,
+ IN PCOORD WriteCoord /*,
+ OUT PULONG CodesWritten */);
CSR_API(SrvFillConsoleOutput)
{
NTSTATUS Status;
PCONSOLE_FILLOUTPUTCODE FillOutputRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputRequest;
- PCONSOLE Console;
- PTEXTMODE_SCREEN_BUFFER Buff;
- DWORD X, Y, Length; // , Written = 0;
- USHORT CodeType;
- PVOID Code = NULL;
- PCHAR_INFO Ptr;
- SMALL_RECT UpdateRect;
+ PTEXTMODE_SCREEN_BUFFER Buffer;
+ USHORT CodeType = FillOutputRequest->CodeType;
DPRINT("SrvFillConsoleOutput\n");
- CodeType = FillOutputRequest->CodeType;
if ( (CodeType != CODE_ASCII ) &&
(CodeType != CODE_UNICODE ) &&
(CodeType != CODE_ATTRIBUTE) )
@@ -809,78 +667,24 @@
Status =
ConSrvGetTextModeBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
FillOutputRequest->OutputHandle,
- &Buff,
- GENERIC_WRITE,
- TRUE);
- if (!NT_SUCCESS(Status)) return Status;
-
- Console = Buff->Header.Console;
-
- switch (CodeType)
- {
- case CODE_ASCII:
- /* On-place conversion from the ASCII char to the UNICODE char */
- ConsoleAnsiCharToUnicodeChar(Console,
&FillOutputRequest->Code.UnicodeChar, &FillOutputRequest->Code.AsciiChar);
- /* Fall through */
- case CODE_UNICODE:
- Code = &FillOutputRequest->Code.UnicodeChar;
- break;
-
- case CODE_ATTRIBUTE:
- Code = &FillOutputRequest->Code.Attribute;
- break;
- }
-
- X = FillOutputRequest->Coord.X;
- Y = (FillOutputRequest->Coord.Y + Buff->VirtualY) %
Buff->ScreenBufferSize.Y;
- Length = FillOutputRequest->Length;
- // Ptr = ConioCoordToPointer(Buff, X, Y); // Doesn't work
- // Ptr = &Buff->Buffer[X + Y * Buff->ScreenBufferSize.X]; // May work
-
- while (Length--)
- {
- // Ptr = ConioCoordToPointer(Buff, X, Y); // Doesn't work either
- Ptr = &Buff->Buffer[X + Y * Buff->ScreenBufferSize.X];
-
- switch (CodeType)
- {
- case CODE_ASCII:
- case CODE_UNICODE:
- Ptr->Char.UnicodeChar = *(PWCHAR)Code;
- break;
-
- case CODE_ATTRIBUTE:
- Ptr->Attributes = *(PWORD)Code;
- break;
- }
- // ++Ptr;
-
- // Written++;
- if (++X == Buff->ScreenBufferSize.X)
- {
- X = 0;
-
- if (++Y == Buff->ScreenBufferSize.Y)
- {
- Y = 0;
- }
- }
- }
-
- if ((PCONSOLE_SCREEN_BUFFER)Buff == Console->ActiveBuffer)
- {
- ConioComputeUpdateRect(Buff, &UpdateRect, &FillOutputRequest->Coord,
- FillOutputRequest->Length);
- ConioDrawRegion(Console, &UpdateRect);
- }
-
- ConSrvReleaseScreenBuffer(Buff, TRUE);
-/*
- Length = FillOutputRequest->Length;
- FillOutputRequest->NrCharactersWritten = Length;
-*/
- return STATUS_SUCCESS;
-}
+ &Buffer, GENERIC_WRITE, TRUE);
+ if (!NT_SUCCESS(Status)) return Status;
+
+ Status = ConDrvFillConsoleOutput(Buffer->Header.Console,
+ Buffer,
+ CodeType,
+ &FillOutputRequest->Code,
+ FillOutputRequest->Length, // NumCodesToWrite,
+ &FillOutputRequest->Coord /*, // WriteCoord,
+ &FillOutputRequest->NrCharactersWritten */);
+
+ // FillOutputRequest->NrCharactersWritten = Written;
+
+ ConSrvReleaseScreenBuffer(Buffer, TRUE);
+ return Status;
+}
+
+#if 0000
CSR_API(SrvGetConsoleScreenBufferInfo)
{