ReactOS  0.4.13-dev-563-g0561610
conoutput.c File Reference
#include "consrv.h"
#include <debug.h>
Include dependency graph for conoutput.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCHAR_CELL CharInfo, IN COORD CharInfoSize, IN PSMALL_RECT WriteRegion)
 
NTSTATUS NTAPI ConDrvInvalidateBitMapRect (IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN PSMALL_RECT Region)
 
 CSR_API (SrvInvalidateBitMapRect)
 
NTSTATUS NTAPI ConDrvSetConsolePalette (IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN HPALETTE PaletteHandle, IN UINT PaletteUsage)
 
 CSR_API (SrvSetConsolePalette)
 
NTSTATUS NTAPI ConDrvGetConsoleCursorInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCONSOLE_CURSOR_INFO CursorInfo)
 
 CSR_API (SrvGetConsoleCursorInfo)
 
NTSTATUS NTAPI ConDrvSetConsoleCursorInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCONSOLE_CURSOR_INFO CursorInfo)
 
 CSR_API (SrvSetConsoleCursorInfo)
 
NTSTATUS NTAPI ConDrvSetConsoleCursorPosition (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Position)
 
 CSR_API (SrvSetConsoleCursorPosition)
 
 CSR_API (SrvCreateConsoleScreenBuffer)
 
NTSTATUS NTAPI ConDrvSetConsoleActiveScreenBuffer (IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer)
 
 CSR_API (SrvSetConsoleActiveScreenBuffer)
 
static NTSTATUS DoWriteConsole (IN PCSR_API_MESSAGE ApiMessage, IN PCSR_THREAD ClientThread, IN BOOLEAN CreateWaitBlock OPTIONAL)
 
static BOOLEAN NTAPI WriteConsoleThread (IN PLIST_ENTRY WaitList, IN PCSR_THREAD WaitThread, IN PCSR_API_MESSAGE WaitApiMessage, IN PVOID WaitContext, IN PVOID WaitArgument1, IN PVOID WaitArgument2, IN ULONG WaitFlags)
 
NTSTATUS NTAPI ConDrvWriteConsole (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN BOOLEAN Unicode, IN PVOID StringBuffer, IN ULONG NumCharsToWrite, OUT PULONG NumCharsWritten OPTIONAL)
 
NTSTATUS NTAPI ConDrvReadConsoleOutput (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, OUT PCHAR_INFO CharInfo, IN OUT PSMALL_RECT ReadRegion)
 
 CSR_API (SrvReadConsoleOutput)
 
NTSTATUS NTAPI ConDrvWriteConsoleOutput (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PCHAR_INFO CharInfo, IN OUT PSMALL_RECT WriteRegion)
 
 CSR_API (SrvWriteConsoleOutput)
 
 CSR_API (SrvWriteConsole)
 
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 PULONG NumCodesRead OPTIONAL)
 
 CSR_API (SrvReadConsoleOutputString)
 
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 PULONG NumCodesWritten OPTIONAL)
 
 CSR_API (SrvWriteConsoleOutputString)
 
NTSTATUS NTAPI ConDrvFillConsoleOutput (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
 
 CSR_API (SrvFillConsoleOutput)
 
NTSTATUS NTAPI ConDrvGetConsoleScreenBufferInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCOORD ScreenBufferSize, OUT PCOORD CursorPosition, OUT PCOORD ViewOrigin, OUT PCOORD ViewSize, OUT PCOORD MaximumViewSize, OUT PWORD Attributes)
 
 CSR_API (SrvGetConsoleScreenBufferInfo)
 
NTSTATUS NTAPI ConDrvSetConsoleTextAttribute (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN WORD Attributes)
 
 CSR_API (SrvSetConsoleTextAttribute)
 
NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Size)
 
 CSR_API (SrvSetConsoleScreenBufferSize)
 
NTSTATUS NTAPI ConDrvScrollConsoleScreenBuffer (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PSMALL_RECT ScrollRectangle, IN BOOLEAN UseClipRectangle, IN PSMALL_RECT ClipRectangle OPTIONAL, IN PCOORD DestinationOrigin, IN CHAR_INFO FillChar)
 
 CSR_API (SrvScrollConsoleScreenBuffer)
 
NTSTATUS NTAPI ConDrvSetConsoleWindowInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Absolute, IN PSMALL_RECT WindowRect)
 
 CSR_API (SrvSetConsoleWindowInfo)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file conoutput.c.

Function Documentation

◆ ConDrvFillConsoleOutput()

NTSTATUS NTAPI ConDrvFillConsoleOutput ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN CODE_TYPE  CodeType,
IN CODE_ELEMENT  Code,
IN ULONG  NumCodesToWrite,
IN PCOORD  WriteCoord,
OUT PULONG NumCodesWritten  OPTIONAL 
)

Definition at line 978 of file text.c.

985 {
986  ULONG X, Y, Length; // , Written = 0;
987  PCHAR_INFO Ptr;
988 
989  if (Console == NULL || Buffer == NULL || WriteCoord == NULL)
990  {
992  }
993 
994  /* Validity check */
995  ASSERT(Console == Buffer->Header.Console);
996 
997  //
998  // FIXME: Make overflow checks on WriteCoord !!!!!!
999  //
1000 
1001  if (NumCodesWritten) *NumCodesWritten = 0;
1002 
1003  if (CodeType == CODE_ASCII)
1004  {
1005  /* Conversion from the ASCII char to the UNICODE char */
1006  CODE_ELEMENT tmp;
1008  Code = tmp;
1009  }
1010 
1011  X = WriteCoord->X;
1012  Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
1013  Length = NumCodesToWrite;
1014  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
1015  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
1016 
1017  while (Length--)
1018  {
1019  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
1020  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
1021 
1022  switch (CodeType)
1023  {
1024  case CODE_ASCII:
1025  case CODE_UNICODE:
1026  Ptr->Char.UnicodeChar = Code.UnicodeChar;
1027  break;
1028 
1029  case CODE_ATTRIBUTE:
1030  Ptr->Attributes = Code.Attribute;
1031  break;
1032  }
1033  // ++Ptr;
1034 
1035  // Written++;
1036  if (++X == Buffer->ScreenBufferSize.X)
1037  {
1038  X = 0;
1039 
1040  if (++Y == Buffer->ScreenBufferSize.Y)
1041  {
1042  Y = 0;
1043  }
1044  }
1045  }
1046 
1047  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1048  {
1050  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
1052  }
1053 
1054  if (NumCodesWritten) *NumCodesWritten = NumCodesToWrite; // Written;
1055  return STATUS_SUCCESS;
1056 }
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
WCHAR UnicodeChar
Definition: conmsg.h:525
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define TermDrawRegion(Console, Region)
Definition: term.h:22
static VOID ConioComputeUpdateRect(IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
Definition: text.c:160
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:29
while(1)
Definition: macro.lex.yy.c:740
X(int i_=0)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define Code
Definition: deflate.h:80
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define X(b, s)

Referenced by CSR_API().

◆ ConDrvGetConsoleCursorInfo()

NTSTATUS NTAPI ConDrvGetConsoleCursorInfo ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
OUT PCONSOLE_CURSOR_INFO  CursorInfo 
)

Definition at line 263 of file conoutput.c.

266 {
267  if (Console == NULL || Buffer == NULL || CursorInfo == NULL)
269 
270  /* Validity check */
271  ASSERT(Console == Buffer->Header.Console);
272 
273  *CursorInfo = Buffer->CursorInfo;
274  // CursorInfo->bVisible = Buffer->CursorInfo.bVisible;
275  // CursorInfo->dwSize = Buffer->CursorInfo.dwSize;
276 
277  return STATUS_SUCCESS;
278 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ ConDrvGetConsoleScreenBufferInfo()

NTSTATUS NTAPI ConDrvGetConsoleScreenBufferInfo ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
OUT PCOORD  ScreenBufferSize,
OUT PCOORD  CursorPosition,
OUT PCOORD  ViewOrigin,
OUT PCOORD  ViewSize,
OUT PCOORD  MaximumViewSize,
OUT PWORD  Attributes 
)

Definition at line 1059 of file text.c.

1067 {
1068  COORD LargestWindowSize;
1069 
1070  if (Console == NULL || Buffer == NULL || ScreenBufferSize == NULL ||
1071  CursorPosition == NULL || ViewOrigin == NULL || ViewSize == NULL ||
1072  MaximumViewSize == NULL || Attributes == NULL)
1073  {
1074  return STATUS_INVALID_PARAMETER;
1075  }
1076 
1077  /* Validity check */
1078  ASSERT(Console == Buffer->Header.Console);
1079 
1080  *ScreenBufferSize = Buffer->ScreenBufferSize;
1081  *CursorPosition = Buffer->CursorPosition;
1082  *ViewOrigin = Buffer->ViewOrigin;
1083  *ViewSize = Buffer->ViewSize;
1084  *Attributes = Buffer->ScreenDefaultAttrib;
1085 
1086  /*
1087  * Retrieve the largest possible console window size, taking
1088  * into account the size of the console screen buffer.
1089  */
1090  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1091  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1092  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1093  *MaximumViewSize = LargestWindowSize;
1094 
1095  return STATUS_SUCCESS;
1096 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: bl.h:1338
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:404
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG Y
Definition: bl.h:1341

Referenced by CSR_API().

◆ ConDrvInvalidateBitMapRect()

NTSTATUS NTAPI ConDrvInvalidateBitMapRect ( IN PCONSOLE  Console,
IN PCONSOLE_SCREEN_BUFFER  Buffer,
IN PSMALL_RECT  Region 
)

Definition at line 202 of file conoutput.c.

205 {
206  if (Console == NULL || Buffer == NULL || Region == NULL)
208 
209  /* Validity check */
210  ASSERT(Console == Buffer->Header.Console);
211 
212  /* If the output buffer is the current one, redraw the correct portion of the screen */
213  if (Buffer == Console->ActiveBuffer) TermDrawRegion(Console, Region);
214 
215  return STATUS_SUCCESS;
216 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TermDrawRegion(Console, Region)
Definition: term.h:22
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ ConDrvReadConsoleOutput()

NTSTATUS NTAPI ConDrvReadConsoleOutput ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN BOOLEAN  Unicode,
OUT PCHAR_INFO  CharInfo,
IN OUT PSMALL_RECT  ReadRegion 
)

Definition at line 467 of file text.c.

472 {
473  SHORT X, Y;
475  PCHAR_INFO CurCharInfo;
476  SMALL_RECT CapturedReadRegion;
477  PCHAR_INFO Ptr;
478 
479  if (Console == NULL || Buffer == NULL || CharInfo == NULL || ReadRegion == NULL)
480  {
482  }
483 
484  /* Validity check */
485  ASSERT(Console == Buffer->Header.Console);
486 
487  CapturedReadRegion = *ReadRegion;
488 
489  /* Make sure ReadRegion is inside the screen buffer */
491  Buffer->ScreenBufferSize.Y - 1,
492  Buffer->ScreenBufferSize.X - 1);
493  if (!ConioGetIntersection(&CapturedReadRegion, &ScreenBuffer, &CapturedReadRegion))
494  {
495  /*
496  * It is okay to have a ReadRegion completely outside
497  * the screen buffer. No data is read then.
498  */
499  return STATUS_SUCCESS;
500  }
501 
502  CurCharInfo = CharInfo;
503 
504  for (Y = CapturedReadRegion.Top; Y <= CapturedReadRegion.Bottom; ++Y)
505  {
506  Ptr = ConioCoordToPointer(Buffer, CapturedReadRegion.Left, Y);
507  for (X = CapturedReadRegion.Left; X <= CapturedReadRegion.Right; ++X)
508  {
509  if (Unicode)
510  {
511  CurCharInfo->Char.UnicodeChar = Ptr->Char.UnicodeChar;
512  }
513  else
514  {
515  // ConsoleOutputUnicodeToAnsiChar(Console, &CurCharInfo->Char.AsciiChar, &Ptr->Char.UnicodeChar);
516  WideCharToMultiByte(Console->OutputCodePage, 0, &Ptr->Char.UnicodeChar, 1,
517  &CurCharInfo->Char.AsciiChar, 1, NULL, NULL);
518  }
519  CurCharInfo->Attributes = Ptr->Attributes;
520  ++Ptr;
521  ++CurCharInfo;
522  }
523  }
524 
525  *ReadRegion = CapturedReadRegion;
526 
527  return STATUS_SUCCESS;
528 }
CHAR AsciiChar
Definition: wincon.h:170
#define WideCharToMultiByte
Definition: compat.h:101
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
WCHAR UnicodeChar
Definition: wincon.h:169
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
SHORT Bottom
Definition: blue.h:28
WORD Attributes
Definition: wincon.h:172
SHORT Top
Definition: blue.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union _CHAR_INFO::@3150 Char
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:150
SHORT Right
Definition: blue.h:27
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define X(b, s)

Referenced by CSR_API().

◆ ConDrvReadConsoleOutputString()

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 PULONG NumCodesRead  OPTIONAL 
)

Definition at line 727 of file text.c.

735 {
736  SHORT Xpos, Ypos;
738  ULONG i;
739  ULONG CodeSize;
740  PCHAR_INFO Ptr;
741 
742  if (Console == NULL || Buffer == NULL || ReadCoord == NULL /* || EndCoord == NULL */)
743  {
745  }
746 
747  /* Validity checks */
748  ASSERT(Console == Buffer->Header.Console);
749  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToRead == 0));
750 
751  //
752  // FIXME: Make overflow checks on ReadCoord !!!!!!
753  //
754 
755  if (NumCodesRead) *NumCodesRead = 0;
756 
757  switch (CodeType)
758  {
759  case CODE_ASCII:
760  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
761  break;
762 
763  case CODE_UNICODE:
764  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
765  break;
766 
767  case CODE_ATTRIBUTE:
768  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
769  break;
770 
771  default:
773  }
774 
776  Xpos = ReadCoord->X;
777  Ypos = (ReadCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
778 
779  /*
780  * MSDN (ReadConsoleOutputAttribute and ReadConsoleOutputCharacter) :
781  *
782  * If the number of attributes (resp. characters) to be read from extends
783  * beyond the end of the specified screen buffer row, attributes (resp.
784  * characters) are read from the next row. If the number of attributes
785  * (resp. characters) to be read from extends beyond the end of the console
786  * screen buffer, attributes (resp. characters) up to the end of the console
787  * screen buffer are read.
788  *
789  * TODO: Do NOT loop up to NumCodesToRead, but stop before
790  * if we are going to overflow...
791  */
792  // Ptr = ConioCoordToPointer(Buffer, Xpos, Ypos); // Doesn't work
793  for (i = 0; i < min(NumCodesToRead, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y); ++i)
794  {
795  // Ptr = ConioCoordToPointer(Buffer, Xpos, Ypos); // Doesn't work either
796  Ptr = &Buffer->Buffer[Xpos + Ypos * Buffer->ScreenBufferSize.X];
797 
798  switch (CodeType)
799  {
800  case CODE_ASCII:
802  break;
803 
804  case CODE_UNICODE:
805  *(PWCHAR)ReadBuffer = Ptr->Char.UnicodeChar;
806  break;
807 
808  case CODE_ATTRIBUTE:
809  *(PWORD)ReadBuffer = Ptr->Attributes;
810  break;
811  }
812  ReadBuffer = (PVOID)((ULONG_PTR)ReadBuffer + CodeSize);
813  // ++Ptr;
814 
815  Xpos++;
816 
817  if (Xpos == Buffer->ScreenBufferSize.X)
818  {
819  Xpos = 0;
820  Ypos++;
821 
822  if (Ypos == Buffer->ScreenBufferSize.Y)
823  {
824  Ypos = 0;
825  }
826  }
827  }
828 
829  // EndCoord->X = Xpos;
830  // EndCoord->Y = (Ypos - Buffer->VirtualY + Buffer->ScreenBufferSize.Y) % Buffer->ScreenBufferSize.Y;
831 
832  if (NumCodesRead)
833  *NumCodesRead = (ULONG)((ULONG_PTR)ReadBuffer - (ULONG_PTR)StringBuffer) / CodeSize;
834  // <= NumCodesToRead
835 
836  return STATUS_SUCCESS;
837 }
signed char * PCHAR
Definition: retypes.h:7
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define ReadBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:339
#define ConsoleOutputUnicodeToAnsiChar(Console, dChar, sWChar)
Definition: text.c:25
uint16_t * PWCHAR
Definition: typedefs.h:54
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
WORD * PWORD
Definition: pedump.c:67
#define for
Definition: utility.h:88
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
return STATUS_SUCCESS
Definition: btrfs.c:2777
WCHAR StringBuffer[156]
Definition: ldrinit.c:41

Referenced by CSR_API().

◆ ConDrvScrollConsoleScreenBuffer()

NTSTATUS NTAPI ConDrvScrollConsoleScreenBuffer ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN BOOLEAN  Unicode,
IN PSMALL_RECT  ScrollRectangle,
IN BOOLEAN  UseClipRectangle,
IN PSMALL_RECT ClipRectangle  OPTIONAL,
IN PCOORD  DestinationOrigin,
IN CHAR_INFO  FillChar 
)

Definition at line 1133 of file text.c.

1141 {
1142  COORD CapturedDestinationOrigin;
1144  SMALL_RECT SrcRegion;
1145  SMALL_RECT DstRegion;
1146  SMALL_RECT UpdateRegion;
1147  SMALL_RECT CapturedClipRectangle;
1148 
1149  if (Console == NULL || Buffer == NULL || ScrollRectangle == NULL ||
1150  (UseClipRectangle ? ClipRectangle == NULL : FALSE) || DestinationOrigin == NULL)
1151  {
1152  return STATUS_INVALID_PARAMETER;
1153  }
1154 
1155  /* Validity check */
1156  ASSERT(Console == Buffer->Header.Console);
1157 
1158  CapturedDestinationOrigin = *DestinationOrigin;
1159 
1160  /* Make sure the source rectangle is inside the screen buffer */
1161  ConioInitRect(&ScreenBuffer, 0, 0,
1162  Buffer->ScreenBufferSize.Y - 1,
1163  Buffer->ScreenBufferSize.X - 1);
1164  if (!ConioGetIntersection(&SrcRegion, &ScreenBuffer, ScrollRectangle))
1165  {
1166  return STATUS_SUCCESS;
1167  }
1168 
1169  /* If the source was clipped on the left or top, adjust the destination accordingly */
1170  if (ScrollRectangle->Left < 0)
1171  {
1172  CapturedDestinationOrigin.X -= ScrollRectangle->Left;
1173  }
1174  if (ScrollRectangle->Top < 0)
1175  {
1176  CapturedDestinationOrigin.Y -= ScrollRectangle->Top;
1177  }
1178 
1179  if (UseClipRectangle)
1180  {
1181  CapturedClipRectangle = *ClipRectangle;
1182  if (!ConioGetIntersection(&CapturedClipRectangle, &CapturedClipRectangle, &ScreenBuffer))
1183  {
1184  return STATUS_SUCCESS;
1185  }
1186  }
1187  else
1188  {
1189  CapturedClipRectangle = ScreenBuffer;
1190  }
1191 
1192  ConioInitRect(&DstRegion,
1193  CapturedDestinationOrigin.Y,
1194  CapturedDestinationOrigin.X,
1195  CapturedDestinationOrigin.Y + ConioRectHeight(&SrcRegion) - 1,
1196  CapturedDestinationOrigin.X + ConioRectWidth(&SrcRegion ) - 1);
1197 
1198  if (!Unicode)
1199  {
1200  WCHAR tmp;
1201  ConsoleOutputAnsiToUnicodeChar(Console, &tmp, &FillChar.Char.AsciiChar);
1202  FillChar.Char.UnicodeChar = tmp;
1203  }
1204 
1205  ConioMoveRegion(Buffer, &SrcRegion, &DstRegion, &CapturedClipRectangle, FillChar);
1206 
1207  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1208  {
1209  ConioGetUnion(&UpdateRegion, &SrcRegion, &DstRegion);
1210  if (ConioGetIntersection(&UpdateRegion, &UpdateRegion, &CapturedClipRectangle))
1211  {
1212  /* Draw update region */
1213  TermDrawRegion(Console, &UpdateRegion);
1214  }
1215  }
1216 
1217  return STATUS_SUCCESS;
1218 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TermDrawRegion(Console, Region)
Definition: term.h:22
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:29
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
smooth NULL
Definition: ftsmooth.c:416
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
__wchar_t WCHAR
Definition: xmlstorage.h:180
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: bl.h:1338
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
static __inline BOOLEAN ConioGetUnion(OUT PSMALL_RECT Union, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:176
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
static VOID ConioMoveRegion(PTEXTMODE_SCREEN_BUFFER ScreenBuffer, PSMALL_RECT SrcRegion, PSMALL_RECT DstRegion, PSMALL_RECT ClipRegion, CHAR_INFO FillChar)
Definition: text.c:188
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:150
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG Y
Definition: bl.h:1341

Referenced by CSR_API().

◆ ConDrvSetConsoleActiveScreenBuffer()

NTSTATUS NTAPI ConDrvSetConsoleActiveScreenBuffer ( IN PCONSOLE  Console,
IN PCONSOLE_SCREEN_BUFFER  Buffer 
)

Definition at line 170 of file conoutput.c.

172 {
173  if (Console == NULL || Buffer == NULL)
175 
176  /* Validity check */
177  ASSERT(Console == Buffer->Header.Console);
178 
179  if (Buffer == Console->ActiveBuffer) return STATUS_SUCCESS;
180 
181  /* If old buffer has no handles, it's now unreferenced */
182  if (Console->ActiveBuffer->Header.ReferenceCount == 0)
183  {
184  ConDrvDeleteScreenBuffer(Console->ActiveBuffer);
185  }
186 
187  /* Tie console to new buffer and signal the change to the frontend */
189 
190  return STATUS_SUCCESS;
191 }
VOID NTAPI ConDrvDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:123
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static VOID ConioSetActiveScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:161
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ ConDrvSetConsoleCursorInfo()

NTSTATUS NTAPI ConDrvSetConsoleCursorInfo ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN PCONSOLE_CURSOR_INFO  CursorInfo 
)

Definition at line 281 of file conoutput.c.

284 {
285  ULONG Size;
286  BOOLEAN Visible, Success = TRUE;
287 
288  if (Console == NULL || Buffer == NULL || CursorInfo == NULL)
290 
291  /* Validity check */
292  ASSERT(Console == Buffer->Header.Console);
293 
294  Size = min(max(CursorInfo->dwSize, 1), 100);
295  Visible = CursorInfo->bVisible;
296 
297  if ( (Size != Buffer->CursorInfo.dwSize) ||
298  (Visible && !Buffer->CursorInfo.bVisible) ||
299  (!Visible && Buffer->CursorInfo.bVisible) )
300  {
301  Buffer->CursorInfo.dwSize = Size;
302  Buffer->CursorInfo.bVisible = Visible;
303 
305  }
306 
308 }
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define TermSetCursorInfo(Console, ScreenBuffer)
Definition: term.h:24
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2777

◆ ConDrvSetConsoleCursorPosition()

NTSTATUS NTAPI ConDrvSetConsoleCursorPosition ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN PCOORD  Position 
)

Definition at line 311 of file conoutput.c.

314 {
315  SHORT OldCursorX, OldCursorY;
316 
317  if (Console == NULL || Buffer == NULL || Position == NULL)
319 
320  /* Validity check */
321  ASSERT(Console == Buffer->Header.Console);
322 
323  if ( Position->X < 0 || Position->X >= Buffer->ScreenBufferSize.X ||
324  Position->Y < 0 || Position->Y >= Buffer->ScreenBufferSize.Y )
325  {
327  }
328 
329  OldCursorX = Buffer->CursorPosition.X;
330  OldCursorY = Buffer->CursorPosition.Y;
331  Buffer->CursorPosition = *Position;
332  // Buffer->CursorPosition.X = Position->X;
333  // Buffer->CursorPosition.Y = Position->Y;
334  if ( ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer) &&
335  (!TermSetScreenInfo(Console, (PCONSOLE_SCREEN_BUFFER)Buffer, OldCursorX, OldCursorY)) )
336  {
337  return STATUS_UNSUCCESSFUL;
338  }
339 
340  return STATUS_SUCCESS;
341 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static COORD Position
Definition: mouse.c:34
#define TermSetScreenInfo(Console, ScreenBuffer, OldCursorX, OldCursorY)
Definition: term.h:26
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG Y
Definition: bl.h:1341

◆ ConDrvSetConsolePalette()

NTSTATUS NTAPI ConDrvSetConsolePalette ( IN PCONSOLE  Console,
IN PCONSOLE_SCREEN_BUFFER  Buffer,
IN HPALETTE  PaletteHandle,
IN UINT  PaletteUsage 
)

Definition at line 219 of file conoutput.c.

224 {
225  BOOL Success;
226 
227  /*
228  * Parameters validation
229  */
230  if (Console == NULL || Buffer == NULL)
232 
233  if ( PaletteUsage != SYSPAL_STATIC &&
234  PaletteUsage != SYSPAL_NOSTATIC &&
235  PaletteUsage != SYSPAL_NOSTATIC256 )
236  {
238  }
239 
240  /* Validity check */
241  ASSERT(Console == Buffer->Header.Console);
242 
243  /* Change the palette */
244  Success = TermSetPalette(Console, PaletteHandle, PaletteUsage);
245  if (Success)
246  {
247  /* Free the old palette handle if there was already one set */
248  if ( Buffer->PaletteHandle != NULL &&
249  Buffer->PaletteHandle != PaletteHandle )
250  {
251  DeleteObject(Buffer->PaletteHandle);
252  }
253 
254  /* Save the new palette in the screen buffer */
255  Buffer->PaletteHandle = PaletteHandle;
256  Buffer->PaletteUsage = PaletteUsage;
257  }
258 
260 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static HPALETTE PaletteHandle
Definition: svga.c:215
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define SYSPAL_NOSTATIC256
Definition: wingdi.h:21
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define SYSPAL_STATIC
Definition: wingdi.h:925
#define TermSetPalette(Console, PaletteHandle, PaletteUsage)
Definition: term.h:36
#define SYSPAL_NOSTATIC
Definition: wingdi.h:924
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by CSR_API().

◆ ConDrvSetConsoleScreenBufferSize()

NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN PCOORD  Size 
)

Definition at line 1114 of file text.c.

1117 {
1118  NTSTATUS Status;
1119 
1120  if (Console == NULL || Buffer == NULL || Size == NULL)
1121  return STATUS_INVALID_PARAMETER;
1122 
1123  /* Validity check */
1124  ASSERT(Console == Buffer->Header.Console);
1125 
1128 
1129  return Status;
1130 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define TermResizeTerminal(Console)
Definition: term.h:28
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
NTSTATUS ConioResizeBuffer(PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
Definition: text.c:257
CConsole Console

Referenced by CSR_API().

◆ ConDrvSetConsoleTextAttribute()

NTSTATUS NTAPI ConDrvSetConsoleTextAttribute ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN WORD  Attributes 
)

Definition at line 1099 of file text.c.

1102 {
1103  if (Console == NULL || Buffer == NULL)
1104  return STATUS_INVALID_PARAMETER;
1105 
1106  /* Validity check */
1107  ASSERT(Console == Buffer->Header.Console);
1108 
1109  Buffer->ScreenDefaultAttrib = Attributes;
1110  return STATUS_SUCCESS;
1111 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
_Must_inspect_result_ _In_ USHORT _In_ PHIDP_PREPARSED_DATA _Out_writes_to_ LengthAttributes PHIDP_EXTENDED_ATTRIBUTES Attributes
Definition: hidpi.h:348
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2777

Referenced by CSR_API().

◆ ConDrvSetConsoleWindowInfo()

NTSTATUS NTAPI ConDrvSetConsoleWindowInfo ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN BOOLEAN  Absolute,
IN PSMALL_RECT  WindowRect 
)

Definition at line 1221 of file text.c.

1225 {
1226  SMALL_RECT CapturedWindowRect;
1227  COORD LargestWindowSize;
1228 
1229  if (Console == NULL || Buffer == NULL || WindowRect == NULL)
1230  return STATUS_INVALID_PARAMETER;
1231 
1232  /* Validity check */
1233  ASSERT(Console == Buffer->Header.Console);
1234 
1235  CapturedWindowRect = *WindowRect;
1236 
1237  if (!Absolute)
1238  {
1239  /* Relative positions are given, transform them to absolute ones */
1240  CapturedWindowRect.Left += Buffer->ViewOrigin.X;
1241  CapturedWindowRect.Top += Buffer->ViewOrigin.Y;
1242  CapturedWindowRect.Right += Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
1243  CapturedWindowRect.Bottom += Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
1244  }
1245 
1246  /*
1247  * The MSDN documentation on SetConsoleWindowInfo is partially wrong about
1248  * the performed checks this API performs. While it is correct that the
1249  * 'Right'/'Bottom' members cannot be strictly smaller than the 'Left'/'Top'
1250  * members, they can be equal.
1251  * Also, if the 'Left' or 'Top' members are negative, this is automatically
1252  * corrected for, and the window rectangle coordinates are shifted accordingly.
1253  */
1254  if ((CapturedWindowRect.Right < CapturedWindowRect.Left) ||
1255  (CapturedWindowRect.Bottom < CapturedWindowRect.Top))
1256  {
1257  return STATUS_INVALID_PARAMETER;
1258  }
1259 
1260  /*
1261  * Forbid window sizes larger than the largest allowed console window size,
1262  * taking into account the size of the console screen buffer.
1263  */
1264  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1265  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1266  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1267  if ((CapturedWindowRect.Right - CapturedWindowRect.Left + 1 > LargestWindowSize.X) ||
1268  (CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1 > LargestWindowSize.Y))
1269  {
1270  return STATUS_INVALID_PARAMETER;
1271  }
1272 
1273  /* Shift the window rectangle coordinates if 'Left' or 'Top' are negative */
1274  if (CapturedWindowRect.Left < 0)
1275  {
1276  CapturedWindowRect.Right -= CapturedWindowRect.Left;
1277  CapturedWindowRect.Left = 0;
1278  }
1279  if (CapturedWindowRect.Top < 0)
1280  {
1281  CapturedWindowRect.Bottom -= CapturedWindowRect.Top;
1282  CapturedWindowRect.Top = 0;
1283  }
1284 
1285  /* Clip the window rectangle to the screen buffer */
1286  CapturedWindowRect.Right = min(CapturedWindowRect.Right , Buffer->ScreenBufferSize.X);
1287  CapturedWindowRect.Bottom = min(CapturedWindowRect.Bottom, Buffer->ScreenBufferSize.Y);
1288 
1289  Buffer->ViewOrigin.X = CapturedWindowRect.Left;
1290  Buffer->ViewOrigin.Y = CapturedWindowRect.Top;
1291 
1292  Buffer->ViewSize.X = CapturedWindowRect.Right - CapturedWindowRect.Left + 1;
1293  Buffer->ViewSize.Y = CapturedWindowRect.Bottom - CapturedWindowRect.Top + 1;
1294 
1296 
1297  return STATUS_SUCCESS;
1298 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TermResizeTerminal(Console)
Definition: term.h:28
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:28
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
SHORT Top
Definition: blue.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: bl.h:1338
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
SHORT Right
Definition: blue.h:27
return STATUS_SUCCESS
Definition: btrfs.c:2777
ULONG Y
Definition: bl.h:1341

Referenced by CSR_API().

◆ ConDrvWriteConsole()

NTSTATUS NTAPI ConDrvWriteConsole ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  ScreenBuffer,
IN BOOLEAN  Unicode,
IN PVOID  StringBuffer,
IN ULONG  NumCharsToWrite,
OUT PULONG NumCharsWritten  OPTIONAL 
)

Definition at line 655 of file text.c.

661 {
663  PWCHAR Buffer = NULL;
664  ULONG Written = 0;
665  ULONG Length;
666 
667  if (Console == NULL || ScreenBuffer == NULL /* || StringBuffer == NULL */)
669 
670  /* Validity checks */
671  ASSERT(Console == ScreenBuffer->Header.Console);
672  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCharsToWrite == 0));
673 
674  /* Stop here if the console is paused */
675  if (Console->UnpauseEvent != NULL) return STATUS_PENDING;
676 
677  /* Convert the string to UNICODE */
678  if (Unicode)
679  {
681  }
682  else
683  {
684  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
686  NumCharsToWrite,
687  NULL, 0);
688  Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length * sizeof(WCHAR));
689  if (Buffer)
690  {
691  MultiByteToWideChar(Console->OutputCodePage, 0,
693  NumCharsToWrite,
694  (PWCHAR)Buffer, Length);
695  }
696  else
697  {
699  }
700  }
701 
702  /* Send it */
703  if (Buffer)
704  {
705  if (NT_SUCCESS(Status))
706  {
708  ScreenBuffer,
709  Buffer,
710  NumCharsToWrite,
711  TRUE);
712  if (NT_SUCCESS(Status))
713  {
714  Written = NumCharsToWrite;
715  }
716  }
717 
718  if (!Unicode) RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
719  }
720 
721  if (NumCharsWritten) *NumCharsWritten = Written;
722 
723  return Status;
724 }
signed char * PCHAR
Definition: retypes.h:7
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
uint16_t * PWCHAR
Definition: typedefs.h:54
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
unsigned int ULONG
Definition: retypes.h:1
#define TermWriteStream(Console, ScreenBuffer, Buffer, Length, Attrib)
Definition: term.h:17
return STATUS_SUCCESS
Definition: btrfs.c:2777
WCHAR StringBuffer[156]
Definition: ldrinit.c:41

Referenced by DoWriteConsole().

◆ ConDrvWriteConsoleOutput()

NTSTATUS NTAPI ConDrvWriteConsoleOutput ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN BOOLEAN  Unicode,
IN PCHAR_INFO  CharInfo,
IN OUT PSMALL_RECT  WriteRegion 
)

Definition at line 531 of file text.c.

536 {
537  SHORT X, Y;
539  PCHAR_INFO CurCharInfo;
540  SMALL_RECT CapturedWriteRegion;
541  PCHAR_INFO Ptr;
542 
543  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
544  {
546  }
547 
548  /* Validity check */
549  ASSERT(Console == Buffer->Header.Console);
550 
551  CapturedWriteRegion = *WriteRegion;
552 
553  /* Make sure WriteRegion is inside the screen buffer */
555  Buffer->ScreenBufferSize.Y - 1,
556  Buffer->ScreenBufferSize.X - 1);
557  if (!ConioGetIntersection(&CapturedWriteRegion, &ScreenBuffer, &CapturedWriteRegion))
558  {
559  /*
560  * It is okay to have a WriteRegion completely outside
561  * the screen buffer. No data is written then.
562  */
563  return STATUS_SUCCESS;
564  }
565 
566  CurCharInfo = CharInfo;
567 
568  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
569  {
570  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
571  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
572  {
573  if (Unicode)
574  {
575  Ptr->Char.UnicodeChar = CurCharInfo->Char.UnicodeChar;
576  }
577  else
578  {
579  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char.AsciiChar);
580  }
581  Ptr->Attributes = CurCharInfo->Attributes;
582  ++Ptr;
583  ++CurCharInfo;
584  }
585  }
586 
587  TermDrawRegion(Console, &CapturedWriteRegion);
588 
589  *WriteRegion = CapturedWriteRegion;
590 
591  return STATUS_SUCCESS;
592 }
CHAR AsciiChar
Definition: wincon.h:170
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
WCHAR UnicodeChar
Definition: wincon.h:169
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define TermDrawRegion(Console, Region)
Definition: term.h:22
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:29
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
SHORT Bottom
Definition: blue.h:28
WORD Attributes
Definition: wincon.h:172
SHORT Top
Definition: blue.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
union _CHAR_INFO::@3150 Char
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:150
SHORT Right
Definition: blue.h:27
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define X(b, s)

Referenced by CSR_API().

◆ ConDrvWriteConsoleOutputString()

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 PULONG NumCodesWritten  OPTIONAL 
)

Definition at line 840 of file text.c.

848 {
851  PWCHAR tmpString = NULL;
852  ULONG X, Y, Length; // , Written = 0;
853  ULONG CodeSize;
854  PCHAR_INFO Ptr;
855 
856  if (Console == NULL || Buffer == NULL || WriteCoord == NULL /* || EndCoord == NULL */)
857  {
859  }
860 
861  /* Validity checks */
862  ASSERT(Console == Buffer->Header.Console);
863  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToWrite == 0));
864 
865  //
866  // FIXME: Make overflow checks on WriteCoord !!!!!!
867  //
868 
869  if (NumCodesWritten) *NumCodesWritten = 0;
870 
871  switch (CodeType)
872  {
873  case CODE_ASCII:
874  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
875  break;
876 
877  case CODE_UNICODE:
878  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
879  break;
880 
881  case CODE_ATTRIBUTE:
882  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
883  break;
884 
885  default:
887  }
888 
889  if (CodeType == CODE_ASCII)
890  {
891  /* Convert the ASCII string into Unicode before writing it to the console */
892  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
894  NumCodesToWrite,
895  NULL, 0);
896  tmpString = WriteBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, Length * sizeof(WCHAR));
897  if (WriteBuffer)
898  {
899  MultiByteToWideChar(Console->OutputCodePage, 0,
901  NumCodesToWrite,
903  }
904  else
905  {
907  }
908 
909  // FIXME: Quick fix: fix the CodeType and CodeSize since the
910  // ASCII string was converted into UNICODE.
911  // A proper fix needs to be written.
912  CodeType = CODE_UNICODE;
913  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
914  }
915  else
916  {
917  /* For CODE_UNICODE or CODE_ATTRIBUTE, we are already OK */
919  }
920 
921  if (WriteBuffer == NULL || !NT_SUCCESS(Status)) goto Cleanup;
922 
923  X = WriteCoord->X;
924  Y = (WriteCoord->Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
925  Length = NumCodesToWrite;
926  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
927  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
928 
929  while (Length--)
930  {
931  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
932  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
933 
934  switch (CodeType)
935  {
936  case CODE_ASCII:
937  case CODE_UNICODE:
938  Ptr->Char.UnicodeChar = *(PWCHAR)WriteBuffer;
939  break;
940 
941  case CODE_ATTRIBUTE:
942  Ptr->Attributes = *(PWORD)WriteBuffer;
943  break;
944  }
945  WriteBuffer = (PVOID)((ULONG_PTR)WriteBuffer + CodeSize);
946  // ++Ptr;
947 
948  // Written++;
949  if (++X == Buffer->ScreenBufferSize.X)
950  {
951  X = 0;
952 
953  if (++Y == Buffer->ScreenBufferSize.Y)
954  {
955  Y = 0;
956  }
957  }
958  }
959 
960  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
961  {
963  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
965  }
966 
967  // EndCoord->X = X;
968  // EndCoord->Y = (Y + Buffer->ScreenBufferSize.Y - Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
969 
970 Cleanup:
971  if (tmpString) RtlFreeHeap(RtlGetProcessHeap(), 0, tmpString);
972 
973  if (NumCodesWritten) *NumCodesWritten = NumCodesToWrite; // Written;
974  return Status;
975 }
signed char * PCHAR
Definition: retypes.h:7
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define TermDrawRegion(Console, Region)
Definition: term.h:22
uint16_t * PWCHAR
Definition: typedefs.h:54
static VOID ConioComputeUpdateRect(IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
Definition: text.c:160
uint32_t ULONG_PTR
Definition: typedefs.h:63
while(1)
Definition: macro.lex.yy.c:740
X(int i_=0)
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
WORD * PWORD
Definition: pedump.c:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR Cleanup[]
Definition: register.c:80
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
return STATUS_SUCCESS
Definition: btrfs.c:2777
WCHAR StringBuffer[156]
Definition: ldrinit.c:41
#define WriteBuffer(BaseIoAddress, Buffer, Count)
Definition: atapi.h:344
#define X(b, s)

Referenced by CSR_API().

◆ ConDrvWriteConsoleOutputVDM()

NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN PCHAR_CELL  CharInfo,
IN COORD  CharInfoSize,
IN PSMALL_RECT  WriteRegion 
)

Definition at line 600 of file text.c.

605 {
606  SHORT X, Y;
608  PCHAR_CELL CurCharInfo;
609  SMALL_RECT CapturedWriteRegion;
610  PCHAR_INFO Ptr;
611 
612  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
613  {
615  }
616 
617  /* Validity check */
618  ASSERT(Console == Buffer->Header.Console);
619 
620  CapturedWriteRegion = *WriteRegion;
621 
622  /* Make sure WriteRegion is inside the screen buffer */
624  Buffer->ScreenBufferSize.Y - 1,
625  Buffer->ScreenBufferSize.X - 1);
626  if (!ConioGetIntersection(&CapturedWriteRegion, &ScreenBuffer, &CapturedWriteRegion))
627  {
628  /*
629  * It is okay to have a WriteRegion completely outside
630  * the screen buffer. No data is written then.
631  */
632  return STATUS_SUCCESS;
633  }
634 
635  // CurCharInfo = CharInfo;
636 
637  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
638  {
639  CurCharInfo = CharInfo + Y * CharInfoSize.X + CapturedWriteRegion.Left;
640 
641  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
642  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
643  {
644  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char);
645  Ptr->Attributes = CurCharInfo->Attributes;
646  ++Ptr;
647  ++CurCharInfo;
648  }
649  }
650 
651  return STATUS_SUCCESS;
652 }
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:29
BYTE Attributes
Definition: svga.h:393
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
CHAR Char
Definition: svga.h:392
SHORT Bottom
Definition: blue.h:28
SHORT Top
Definition: blue.h:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
static __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:150
SHORT Right
Definition: blue.h:27
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define X(b, s)

Referenced by CSR_API().

◆ CSR_API() [1/18]

CSR_API ( SrvInvalidateBitMapRect  )

Definition at line 33 of file conoutput.c.

34 {
36  PCONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.InvalidateDIBitsRequest;
38 
39  DPRINT("SrvInvalidateBitMapRect\n");
40 
42  InvalidateDIBitsRequest->OutputHandle,
44  if (!NT_SUCCESS(Status)) return Status;
45 
46  /* In text-mode only, draw the VDM buffer if present */
47  if (GetType(Buffer) == TEXTMODE_BUFFER && Buffer->Header.Console->VDMBuffer)
48  {
50 
51  /*Status =*/ ConDrvWriteConsoleOutputVDM(Buffer->Header.Console,
52  TextBuffer,
53  Buffer->Header.Console->VDMBuffer,
54  Buffer->Header.Console->VDMBufferSize,
55  &InvalidateDIBitsRequest->Region);
56  }
57 
58  Status = ConDrvInvalidateBitMapRect(Buffer->Header.Console,
59  Buffer,
60  &InvalidateDIBitsRequest->Region);
61 
63  return Status;
64 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define TEXTMODE_BUFFER
Definition: pccons.c:21
NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCHAR_CELL CharInfo, IN COORD CharInfoSize, IN PSMALL_RECT WriteRegion)
Definition: text.c:600
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvInvalidateBitMapRect(IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN PSMALL_RECT Region)
Definition: conoutput.c:202
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
char TextBuffer[BUFFERLEN]
Definition: combotst.c:45
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER

◆ CSR_API() [2/18]

CSR_API ( SrvSetConsolePalette  )

Definition at line 72 of file conoutput.c.

73 {
75  PCONSOLE_SETPALETTE SetPaletteRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetPaletteRequest;
76  // PGRAPHICS_SCREEN_BUFFER Buffer;
78 
79  DPRINT("SrvSetConsolePalette\n");
80 
81  // NOTE: Tests show that this function is used only for graphics screen buffers
82  // and otherwise it returns FALSE + sets last error to invalid handle.
83  // I think it's ridiculous, because if you are in text mode, simulating
84  // a change of VGA palette via DAC registers (done by a call to SetConsolePalette)
85  // cannot be done... So I allow it in ReactOS !
86  /*
87  Status = ConSrvGetGraphicsBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
88  SetPaletteRequest->OutputHandle,
89  &Buffer, GENERIC_WRITE, TRUE);
90  */
92  SetPaletteRequest->OutputHandle,
94  if (!NT_SUCCESS(Status)) return Status;
95 
96  /*
97  * Make the palette handle public, so that it can be
98  * used by other threads calling GDI functions on it.
99  * Indeed, the palette handle comes from a console app
100  * calling ourselves, running in CSRSS.
101  */
103  &SetPaletteRequest->PaletteHandle,
104  sizeof(SetPaletteRequest->PaletteHandle));
105 
106  Status = ConDrvSetConsolePalette(Buffer->Header.Console,
107  Buffer,
108  SetPaletteRequest->PaletteHandle,
109  SetPaletteRequest->Usage);
110 
112  return Status;
113 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
HPALETTE PaletteHandle
Definition: conmsg.h:479
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
HANDLE OutputHandle
Definition: conmsg.h:478
#define GENERIC_WRITE
Definition: nt_native.h:90
NTSTATUS APIENTRY NtUserConsoleControl(IN CONSOLECONTROL ConsoleCtrl, IN PVOID ConsoleCtrlInfo, IN ULONG ConsoleCtrlInfoLength)
Definition: console.c:14
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
NTSTATUS NTAPI ConDrvSetConsolePalette(IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer, IN HPALETTE PaletteHandle, IN UINT PaletteUsage)
Definition: conoutput.c:219
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [3/18]

CSR_API ( SrvGetConsoleCursorInfo  )

Definition at line 119 of file conoutput.c.

120 {
122  PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CursorInfoRequest;
124 
125  DPRINT("SrvGetConsoleCursorInfo\n");
126 
128  CursorInfoRequest->OutputHandle,
130  if (!NT_SUCCESS(Status)) return Status;
131 
132  Status = ConDrvGetConsoleCursorInfo(Buffer->Header.Console,
133  Buffer,
134  &CursorInfoRequest->Info);
135 
137  return Status;
138 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ConDrvGetConsoleCursorInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCONSOLE_CURSOR_INFO CursorInfo)
Definition: conoutput.c:263
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
CONSOLE_CURSOR_INFO Info
Definition: conmsg.h:346
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [4/18]

CSR_API ( SrvSetConsoleCursorInfo  )

Definition at line 144 of file conoutput.c.

145 {
147  PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CursorInfoRequest;
149 
150  DPRINT("SrvSetConsoleCursorInfo\n");
151 
153  CursorInfoRequest->OutputHandle,
155  if (!NT_SUCCESS(Status)) return Status;
156 
157  Status = ConDrvSetConsoleCursorInfo(Buffer->Header.Console,
158  Buffer,
159  &CursorInfoRequest->Info);
160 
162  return Status;
163 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
CONSOLE_CURSOR_INFO Info
Definition: conmsg.h:346
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
NTSTATUS NTAPI ConDrvSetConsoleCursorInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCONSOLE_CURSOR_INFO CursorInfo)
Definition: conoutput.c:281
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [5/18]

CSR_API ( SrvSetConsoleCursorPosition  )

Definition at line 169 of file conoutput.c.

170 {
172  PCONSOLE_SETCURSORPOSITION SetCursorPositionRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorPositionRequest;
174 
175  DPRINT("SrvSetConsoleCursorPosition\n");
176 
178  SetCursorPositionRequest->OutputHandle,
180  if (!NT_SUCCESS(Status)) return Status;
181 
182  Status = ConDrvSetConsoleCursorPosition(Buffer->Header.Console,
183  Buffer,
184  &SetCursorPositionRequest->Position);
185 
187  return Status;
188 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
NTSTATUS NTAPI ConDrvSetConsoleCursorPosition(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Position)
Definition: conoutput.c:311
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [6/18]

CSR_API ( SrvCreateConsoleScreenBuffer  )

Definition at line 190 of file conoutput.c.

191 {
193  PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CreateScreenBufferRequest;
198 
200  TEXTMODE_BUFFER_INFO TextModeInfo = {{80, 25},
203  TRUE,
205  GRAPHICS_BUFFER_INFO GraphicsInfo;
206  GraphicsInfo.Info = CreateScreenBufferRequest->GraphicsBufferInfo; // HACK for MSVC
207 
208  DPRINT("SrvCreateConsoleScreenBuffer\n");
209 
210  Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
211  if (!NT_SUCCESS(Status)) return Status;
212 
213  if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_TEXTMODE_BUFFER)
214  {
215  ScreenBufferInfo = &TextModeInfo;
216 
217  /*
218  if (Console->ActiveBuffer)
219  {
220  TextModeInfo.ScreenBufferSize = Console->ActiveBuffer->ScreenBufferSize;
221  if (TextModeInfo.ScreenBufferSize.X == 0) TextModeInfo.ScreenBufferSize.X = 80;
222  if (TextModeInfo.ScreenBufferSize.Y == 0) TextModeInfo.ScreenBufferSize.Y = 25;
223 
224  TextModeInfo.ScreenAttrib = Console->ActiveBuffer->ScreenBuffer.TextBuffer.ScreenDefaultAttrib;
225  TextModeInfo.PopupAttrib = Console->ActiveBuffer->ScreenBuffer.TextBuffer.PopupDefaultAttrib;
226 
227  TextModeInfo.IsCursorVisible = Console->ActiveBuffer->CursorInfo.bVisible;
228  TextModeInfo.CursorSize = Console->ActiveBuffer->CursorInfo.dwSize;
229  }
230  */
231 
232  /*
233  * This is Windows' behaviour
234  */
235 
236  /* Use the current console size. Regularize it if needed. */
237  TextModeInfo.ScreenBufferSize = Console->ConsoleSize;
238  if (TextModeInfo.ScreenBufferSize.X == 0) TextModeInfo.ScreenBufferSize.X = 1;
239  if (TextModeInfo.ScreenBufferSize.Y == 0) TextModeInfo.ScreenBufferSize.Y = 1;
240 
241  /* If we have an active screen buffer, use its attributes as the new ones */
242  if (Console->ActiveBuffer && GetType(Console->ActiveBuffer) == TEXTMODE_BUFFER)
243  {
245 
246  TextModeInfo.ScreenAttrib = Buffer->ScreenDefaultAttrib;
247  TextModeInfo.PopupAttrib = Buffer->PopupDefaultAttrib;
248 
249  TextModeInfo.IsCursorVisible = Buffer->CursorInfo.bVisible;
250  TextModeInfo.CursorSize = Buffer->CursorInfo.dwSize;
251  }
252  }
253  else if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_GRAPHICS_BUFFER)
254  {
255  /* Get infos from the graphics buffer information structure */
256  if (!CsrValidateMessageBuffer(ApiMessage,
257  (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo,
258  CreateScreenBufferRequest->GraphicsBufferInfo.dwBitMapInfoLength,
259  sizeof(BYTE)))
260  {
262  goto Quit;
263  }
264 
265  ScreenBufferInfo = &GraphicsInfo;
266 
267  /* Initialize shared variables */
268  // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
269  CreateScreenBufferRequest->hMutex = GraphicsInfo.Info.hMutex = INVALID_HANDLE_VALUE;
270  // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
271  CreateScreenBufferRequest->lpBitMap = GraphicsInfo.Info.lpBitMap = NULL;
272 
273  /* A graphics screen buffer is never inheritable */
274  CreateScreenBufferRequest->InheritHandle = FALSE;
275  }
276 
278  (PCONSOLE)Console,
279  Process->ProcessHandle,
280  CreateScreenBufferRequest->ScreenBufferType,
282  if (!NT_SUCCESS(Status)) goto Quit;
283 
284  /* Insert the new handle inside the process handles table */
286 
287  Status = ConSrvInsertObject(ProcessData,
288  &CreateScreenBufferRequest->OutputHandle,
289  &Buff->Header,
290  CreateScreenBufferRequest->DesiredAccess,
291  CreateScreenBufferRequest->InheritHandle,
292  CreateScreenBufferRequest->ShareMode);
293 
295 
296  if (!NT_SUCCESS(Status)) goto Quit;
297 
298  if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_GRAPHICS_BUFFER)
299  {
301  /*
302  * Initialize the graphics buffer information structure
303  * and give it back to the client.
304  */
305  // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
306  CreateScreenBufferRequest->hMutex = Buffer->ClientMutex;
307  // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
308  CreateScreenBufferRequest->lpBitMap = Buffer->ClientBitMap;
309  }
310 
311 Quit:
313  return Status;
314 }
CONSOLE_GRAPHICS_BUFFER_INFO Info
Definition: conio.h:167
#define DEFAULT_SCREEN_ATTRIB
Definition: settings.c:29
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
BOOLEAN IsCursorVisible
Definition: conio.h:147
NTSTATUS ConDrvCreateScreenBuffer(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN HANDLE ProcessHandle OPTIONAL, IN ULONG BufferType, IN PVOID ScreenBufferInfo)
Definition: conoutput.c:79
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define CSR_DEFAULT_CURSOR_SIZE
Definition: settings.c:26
struct _GRAPHICS_SCREEN_BUFFER * PGRAPHICS_SCREEN_BUFFER
INT GetType(BOOL bLocal, LPOSVERSIONINFOEX osvi, LPSERVER_INFO_102 pBuf102)
Definition: gettype.c:129
CONSOLE_GRAPHICS_BUFFER_INFO GraphicsBufferInfo
Definition: conmsg.h:456
unsigned char BYTE
Definition: mem.h:68
USHORT PopupAttrib
Definition: conio.h:145
Status
Definition: gdiplustypes.h:24
#define DEFAULT_POPUP_ATTRIB
Definition: settings.c:30
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:59
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon.h:60
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS ConSrvInsertObject(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PHANDLE Handle, IN PCONSOLE_IO_OBJECT Object, IN ULONG Access, IN BOOLEAN Inheritable, IN ULONG ShareMode)
Definition: handle.c:310
ULONG Y
Definition: bl.h:1341
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER
COORD ScreenBufferSize
Definition: conio.h:143
USHORT ScreenAttrib
Definition: conio.h:144
RTL_CRITICAL_SECTION HandleTableLock
Definition: consrv.h:48

◆ CSR_API() [7/18]

CSR_API ( SrvSetConsoleActiveScreenBuffer  )

Definition at line 319 of file conoutput.c.

320 {
322  PCONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetScreenBufferRequest;
324 
325  DPRINT("SrvSetConsoleActiveScreenBuffer\n");
326 
328  SetScreenBufferRequest->OutputHandle,
330  if (!NT_SUCCESS(Status)) return Status;
331 
333  Buffer);
334 
336  return Status;
337 }
NTSTATUS NTAPI ConDrvSetConsoleActiveScreenBuffer(IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:170
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define ConSrvGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:26
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [8/18]

CSR_API ( SrvReadConsoleOutput  )

Definition at line 481 of file conoutput.c.

482 {
484  PCONSOLE_READOUTPUT ReadOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadOutputRequest;
486 
487  ULONG NumCells;
488  PCHAR_INFO CharInfo;
489 
490  DPRINT("SrvReadConsoleOutput\n");
491 
492  NumCells = (ReadOutputRequest->ReadRegion.Right - ReadOutputRequest->ReadRegion.Left + 1) *
493  (ReadOutputRequest->ReadRegion.Bottom - ReadOutputRequest->ReadRegion.Top + 1);
494 
495  /*
496  * For optimization purposes, Windows (and hence ReactOS, too, for
497  * compatibility reasons) uses a static buffer if no more than one
498  * cell is read. Otherwise a new buffer is used.
499  * The client-side expects that we know this behaviour.
500  */
501  if (NumCells <= 1)
502  {
503  /*
504  * Adjust the internal pointer, because its old value points to
505  * the static buffer in the original ApiMessage structure.
506  */
507  // ReadOutputRequest->CharInfo = &ReadOutputRequest->StaticBuffer;
508  CharInfo = &ReadOutputRequest->StaticBuffer;
509  }
510  else
511  {
512  if (!CsrValidateMessageBuffer(ApiMessage,
513  (PVOID*)&ReadOutputRequest->CharInfo,
514  NumCells,
515  sizeof(CHAR_INFO)))
516  {
518  }
519 
520  CharInfo = ReadOutputRequest->CharInfo;
521  }
522 
524  ReadOutputRequest->OutputHandle,
526  if (!NT_SUCCESS(Status)) return Status;
527 
528  Status = ConDrvReadConsoleOutput(Buffer->Header.Console,
529  Buffer,
530  ReadOutputRequest->Unicode,
531  CharInfo,
532  &ReadOutputRequest->ReadRegion);
533 
535  return Status;
536 }
HANDLE OutputHandle
Definition: conmsg.h:587
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
BOOLEAN Unicode
Definition: conmsg.h:593
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
SHORT Bottom
Definition: blue.h:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
PCHAR_INFO CharInfo
Definition: conmsg.h:590
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
SHORT Top
Definition: blue.h:26
SMALL_RECT ReadRegion
Definition: conmsg.h:592
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI ConDrvReadConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, OUT PCHAR_INFO CharInfo, IN OUT PSMALL_RECT ReadRegion)
Definition: text.c:467
SHORT Right
Definition: blue.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
CHAR_INFO StaticBuffer
Definition: conmsg.h:589

◆ CSR_API() [9/18]

CSR_API ( SrvWriteConsoleOutput  )

Definition at line 544 of file conoutput.c.

545 {
547  PCONSOLE_WRITEOUTPUT WriteOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteOutputRequest;
550 
551  ULONG NumCells;
552  PCHAR_INFO CharInfo;
553 
554  DPRINT("SrvWriteConsoleOutput\n");
555 
556  NumCells = (WriteOutputRequest->WriteRegion.Right - WriteOutputRequest->WriteRegion.Left + 1) *
557  (WriteOutputRequest->WriteRegion.Bottom - WriteOutputRequest->WriteRegion.Top + 1);
558 
560  WriteOutputRequest->OutputHandle,
562  if (!NT_SUCCESS(Status)) return Status;
563 
564  /*
565  * Validate the message buffer if we do not use a process' heap buffer
566  * (CsrAllocateCaptureBuffer succeeded because we haven't allocated
567  * a too large (>= 64 kB, size of the CSR heap) data buffer).
568  */
569  if (!WriteOutputRequest->UseVirtualMemory)
570  {
571  /*
572  * For optimization purposes, Windows (and hence ReactOS, too, for
573  * compatibility reasons) uses a static buffer if no more than one
574  * cell is written. Otherwise a new buffer is used.
575  * The client-side expects that we know this behaviour.
576  */
577  if (NumCells <= 1)
578  {
579  /*
580  * Adjust the internal pointer, because its old value points to
581  * the static buffer in the original ApiMessage structure.
582  */
583  // WriteOutputRequest->CharInfo = &WriteOutputRequest->StaticBuffer;
584  CharInfo = &WriteOutputRequest->StaticBuffer;
585  }
586  else
587  {
588  if (!CsrValidateMessageBuffer(ApiMessage,
589  (PVOID*)&WriteOutputRequest->CharInfo,
590  NumCells,
591  sizeof(CHAR_INFO)))
592  {
594  goto Quit;
595  }
596 
597  CharInfo = WriteOutputRequest->CharInfo;
598  }
599  }
600  else
601  {
602  /*
603  * This was not the case: we use a heap buffer. Retrieve its contents.
604  */
605  ULONG Size = NumCells * sizeof(CHAR_INFO);
606 
608  if (CharInfo == NULL)
609  {
611  goto Quit;
612  }
613 
614  Status = NtReadVirtualMemory(Process->ProcessHandle,
615  WriteOutputRequest->CharInfo,
616  CharInfo,
617  Size,
618  NULL);
619  if (!NT_SUCCESS(Status))
620  {
621  ConsoleFreeHeap(CharInfo);
622  // Status = STATUS_NO_MEMORY;
623  goto Quit;
624  }
625  }
626 
627  Status = ConDrvWriteConsoleOutput(Buffer->Header.Console,
628  Buffer,
629  WriteOutputRequest->Unicode,
630  CharInfo,
631  &WriteOutputRequest->WriteRegion);
632 
633  /* Free the temporary buffer if we used the process' heap buffer */
634  if (WriteOutputRequest->UseVirtualMemory && CharInfo)
635  ConsoleFreeHeap(CharInfo);
636 
637 Quit:
639  return Status;
640 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
BOOLEAN UseVirtualMemory
Definition: conmsg.h:612
#define GENERIC_WRITE
Definition: nt_native.h:90
struct _CHAR_INFO CHAR_INFO
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
HANDLE OutputHandle
Definition: conmsg.h:599
Definition: bufpool.h:45
NTSTATUS NTAPI ConDrvWriteConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PCHAR_INFO CharInfo, IN OUT PSMALL_RECT WriteRegion)
Definition: text.c:531
SHORT Left
Definition: blue.h:25
CHAR_INFO StaticBuffer
Definition: conmsg.h:601
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
SHORT Bottom
Definition: blue.h:28
SMALL_RECT WriteRegion
Definition: conmsg.h:604
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
SHORT Top
Definition: blue.h:26
NTSTATUS NTAPI NtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T NumberOfBytesToRead, OUT PSIZE_T NumberOfBytesRead OPTIONAL)
Definition: virtual.c:2691
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
SHORT Right
Definition: blue.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
PCHAR_INFO CharInfo
Definition: conmsg.h:602

◆ CSR_API() [10/18]

CSR_API ( SrvWriteConsole  )

Definition at line 642 of file conoutput.c.

643 {
645  PCONSOLE_WRITECONSOLE WriteConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleRequest;
646 
647  DPRINT("SrvWriteConsole\n");
648 
649  /*
650  * For optimization purposes, Windows (and hence ReactOS, too, for
651  * compatibility reasons) uses a static buffer if no more than eighty
652  * bytes are written. Otherwise a new buffer is used.
653  * The client-side expects that we know this behaviour.
654  */
655  if (WriteConsoleRequest->UsingStaticBuffer &&
656  WriteConsoleRequest->NumBytes <= sizeof(WriteConsoleRequest->StaticBuffer))
657  {
658  /*
659  * Adjust the internal pointer, because its old value points to
660  * the static buffer in the original ApiMessage structure.
661  */
662  // WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer;
663  }
664  else
665  {
666  if (!CsrValidateMessageBuffer(ApiMessage,
667  (PVOID)&WriteConsoleRequest->Buffer,
668  WriteConsoleRequest->NumBytes,
669  sizeof(BYTE)))
670  {
672  }
673  }
674 
675  Status = DoWriteConsole(ApiMessage, CsrGetClientThread(), TRUE);
676 
677  if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;
678 
679  return Status;
680 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
static NTSTATUS DoWriteConsole(IN PCSR_API_MESSAGE ApiMessage, IN PCSR_THREAD ClientThread, IN BOOLEAN CreateWaitBlock OPTIONAL)
Definition: conoutput.c:392
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
BOOLEAN UsingStaticBuffer
Definition: conmsg.h:246
CHAR StaticBuffer[80]
Definition: conmsg.h:239

◆ CSR_API() [11/18]

CSR_API ( SrvReadConsoleOutputString  )

Definition at line 691 of file conoutput.c.

692 {
694  PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadOutputCodeRequest;
696  ULONG CodeSize;
697 
698  PVOID pCode;
699 
700  DPRINT("SrvReadConsoleOutputString\n");
701 
702  switch (ReadOutputCodeRequest->CodeType)
703  {
704  case CODE_ASCII:
705  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
706  break;
707 
708  case CODE_UNICODE:
709  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
710  break;
711 
712  case CODE_ATTRIBUTE:
713  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
714  break;
715 
716  default:
718  }
719 
720  /*
721  * For optimization purposes, Windows (and hence ReactOS, too, for
722  * compatibility reasons) uses a static buffer if no more than eighty
723  * bytes are read. Otherwise a new buffer is used.
724  * The client-side expects that we know this behaviour.
725  */
726  if (ReadOutputCodeRequest->NumCodes * CodeSize <= sizeof(ReadOutputCodeRequest->CodeStaticBuffer))
727  {
728  /*
729  * Adjust the internal pointer, because its old value points to
730  * the static buffer in the original ApiMessage structure.
731  */
732  // ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer;
733  pCode = ReadOutputCodeRequest->CodeStaticBuffer;
734  }
735  else
736  {
737  if (!CsrValidateMessageBuffer(ApiMessage,
738  (PVOID*)&ReadOutputCodeRequest->pCode,
739  ReadOutputCodeRequest->NumCodes,
740  CodeSize))
741  {
743  }
744 
745  pCode = ReadOutputCodeRequest->pCode;
746  }
747 
749  ReadOutputCodeRequest->OutputHandle,
751  if (!NT_SUCCESS(Status))
752  {
753  ReadOutputCodeRequest->NumCodes = 0;
754  return Status;
755  }
756 
757  Status = ConDrvReadConsoleOutputString(Buffer->Header.Console,
758  Buffer,
759  ReadOutputCodeRequest->CodeType,
760  pCode,
761  ReadOutputCodeRequest->NumCodes,
762  &ReadOutputCodeRequest->Coord,
763  // &ReadOutputCodeRequest->EndCoord,
764  &ReadOutputCodeRequest->NumCodes);
765 
767  return Status;
768 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
CODE_TYPE CodeType
Definition: conmsg.h:535
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
CHAR CodeStaticBuffer[80]
Definition: conmsg.h:536
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
HANDLE OutputHandle
Definition: conmsg.h:532
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 PULONG NumCodesRead OPTIONAL)
Definition: text.c:727
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [12/18]

CSR_API ( SrvWriteConsoleOutputString  )

Definition at line 779 of file conoutput.c.

780 {
782  PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteOutputCodeRequest;
784  ULONG CodeSize;
785 
786  PVOID pCode;
787 
788  DPRINT("SrvWriteConsoleOutputString\n");
789 
790  switch (WriteOutputCodeRequest->CodeType)
791  {
792  case CODE_ASCII:
793  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
794  break;
795 
796  case CODE_UNICODE:
797  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
798  break;
799 
800  case CODE_ATTRIBUTE:
801  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
802  break;
803 
804  default:
806  }
807 
808  /*
809  * For optimization purposes, Windows (and hence ReactOS, too, for
810  * compatibility reasons) uses a static buffer if no more than eighty
811  * bytes are written. Otherwise a new buffer is used.
812  * The client-side expects that we know this behaviour.
813  */
814  if (WriteOutputCodeRequest->NumCodes * CodeSize <= sizeof(WriteOutputCodeRequest->CodeStaticBuffer))
815  {
816  /*
817  * Adjust the internal pointer, because its old value points to
818  * the static buffer in the original ApiMessage structure.
819  */
820  // WriteOutputCodeRequest->pCode = WriteOutputCodeRequest->CodeStaticBuffer;
821  pCode = WriteOutputCodeRequest->CodeStaticBuffer;
822  }
823  else
824  {
825  if (!CsrValidateMessageBuffer(ApiMessage,
826  (PVOID*)&WriteOutputCodeRequest->pCode,
827  WriteOutputCodeRequest->NumCodes,
828  CodeSize))
829  {
831  }
832 
833  pCode = WriteOutputCodeRequest->pCode;
834  }
835 
837  WriteOutputCodeRequest->OutputHandle,
839  if (!NT_SUCCESS(Status))
840  {
841  WriteOutputCodeRequest->NumCodes = 0;
842  return Status;
843  }
844 
845  Status = ConDrvWriteConsoleOutputString(Buffer->Header.Console,
846  Buffer,
847  WriteOutputCodeRequest->CodeType,
848  pCode,
849  WriteOutputCodeRequest->NumCodes,
850  &WriteOutputCodeRequest->Coord,
851  // &WriteOutputCodeRequest->EndCoord,
852  &WriteOutputCodeRequest->NumCodes);
853 
855  return Status;
856 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
CODE_TYPE CodeType
Definition: conmsg.h:535
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define GENERIC_WRITE
Definition: nt_native.h:90
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 PULONG NumCodesWritten OPTIONAL)
Definition: text.c:840
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
CHAR CodeStaticBuffer[80]
Definition: conmsg.h:536
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
HANDLE OutputHandle
Definition: conmsg.h:532
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [13/18]

CSR_API ( SrvFillConsoleOutput  )

Definition at line 866 of file conoutput.c.

867 {
869  PCONSOLE_FILLOUTPUTCODE FillOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputRequest;
871  CODE_TYPE CodeType = FillOutputRequest->CodeType;
872 
873  DPRINT("SrvFillConsoleOutput\n");
874 
875  if ( (CodeType != CODE_ASCII ) &&
876  (CodeType != CODE_UNICODE ) &&
877  (CodeType != CODE_ATTRIBUTE) )
878  {
880  }
881 
883  FillOutputRequest->OutputHandle,
885  if (!NT_SUCCESS(Status))
886  {
887  FillOutputRequest->NumCodes = 0;
888  return Status;
889  }
890 
891  Status = ConDrvFillConsoleOutput(Buffer->Header.Console,
892  Buffer,
893  CodeType,
894  FillOutputRequest->Code,
895  FillOutputRequest->NumCodes,
896  &FillOutputRequest->WriteCoord,
897  &FillOutputRequest->NumCodes);
898 
900  return Status;
901 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
CODE_ELEMENT Code
Definition: conmsg.h:557
CODE_TYPE CodeType
Definition: conmsg.h:556
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
enum _CODE_TYPE CODE_TYPE
NTSTATUS NTAPI ConDrvFillConsoleOutput(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN CODE_TYPE CodeType, IN CODE_ELEMENT Code, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:978

◆ CSR_API() [14/18]

CSR_API ( SrvGetConsoleScreenBufferInfo  )

Definition at line 912 of file conoutput.c.

913 {
915  PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScreenBufferInfoRequest;
917 
918  DPRINT("SrvGetConsoleScreenBufferInfo\n");
919 
921  ScreenBufferInfoRequest->OutputHandle,
923  if (!NT_SUCCESS(Status)) return Status;
924 
926  Buffer,
927  &ScreenBufferInfoRequest->ScreenBufferSize,
928  &ScreenBufferInfoRequest->CursorPosition,
929  &ScreenBufferInfoRequest->ViewOrigin,
930  &ScreenBufferInfoRequest->ViewSize,
931  &ScreenBufferInfoRequest->MaximumViewSize,
932  &ScreenBufferInfoRequest->Attributes);
933 
935  return Status;
936 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI ConDrvGetConsoleScreenBufferInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PCOORD ScreenBufferSize, OUT PCOORD CursorPosition, OUT PCOORD ViewOrigin, OUT PCOORD ViewSize, OUT PCOORD MaximumViewSize, OUT PWORD Attributes)
Definition: text.c:1059
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [15/18]

CSR_API ( SrvSetConsoleTextAttribute  )

Definition at line 942 of file conoutput.c.

943 {
945  PCONSOLE_SETTEXTATTRIB SetTextAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetTextAttribRequest;
947 
948  DPRINT("SrvSetConsoleTextAttribute\n");
949 
951  SetTextAttribRequest->OutputHandle,
953  if (!NT_SUCCESS(Status)) return Status;
954 
955  Status = ConDrvSetConsoleTextAttribute(Buffer->Header.Console,
956  Buffer,
957  SetTextAttribRequest->Attributes);
958 
960  return Status;
961 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI ConDrvSetConsoleTextAttribute(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN WORD Attributes)
Definition: text.c:1099
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [16/18]

CSR_API ( SrvSetConsoleScreenBufferSize  )

Definition at line 967 of file conoutput.c.

968 {
970  PCONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetScreenBufferSizeRequest;
972 
973  DPRINT("SrvSetConsoleScreenBufferSize\n");
974 
976  SetScreenBufferSizeRequest->OutputHandle,
978  if (!NT_SUCCESS(Status)) return Status;
979 
981  Buffer,
982  &SetScreenBufferSizeRequest->Size);
983 
985  return Status;
986 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Size)
Definition: text.c:1114
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [17/18]

CSR_API ( SrvScrollConsoleScreenBuffer  )

Definition at line 997 of file conoutput.c.

998 {
1000  PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScrollScreenBufferRequest;
1002 
1003  DPRINT("SrvScrollConsoleScreenBuffer\n");
1004 
1006  ScrollScreenBufferRequest->OutputHandle,
1008  if (!NT_SUCCESS(Status)) return Status;
1009 
1010  Status = ConDrvScrollConsoleScreenBuffer(Buffer->Header.Console,
1011  Buffer,
1012  ScrollScreenBufferRequest->Unicode,
1013  &ScrollScreenBufferRequest->ScrollRectangle,
1014  ScrollScreenBufferRequest->UseClipRectangle,
1015  &ScrollScreenBufferRequest->ClipRectangle,
1016  &ScrollScreenBufferRequest->DestinationOrigin,
1017  ScrollScreenBufferRequest->Fill);
1018 
1020  return Status;
1021 }
SMALL_RECT ScrollRectangle
Definition: conmsg.h:501
SMALL_RECT ClipRectangle
Definition: conmsg.h:502
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define GENERIC_WRITE
Definition: nt_native.h:90
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
NTSTATUS NTAPI ConDrvScrollConsoleScreenBuffer(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PSMALL_RECT ScrollRectangle, IN BOOLEAN UseClipRectangle, IN PSMALL_RECT ClipRectangle OPTIONAL, IN PCOORD DestinationOrigin, IN CHAR_INFO FillChar)
Definition: text.c:1133
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [18/18]

CSR_API ( SrvSetConsoleWindowInfo  )

Definition at line 1028 of file conoutput.c.

1029 {
1030  NTSTATUS Status;
1031  PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetWindowInfoRequest;
1032  // PCONSOLE_SCREEN_BUFFER Buffer;
1034 
1035  DPRINT1("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n",
1036  SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute,
1037  SetWindowInfoRequest->WindowRect.Left ,
1038  SetWindowInfoRequest->WindowRect.Top ,
1039  SetWindowInfoRequest->WindowRect.Right,
1040  SetWindowInfoRequest->WindowRect.Bottom);
1041 
1042  // ConSrvGetScreenBuffer
1044  SetWindowInfoRequest->OutputHandle,
1045  &Buffer, GENERIC_READ, TRUE);
1046  if (!NT_SUCCESS(Status)) return Status;
1047 
1048  Status = ConDrvSetConsoleWindowInfo(Buffer->Header.Console,
1049  Buffer,
1050  SetWindowInfoRequest->Absolute,
1051  &SetWindowInfoRequest->WindowRect);
1052 
1054  return Status;
1055 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
SMALL_RECT WindowRect
Definition: conmsg.h:710
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:25
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
SHORT Bottom
Definition: blue.h:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
SHORT Top
Definition: blue.h:26
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvSetConsoleWindowInfo(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Absolute, IN PSMALL_RECT WindowRect)
Definition: text.c:1221
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
SHORT Right
Definition: blue.h:27
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ DoWriteConsole()

static NTSTATUS DoWriteConsole ( IN PCSR_API_MESSAGE  ApiMessage,
IN PCSR_THREAD  ClientThread,
IN BOOLEAN CreateWaitBlock  OPTIONAL 
)
static

Definition at line 392 of file conoutput.c.

395 {
397  PCONSOLE_WRITECONSOLE WriteConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleRequest;
399 
400  PVOID Buffer;
401  ULONG NrCharactersWritten = 0;
402  ULONG CharSize = (WriteConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR));
403 
405  WriteConsoleRequest->OutputHandle,
407  if (!NT_SUCCESS(Status)) return Status;
408 
409  /*
410  * For optimization purposes, Windows (and hence ReactOS, too, for
411  * compatibility reasons) uses a static buffer if no more than eighty
412  * bytes are written. Otherwise a new buffer is used.
413  * The client-side expects that we know this behaviour.
414  */
415  if (WriteConsoleRequest->UsingStaticBuffer &&
416  WriteConsoleRequest->NumBytes <= sizeof(WriteConsoleRequest->StaticBuffer))
417  {
418  /*
419  * Adjust the internal pointer, because its old value points to
420  * the static buffer in the original ApiMessage structure.
421  */
422  // WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer;
423  Buffer = WriteConsoleRequest->StaticBuffer;
424  }
425  else
426  {
427  Buffer = WriteConsoleRequest->Buffer;
428  }
429 
430  DPRINT("Calling ConDrvWriteConsole\n");
431  Status = ConDrvWriteConsole(ScreenBuffer->Header.Console,
432  ScreenBuffer,
433  WriteConsoleRequest->Unicode,
434  Buffer,
435  WriteConsoleRequest->NumBytes / CharSize, // NrCharactersToWrite
436  &NrCharactersWritten);
437  DPRINT("ConDrvWriteConsole returned (%d ; Status = 0x%08x)\n",
438  NrCharactersWritten, Status);
439 
440  if (Status == STATUS_PENDING)
441  {
442  if (CreateWaitBlock)
443  {
445 
446  if (!CsrCreateWait(&Console->WriteWaitQueue,
448  ClientThread,
449  ApiMessage,
450  NULL))
451  {
452  /* Fail */
454  goto Quit;
455  }
456  }
457 
458  /* Wait until we un-pause the console */
459  // Status = STATUS_PENDING;
460  }
461  else
462  {
463  /* We read all what we wanted. Set the number of bytes written. */
464  WriteConsoleRequest->NumBytes = NrCharactersWritten * CharSize;
465  }
466 
467 Quit:
469  return Status;
470 }
static BOOLEAN NTAPI WriteConsoleThread(IN PLIST_ENTRY WaitList, IN PCSR_THREAD WaitThread, IN PCSR_API_MESSAGE WaitApiMessage, IN PVOID WaitContext, IN PVOID WaitArgument1, IN PVOID WaitArgument2, IN ULONG WaitFlags)
Definition: conoutput.c:350
char CHAR
Definition: xmlstorage.h:175
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
UINT CALLBACK ClientThread(_Inout_ PVOID Parameter)
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
Status
Definition: gdiplustypes.h:24
BOOLEAN UsingStaticBuffer
Definition: conmsg.h:246
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
CConsole Console
HANDLE ScreenBuffer
Definition: notevil.c:37
CHAR StaticBuffer[80]
Definition: conmsg.h:239
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN NTAPI CsrCreateWait(IN PLIST_ENTRY WaitList, IN CSR_WAIT_FUNCTION WaitFunction, IN PCSR_THREAD CsrWaitThread, IN OUT PCSR_API_MESSAGE WaitApiMessage, IN PVOID WaitContext)
Definition: wait.c:209
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
NTSTATUS NTAPI ConDrvWriteConsole(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN BOOLEAN Unicode, IN PVOID StringBuffer, IN ULONG NumCharsToWrite, OUT PULONG NumCharsWritten OPTIONAL)
Definition: text.c:655

Referenced by CSR_API(), and WriteConsoleThread().

◆ WriteConsoleThread()

static BOOLEAN NTAPI WriteConsoleThread ( IN PLIST_ENTRY  WaitList,
IN PCSR_THREAD  WaitThread,
IN PCSR_API_MESSAGE  WaitApiMessage,
IN PVOID  WaitContext,
IN PVOID  WaitArgument1,
IN PVOID  WaitArgument2,
IN ULONG  WaitFlags 
)
static

Definition at line 350 of file conoutput.c.

357 {
359 
360  DPRINT("WriteConsoleThread - WaitContext = 0x%p, WaitArgument1 = 0x%p, WaitArgument2 = 0x%p, WaitFlags = %lu\n", WaitContext, WaitArgument1, WaitArgument2, WaitFlags);
361 
362  /*
363  * If we are notified of the process termination via a call
364  * to CsrNotifyWaitBlock triggered by CsrDestroyProcess or
365  * CsrDestroyThread, just return.
366  */
367  if (WaitFlags & CsrProcessTerminating)
368  {
370  goto Quit;
371  }
372 
373  Status = DoWriteConsole(WaitApiMessage, WaitThread, FALSE);
374 
375 Quit:
376  if (Status != STATUS_PENDING)
377  {
378  WaitApiMessage->Status = Status;
379  }
380 
381  return (Status == STATUS_PENDING ? FALSE : TRUE);
382 }
#define TRUE
Definition: types.h:120
static NTSTATUS DoWriteConsole(IN PCSR_API_MESSAGE ApiMessage, IN PCSR_THREAD ClientThread, IN BOOLEAN CreateWaitBlock OPTIONAL)
Definition: conoutput.c:392
#define STATUS_THREAD_IS_TERMINATING
Definition: ntstatus.h:297
LONG NTSTATUS
Definition: precomp.h:26
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24

Referenced by DoWriteConsole().