ReactOS  0.4.14-dev-1112-g2b067d6
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 1264 of file text.c.

1271 {
1272  SHORT X, Y;
1273  SHORT XStart;
1274  ULONG nNumChars = 0;
1275  PCHAR_INFO Ptr;
1276  BOOLEAN bLead, bFullwidth;
1277 
1278  if (Console == NULL || Buffer == NULL || WriteCoord == NULL)
1279  {
1280  return STATUS_INVALID_PARAMETER;
1281  }
1282 
1283  /* Validity check */
1284  ASSERT(Console == Buffer->Header.Console);
1285 
1286  if (NumCodesWritten)
1287  *NumCodesWritten = 0;
1288 
1289  if (NumCodesToWrite == 0)
1290  return STATUS_SUCCESS; // Nothing to do!
1291 
1292  /* Do nothing if the writing starting point is outside of the screen buffer */
1293  if ( WriteCoord->X < 0 || WriteCoord->X >= Buffer->ScreenBufferSize.X ||
1294  WriteCoord->Y < 0 || WriteCoord->Y >= Buffer->ScreenBufferSize.Y )
1295  {
1296  return STATUS_SUCCESS;
1297  }
1298 
1299  NumCodesToWrite = min(NumCodesToWrite, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
1300 
1301  if (CodeType == CODE_ASCII)
1302  {
1303  /* Conversion from the ASCII char to the UNICODE char */
1304  CODE_ELEMENT tmp;
1306  Code = tmp;
1307  }
1308 
1309  XStart = WriteCoord->X;
1310 
1311  /* For Chinese, Japanese and Korean */
1312  X = XStart;
1313  Y = WriteCoord->Y;
1314  bLead = TRUE;
1315  bFullwidth = FALSE;
1316  if (Console->IsCJK)
1317  {
1318  bFullwidth = IS_FULL_WIDTH(Code.UnicodeChar);
1319  if (X > 0)
1320  {
1321  Ptr = ConioCoordToPointer(Buffer, X - 1, Y);
1322  if (Ptr->Attributes & COMMON_LVB_LEADING_BYTE)
1323  {
1324  Ptr->Char.UnicodeChar = L' ';
1325  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1326  }
1327  }
1328  }
1329 
1330  for (Y = WriteCoord->Y; Y < Buffer->ScreenBufferSize.Y; ++Y)
1331  {
1332  Ptr = ConioCoordToPointer(Buffer, XStart, Y);
1333  for (X = XStart; X < Buffer->ScreenBufferSize.X; ++X)
1334  {
1335  if (nNumChars >= NumCodesToWrite)
1336  goto Quit;
1337 
1338  switch (CodeType)
1339  {
1340  case CODE_ASCII:
1341  case CODE_UNICODE:
1342  Ptr->Char.UnicodeChar = Code.UnicodeChar;
1343  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1344  if (bFullwidth)
1345  {
1346  if (bLead)
1347  Ptr->Attributes |= COMMON_LVB_LEADING_BYTE;
1348  else
1349  Ptr->Attributes |= COMMON_LVB_TRAILING_BYTE;
1350  }
1351  bLead = !bLead;
1352  break;
1353 
1354  case CODE_ATTRIBUTE:
1355  Ptr->Attributes &= COMMON_LVB_SBCSDBCS;
1356  Ptr->Attributes |= (Code.Attribute & ~COMMON_LVB_SBCSDBCS);
1357  break;
1358  }
1359 
1360  ++Ptr;
1361 
1362  ++nNumChars;
1363  }
1364  /* Restart at the beginning of the next line */
1365  XStart = 0;
1366  }
1367 Quit:
1368 
1369  if ((nNumChars & 1) & bFullwidth)
1370  {
1371  if (X + Y * Buffer->ScreenBufferSize.X > 0)
1372  {
1373  Ptr = ConioCoordToPointer(Buffer, X - 1, Y);
1374  Ptr->Char.UnicodeChar = L' ';
1375  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
1376  }
1377  }
1378 
1379  if (NumCodesWritten)
1380  *NumCodesWritten = nNumChars;
1381 
1382  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1383  {
1385  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, nNumChars);
1387  }
1388 
1389  return STATUS_SUCCESS;
1390 }
#define TRUE
Definition: types.h:120
#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:156
WCHAR UnicodeChar
Definition: conmsg.h:525
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
#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:178
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:31
short SHORT
Definition: pedump.c:59
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define Code
Definition: deflate.h:80
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
#define COMMON_LVB_LEADING_BYTE
Definition: wincon.h:48
unsigned int ULONG
Definition: retypes.h:1
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
#define COMMON_LVB_TRAILING_BYTE
Definition: wincon.h:49
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define IS_FULL_WIDTH(wch)
Definition: conio.h:379
#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:2938

◆ 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 1393 of file text.c.

1401 {
1402  COORD LargestWindowSize;
1403 
1404  if (Console == NULL || Buffer == NULL || ScreenBufferSize == NULL ||
1405  CursorPosition == NULL || ViewOrigin == NULL || ViewSize == NULL ||
1406  MaximumViewSize == NULL || Attributes == NULL)
1407  {
1408  return STATUS_INVALID_PARAMETER;
1409  }
1410 
1411  /* Validity check */
1412  ASSERT(Console == Buffer->Header.Console);
1413 
1414  *ScreenBufferSize = Buffer->ScreenBufferSize;
1415  *CursorPosition = Buffer->CursorPosition;
1416  *ViewOrigin = Buffer->ViewOrigin;
1417  *ViewSize = Buffer->ViewSize;
1418  *Attributes = Buffer->ScreenDefaultAttrib;
1419 
1420  /*
1421  * Retrieve the largest possible console window size, taking
1422  * into account the size of the console screen buffer.
1423  */
1424  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1425  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1426  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1427  *MaximumViewSize = LargestWindowSize;
1428 
1429  return STATUS_SUCCESS;
1430 }
#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:2938
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:2938

◆ 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 582 of file text.c.

587 {
588  SHORT X, Y;
590  PCHAR_INFO CurCharInfo;
591  SMALL_RECT CapturedReadRegion;
592  PCHAR_INFO Ptr;
593 
594  if (Console == NULL || Buffer == NULL || CharInfo == NULL || ReadRegion == NULL)
595  {
597  }
598 
599  /* Validity check */
600  ASSERT(Console == Buffer->Header.Console);
601 
602  CapturedReadRegion = *ReadRegion;
603 
604  /* Make sure ReadRegion is inside the screen buffer */
606  Buffer->ScreenBufferSize.Y - 1,
607  Buffer->ScreenBufferSize.X - 1);
608  if (!ConioGetIntersection(&CapturedReadRegion, &CapturedReadRegion, &ScreenBuffer))
609  {
610  /*
611  * It is okay to have a ReadRegion completely outside
612  * the screen buffer. No data is read then.
613  */
614  return STATUS_SUCCESS;
615  }
616 
617  CurCharInfo = CharInfo;
618 
619  for (Y = CapturedReadRegion.Top; Y <= CapturedReadRegion.Bottom; ++Y)
620  {
621  Ptr = ConioCoordToPointer(Buffer, CapturedReadRegion.Left, Y);
622  for (X = CapturedReadRegion.Left; X <= CapturedReadRegion.Right; ++X)
623  {
624  if (Unicode)
625  {
626  CurCharInfo->Char.UnicodeChar = Ptr->Char.UnicodeChar;
627  }
628  else
629  {
630  // ConsoleOutputUnicodeToAnsiChar(Console, &CurCharInfo->Char.AsciiChar, &Ptr->Char.UnicodeChar);
631  WideCharToMultiByte(Console->OutputCodePage, 0, &Ptr->Char.UnicodeChar, 1,
632  &CurCharInfo->Char.AsciiChar, 1, NULL, NULL);
633  }
634 #if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
635  /* NOTE: Windows < 8 compatibility: DBCS flags are filtered out */
636  CurCharInfo->Attributes = (Ptr->Attributes & ~COMMON_LVB_SBCSDBCS);
637 #else
638  CurCharInfo->Attributes = Ptr->Attributes;
639 #endif
640  ++Ptr;
641  ++CurCharInfo;
642  }
643  }
644 
645  *ReadRegion = CapturedReadRegion;
646 
647  return STATUS_SUCCESS;
648 }
CHAR AsciiChar
Definition: wincon.h:185
#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:156
WCHAR UnicodeChar
Definition: wincon.h:184
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
short SHORT
Definition: pedump.c:59
union _CHAR_INFO::@3176 Char
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:32
SHORT Bottom
Definition: blue.h:35
WORD Attributes
Definition: wincon.h:187
SHORT Top
Definition: blue.h:33
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:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
#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 955 of file text.c.

963 {
964  if (Console == NULL || Buffer == NULL || ReadCoord == NULL /* || EndCoord == NULL */)
965  {
967  }
968 
969  /* Validity checks */
970  ASSERT(Console == Buffer->Header.Console);
971  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToRead == 0));
972 
973  if (NumCodesRead)
974  *NumCodesRead = 0;
975 
976  if (!StringBuffer || (NumCodesToRead == 0))
977  return STATUS_SUCCESS; // Nothing to do!
978 
979  /* Do nothing if the reading starting point is outside of the screen buffer */
980  if ( ReadCoord->X < 0 || ReadCoord->X >= Buffer->ScreenBufferSize.X ||
981  ReadCoord->Y < 0 || ReadCoord->Y >= Buffer->ScreenBufferSize.Y )
982  {
983  return STATUS_SUCCESS;
984  }
985 
986  NumCodesToRead = min(NumCodesToRead, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
987 
988  switch (CodeType)
989  {
990  case CODE_ASCII:
991  {
993  Buffer,
994  StringBuffer,
995  FALSE,
996  NumCodesToRead,
997  ReadCoord,
998  NumCodesRead);
999  }
1000 
1001  case CODE_UNICODE:
1002  {
1004  Buffer,
1005  StringBuffer,
1006  TRUE,
1007  NumCodesToRead,
1008  ReadCoord,
1009  NumCodesRead);
1010  }
1011 
1012  case CODE_ATTRIBUTE:
1013  {
1014  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, Attribute) == sizeof(WORD));
1016  Buffer,
1018  NumCodesToRead,
1019  ReadCoord,
1020  NumCodesRead);
1021  }
1022 
1023  default:
1024  return STATUS_INVALID_PARAMETER;
1025  }
1026 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
static NTSTATUS IntReadConsoleOutputStringChars(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PVOID StringBuffer, IN BOOLEAN Unicode, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:848
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static NTSTATUS IntReadConsoleOutputStringAttributes(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, OUT PWORD StringBuffer, IN ULONG NumCodesToRead, IN PCOORD ReadCoord, OUT PULONG NumCodesRead OPTIONAL)
Definition: text.c:916
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define C_ASSERT(e)
Definition: intsafe.h:79
WORD * PWORD
Definition: pedump.c:67
unsigned short WORD
Definition: ntddk_ex.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2938
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 1467 of file text.c.

1476 {
1477  COORD CapturedDestinationOrigin;
1479  SMALL_RECT CapturedClipRectangle;
1480  SMALL_RECT SrcRegion;
1481  SMALL_RECT DstRegion;
1482  SMALL_RECT UpdateRegion;
1483 
1484  if (Console == NULL || Buffer == NULL || ScrollRectangle == NULL ||
1485  (UseClipRectangle && (ClipRectangle == NULL)) || DestinationOrigin == NULL)
1486  {
1487  return STATUS_INVALID_PARAMETER;
1488  }
1489 
1490  /* Validity check */
1491  ASSERT(Console == Buffer->Header.Console);
1492 
1493  CapturedDestinationOrigin = *DestinationOrigin;
1494 
1495  /* Make sure the source rectangle is inside the screen buffer */
1496  ConioInitRect(&ScreenBuffer, 0, 0,
1497  Buffer->ScreenBufferSize.Y - 1,
1498  Buffer->ScreenBufferSize.X - 1);
1499  if (!ConioGetIntersection(&SrcRegion, ScrollRectangle, &ScreenBuffer))
1500  {
1501  return STATUS_SUCCESS;
1502  }
1503 
1504  /* If the source was clipped on the left or top, adjust the destination accordingly */
1505  if (ScrollRectangle->Left < 0)
1506  CapturedDestinationOrigin.X -= ScrollRectangle->Left;
1507  if (ScrollRectangle->Top < 0)
1508  CapturedDestinationOrigin.Y -= ScrollRectangle->Top;
1509 
1510  /*
1511  * If a clip rectangle is provided, clip it to the screen buffer,
1512  * otherwise use the latter one as the clip rectangle.
1513  */
1514  if (UseClipRectangle)
1515  {
1516  CapturedClipRectangle = *ClipRectangle;
1517  if (!ConioGetIntersection(&CapturedClipRectangle, &CapturedClipRectangle, &ScreenBuffer))
1518  {
1519  return STATUS_SUCCESS;
1520  }
1521  }
1522  else
1523  {
1524  CapturedClipRectangle = ScreenBuffer;
1525  }
1526 
1527  /*
1528  * Windows compatibility: Do nothing if the intersection of the source region
1529  * with the clip rectangle is empty, even if the intersection of destination
1530  * region with the clip rectangle is NOT empty and therefore it would have
1531  * been possible to copy contents to it...
1532  */
1533  if (!ConioGetIntersection(&UpdateRegion, &SrcRegion, &CapturedClipRectangle))
1534  {
1535  return STATUS_SUCCESS;
1536  }
1537 
1538  /* Initialize the destination rectangle, of same size as the source rectangle */
1539  ConioInitRect(&DstRegion,
1540  CapturedDestinationOrigin.Y,
1541  CapturedDestinationOrigin.X,
1542  CapturedDestinationOrigin.Y + ConioRectHeight(&SrcRegion) - 1,
1543  CapturedDestinationOrigin.X + ConioRectWidth(&SrcRegion ) - 1);
1544 
1545  if (ConioGetIntersection(&DstRegion, &DstRegion, &CapturedClipRectangle))
1546  {
1547  /*
1548  * Build the region image, within the source region,
1549  * of the destination region we should copy into.
1550  */
1551  SrcRegion.Left += DstRegion.Left - CapturedDestinationOrigin.X;
1552  SrcRegion.Top += DstRegion.Top - CapturedDestinationOrigin.Y;
1553  SrcRegion.Right = SrcRegion.Left + (DstRegion.Right - DstRegion.Left);
1554  SrcRegion.Bottom = SrcRegion.Top + (DstRegion.Bottom - DstRegion.Top);
1555 
1556  /* Do the copy */
1557  CapturedDestinationOrigin.X = DstRegion.Left;
1558  CapturedDestinationOrigin.Y = DstRegion.Top;
1559  ConioCopyRegion(Buffer, &SrcRegion, &CapturedDestinationOrigin);
1560  }
1561 
1562  if (!Unicode)
1563  {
1564  /* Conversion from the ASCII char to the UNICODE char */
1565  WCHAR tmp;
1566  ConsoleOutputAnsiToUnicodeChar(Console, &tmp, &FillChar.Char.AsciiChar);
1567  FillChar.Char.UnicodeChar = tmp;
1568  }
1569  /* Sanitize the attribute */
1570  FillChar.Attributes &= ~COMMON_LVB_SBCSDBCS;
1571 
1572  /*
1573  * Fill the intersection (== UpdateRegion) of the source region with the
1574  * clip rectangle, excluding the destination region.
1575  */
1576  ConioFillRegion(Buffer, &UpdateRegion, &DstRegion, FillChar);
1577 
1578  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1579  {
1580  ConioGetUnion(&UpdateRegion, &UpdateRegion, &DstRegion);
1581  if (ConioGetIntersection(&UpdateRegion, &UpdateRegion, &CapturedClipRectangle))
1582  {
1583  /* Draw update region */
1584  TermDrawRegion(Console, &UpdateRegion);
1585  }
1586  }
1587 
1588  return STATUS_SUCCESS;
1589 }
static VOID ConioFillRegion(IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN PSMALL_RECT Region, IN PSMALL_RECT ExcludeRegion OPTIONAL, IN CHAR_INFO FillChar)
Definition: text.c:303
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
#define TermDrawRegion(Console, Region)
Definition: term.h:22
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:31
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
smooth NULL
Definition: ftsmooth.c:416
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
Definition: bufpool.h:45
static VOID ConioCopyRegion(IN PTEXTMODE_SCREEN_BUFFER ScreenBuffer, IN PSMALL_RECT SrcRegion, IN PCOORD DstOrigin)
Definition: text.c:206
SHORT Left
Definition: blue.h:32
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:35
__wchar_t WCHAR
Definition: xmlstorage.h:180
SHORT Top
Definition: blue.h:33
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 __inline BOOLEAN ConioGetIntersection(OUT PSMALL_RECT Intersection, IN PSMALL_RECT Rect1, IN PSMALL_RECT Rect2)
Definition: text.c:150
SHORT Right
Definition: blue.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
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:2938

◆ 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:2938

◆ 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 
333  if ( ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer) &&
334  (!TermSetScreenInfo(Console, (PCONSOLE_SCREEN_BUFFER)Buffer, OldCursorX, OldCursorY)) )
335  {
336  return STATUS_UNSUCCESSFUL;
337  }
338 
339  return STATUS_SUCCESS;
340 }
#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:2938
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:2938

Referenced by CSR_API().

◆ ConDrvSetConsoleScreenBufferSize()

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

Definition at line 1448 of file text.c.

1451 {
1452  NTSTATUS Status;
1453 
1454  if (Console == NULL || Buffer == NULL || Size == NULL)
1455  return STATUS_INVALID_PARAMETER;
1456 
1457  /* Validity check */
1458  ASSERT(Console == Buffer->Header.Console);
1459 
1462 
1463  return Status;
1464 }
#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:372
CConsole Console

Referenced by CSR_API().

◆ ConDrvSetConsoleTextAttribute()

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

Definition at line 1433 of file text.c.

1436 {
1437  if (Console == NULL || Buffer == NULL)
1438  return STATUS_INVALID_PARAMETER;
1439 
1440  /* Validity check */
1441  ASSERT(Console == Buffer->Header.Console);
1442 
1443  Buffer->ScreenDefaultAttrib = (Attributes & ~COMMON_LVB_SBCSDBCS);
1444  return STATUS_SUCCESS;
1445 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
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:2938

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 1592 of file text.c.

1596 {
1597  SMALL_RECT CapturedWindowRect;
1598  COORD LargestWindowSize;
1599 
1600  if (Console == NULL || Buffer == NULL || WindowRect == NULL)
1601  return STATUS_INVALID_PARAMETER;
1602 
1603  /* Validity check */
1604  ASSERT(Console == Buffer->Header.Console);
1605 
1606  CapturedWindowRect = *WindowRect;
1607 
1608  if (!Absolute)
1609  {
1610  /* Relative positions are given, transform them to absolute ones */
1611  CapturedWindowRect.Left += Buffer->ViewOrigin.X;
1612  CapturedWindowRect.Top += Buffer->ViewOrigin.Y;
1613  CapturedWindowRect.Right += Buffer->ViewOrigin.X + Buffer->ViewSize.X - 1;
1614  CapturedWindowRect.Bottom += Buffer->ViewOrigin.Y + Buffer->ViewSize.Y - 1;
1615  }
1616 
1617  /*
1618  * The MSDN documentation on SetConsoleWindowInfo() is partially wrong about
1619  * the performed checks this API performs. While it is correct that the
1620  * 'Right'/'Bottom' members cannot be strictly smaller than the 'Left'/'Top'
1621  * members (the rectangle cannot be empty), they can be equal (describe one cell).
1622  * Also, if the 'Left' or 'Top' members are negative, this is automatically
1623  * corrected for, and the window rectangle coordinates are shifted accordingly.
1624  */
1625  if (ConioIsRectEmpty(&CapturedWindowRect))
1626  {
1627  return STATUS_INVALID_PARAMETER;
1628  }
1629 
1630  /*
1631  * Forbid window sizes larger than the largest allowed console window size,
1632  * taking into account the size of the console screen buffer.
1633  */
1634  TermGetLargestConsoleWindowSize(Console, &LargestWindowSize);
1635  LargestWindowSize.X = min(LargestWindowSize.X, Buffer->ScreenBufferSize.X);
1636  LargestWindowSize.Y = min(LargestWindowSize.Y, Buffer->ScreenBufferSize.Y);
1637  if ((ConioRectWidth(&CapturedWindowRect) > LargestWindowSize.X) ||
1638  (ConioRectHeight(&CapturedWindowRect) > LargestWindowSize.Y))
1639  {
1640  return STATUS_INVALID_PARAMETER;
1641  }
1642 
1643  /* Shift the window rectangle coordinates if 'Left' or 'Top' are negative */
1644  if (CapturedWindowRect.Left < 0)
1645  {
1646  CapturedWindowRect.Right -= CapturedWindowRect.Left;
1647  CapturedWindowRect.Left = 0;
1648  }
1649  if (CapturedWindowRect.Top < 0)
1650  {
1651  CapturedWindowRect.Bottom -= CapturedWindowRect.Top;
1652  CapturedWindowRect.Top = 0;
1653  }
1654 
1655  /* Clip the window rectangle to the screen buffer */
1656  CapturedWindowRect.Right = min(CapturedWindowRect.Right , Buffer->ScreenBufferSize.X);
1657  CapturedWindowRect.Bottom = min(CapturedWindowRect.Bottom, Buffer->ScreenBufferSize.Y);
1658 
1659  Buffer->ViewOrigin.X = CapturedWindowRect.Left;
1660  Buffer->ViewOrigin.Y = CapturedWindowRect.Top;
1661 
1662  Buffer->ViewSize.X = ConioRectWidth(&CapturedWindowRect);
1663  Buffer->ViewSize.Y = ConioRectHeight(&CapturedWindowRect);
1664 
1666 
1667  return STATUS_SUCCESS;
1668 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define TermResizeTerminal(Console)
Definition: term.h:28
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
smooth NULL
Definition: ftsmooth.c:416
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:32
ULONG X
Definition: bl.h:1340
SHORT Bottom
Definition: blue.h:35
#define TermGetLargestConsoleWindowSize(Console, pSize)
Definition: term.h:34
SHORT Top
Definition: blue.h:33
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: bl.h:1338
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
#define ConioIsRectEmpty(Rect)
Definition: rect.h:28
SHORT Right
Definition: blue.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
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 776 of file text.c.

782 {
784  PWCHAR Buffer = NULL;
785  ULONG Written = 0;
786  ULONG Length;
787 
788  if (Console == NULL || ScreenBuffer == NULL /* || StringBuffer == NULL */)
790 
791  /* Validity checks */
792  ASSERT(Console == ScreenBuffer->Header.Console);
793  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCharsToWrite == 0));
794 
795  /* Stop here if the console is paused */
796  if (Console->UnpauseEvent != NULL) return STATUS_PENDING;
797 
798  /* Convert the string to UNICODE */
799  if (Unicode)
800  {
802  }
803  else
804  {
805  Length = MultiByteToWideChar(Console->OutputCodePage, 0,
807  NumCharsToWrite,
808  NULL, 0);
809  Buffer = ConsoleAllocHeap(0, Length * sizeof(WCHAR));
810  if (Buffer)
811  {
812  MultiByteToWideChar(Console->OutputCodePage, 0,
814  NumCharsToWrite,
815  (PWCHAR)Buffer, Length);
816  }
817  else
818  {
820  }
821  }
822 
823  /* Send it */
824  if (Buffer)
825  {
826  if (NT_SUCCESS(Status))
827  {
829  ScreenBuffer,
830  Buffer,
831  NumCharsToWrite,
832  TRUE);
833  if (NT_SUCCESS(Status))
834  {
835  Written = NumCharsToWrite;
836  }
837  }
838 
839  if (!Unicode) ConsoleFreeHeap(Buffer);
840  }
841 
842  if (NumCharsWritten) *NumCharsWritten = Written;
843 
844  return Status;
845 }
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
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
uint16_t * PWCHAR
Definition: typedefs.h:55
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__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
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
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:2938
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 651 of file text.c.

656 {
657  SHORT X, Y;
659  PCHAR_INFO CurCharInfo;
660  SMALL_RECT CapturedWriteRegion;
661  PCHAR_INFO Ptr;
662 
663  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
664  {
666  }
667 
668  /* Validity check */
669  ASSERT(Console == Buffer->Header.Console);
670 
671  CapturedWriteRegion = *WriteRegion;
672 
673  /* Make sure WriteRegion is inside the screen buffer */
675  Buffer->ScreenBufferSize.Y - 1,
676  Buffer->ScreenBufferSize.X - 1);
677  if (!ConioGetIntersection(&CapturedWriteRegion, &CapturedWriteRegion, &ScreenBuffer))
678  {
679  /*
680  * It is okay to have a WriteRegion completely outside
681  * the screen buffer. No data is written then.
682  */
683  return STATUS_SUCCESS;
684  }
685 
686  CurCharInfo = CharInfo;
687 
688  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
689  {
690  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
691  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
692  {
693  if (Unicode)
694  {
695  Ptr->Char.UnicodeChar = CurCharInfo->Char.UnicodeChar;
696  }
697  else
698  {
699  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char.AsciiChar);
700  }
701  // TODO: Sanitize DBCS attributes?
702  Ptr->Attributes = CurCharInfo->Attributes;
703  ++Ptr;
704  ++CurCharInfo;
705  }
706  }
707 
708  TermDrawRegion(Console, &CapturedWriteRegion);
709 
710  *WriteRegion = CapturedWriteRegion;
711 
712  return STATUS_SUCCESS;
713 }
CHAR AsciiChar
Definition: wincon.h:185
#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:156
WCHAR UnicodeChar
Definition: wincon.h:184
_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:31
short SHORT
Definition: pedump.c:59
union _CHAR_INFO::@3176 Char
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:32
SHORT Bottom
Definition: blue.h:35
WORD Attributes
Definition: wincon.h:187
SHORT Top
Definition: blue.h:33
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:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
#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 1174 of file text.c.

1182 {
1183  NTSTATUS Status;
1184 
1185  if (Console == NULL || Buffer == NULL || WriteCoord == NULL /* || EndCoord == NULL */)
1186  {
1187  return STATUS_INVALID_PARAMETER;
1188  }
1189 
1190  /* Validity checks */
1191  ASSERT(Console == Buffer->Header.Console);
1192  ASSERT((StringBuffer != NULL) || (StringBuffer == NULL && NumCodesToWrite == 0));
1193 
1194  if (NumCodesWritten)
1195  *NumCodesWritten = 0;
1196 
1197  if (!StringBuffer || (NumCodesToWrite == 0))
1198  return STATUS_SUCCESS; // Nothing to do!
1199 
1200  /* Do nothing if the writing starting point is outside of the screen buffer */
1201  if ( WriteCoord->X < 0 || WriteCoord->X >= Buffer->ScreenBufferSize.X ||
1202  WriteCoord->Y < 0 || WriteCoord->Y >= Buffer->ScreenBufferSize.Y )
1203  {
1204  return STATUS_SUCCESS;
1205  }
1206 
1207  NumCodesToWrite = min(NumCodesToWrite, (ULONG)Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y);
1208 
1209  switch (CodeType)
1210  {
1211  case CODE_ASCII:
1212  {
1213  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar) == sizeof(CHAR));
1215  Buffer,
1216  StringBuffer,
1217  FALSE,
1218  NumCodesToWrite,
1219  WriteCoord,
1220  NumCodesWritten);
1221  break;
1222  }
1223 
1224  case CODE_UNICODE:
1225  {
1226  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar) == sizeof(WCHAR));
1228  Buffer,
1229  StringBuffer,
1230  TRUE,
1231  NumCodesToWrite,
1232  WriteCoord,
1233  NumCodesWritten);
1234  break;
1235  }
1236 
1237  case CODE_ATTRIBUTE:
1238  {
1239  C_ASSERT(RTL_FIELD_SIZE(CODE_ELEMENT, Attribute) == sizeof(WORD));
1241  Buffer,
1243  NumCodesToWrite,
1244  WriteCoord,
1245  NumCodesWritten);
1246  break;
1247  }
1248 
1249  default:
1250  return STATUS_INVALID_PARAMETER;
1251  }
1252 
1253  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
1254  {
1256  ConioComputeUpdateRect(Buffer, &UpdateRect, WriteCoord, NumCodesToWrite);
1258  }
1259 
1260  return Status;
1261 }
#define RTL_FIELD_SIZE(type, field)
Definition: kdb_expr.c:84
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#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:178
static NTSTATUS IntWriteConsoleOutputStringChars(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PVOID StringBuffer, IN BOOLEAN Unicode, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:1029
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define C_ASSERT(e)
Definition: intsafe.h:79
WORD * PWORD
Definition: pedump.c:67
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short WORD
Definition: ntddk_ex.h:93
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static NTSTATUS IntWriteConsoleOutputStringAttribute(IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PWORD StringBuffer, IN ULONG NumCodesToWrite, IN PCOORD WriteCoord, OUT PULONG NumCodesWritten OPTIONAL)
Definition: text.c:1133
Status
Definition: gdiplustypes.h:24
#define min(a, b)
Definition: monoChain.cc:55
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:2938
WCHAR StringBuffer[156]
Definition: ldrinit.c:41

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 721 of file text.c.

726 {
727  SHORT X, Y;
729  PCHAR_CELL CurCharInfo;
730  SMALL_RECT CapturedWriteRegion;
731  PCHAR_INFO Ptr;
732 
733  if (Console == NULL || Buffer == NULL || CharInfo == NULL || WriteRegion == NULL)
734  {
736  }
737 
738  /* Validity check */
739  ASSERT(Console == Buffer->Header.Console);
740 
741  CapturedWriteRegion = *WriteRegion;
742 
743  /* Make sure WriteRegion is inside the screen buffer */
745  Buffer->ScreenBufferSize.Y - 1,
746  Buffer->ScreenBufferSize.X - 1);
747  if (!ConioGetIntersection(&CapturedWriteRegion, &CapturedWriteRegion, &ScreenBuffer))
748  {
749  /*
750  * It is okay to have a WriteRegion completely outside
751  * the screen buffer. No data is written then.
752  */
753  return STATUS_SUCCESS;
754  }
755 
756  // CurCharInfo = CharInfo;
757 
758  for (Y = CapturedWriteRegion.Top; Y <= CapturedWriteRegion.Bottom; ++Y)
759  {
760  CurCharInfo = CharInfo + Y * CharInfoSize.X + CapturedWriteRegion.Left;
761 
762  Ptr = ConioCoordToPointer(Buffer, CapturedWriteRegion.Left, Y);
763  for (X = CapturedWriteRegion.Left; X <= CapturedWriteRegion.Right; ++X)
764  {
765  ConsoleOutputAnsiToUnicodeChar(Console, &Ptr->Char.UnicodeChar, &CurCharInfo->Char);
766  Ptr->Attributes = CurCharInfo->Attributes;
767  ++Ptr;
768  ++CurCharInfo;
769  }
770  }
771 
772  return STATUS_SUCCESS;
773 }
#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:156
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
Definition: text.c:31
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:32
CHAR Char
Definition: svga.h:392
SHORT Bottom
Definition: blue.h:35
SHORT Top
Definition: blue.h:33
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:34
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define X(b, s)

Referenced by CSR_API().

◆ CSR_API() [1/18]

CSR_API ( SrvInvalidateBitMapRect  )

Definition at line 34 of file conoutput.c.

35 {
37  PCONSOLE_INVALIDATEDIBITS InvalidateDIBitsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.InvalidateDIBitsRequest;
39 
40  DPRINT("SrvInvalidateBitMapRect\n");
41 
43  InvalidateDIBitsRequest->OutputHandle,
45  if (!NT_SUCCESS(Status)) return Status;
46 
47  /* In text-mode only, draw the VDM buffer if present */
48  if (GetType(Buffer) == TEXTMODE_BUFFER && Buffer->Header.Console->VDMBuffer)
49  {
51 
52  /*Status =*/ ConDrvWriteConsoleOutputVDM(Buffer->Header.Console,
53  TextBuffer,
54  Buffer->Header.Console->VDMBuffer,
55  Buffer->Header.Console->VDMBufferSize,
56  &InvalidateDIBitsRequest->Region);
57  }
58 
59  Status = ConDrvInvalidateBitMapRect(Buffer->Header.Console,
60  Buffer,
61  &InvalidateDIBitsRequest->Region);
62 
64  return Status;
65 }
#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:721
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 74 of file conoutput.c.

75 {
77  PCONSOLE_SETPALETTE SetPaletteRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetPaletteRequest;
78  // PGRAPHICS_SCREEN_BUFFER Buffer;
80 
81  DPRINT("SrvSetConsolePalette\n");
82 
83  // NOTE: Tests show that this function is used only for graphics screen buffers
84  // and otherwise it returns FALSE + sets last error to invalid handle.
85  // I think it's ridiculous, because if you are in text mode, simulating
86  // a change of VGA palette via DAC registers (done by a call to SetConsolePalette)
87  // cannot be done... So I allow it in ReactOS !
88  /*
89  Status = ConSrvGetGraphicsBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
90  SetPaletteRequest->OutputHandle,
91  &Buffer, GENERIC_WRITE, TRUE);
92  */
94  SetPaletteRequest->OutputHandle,
96  if (!NT_SUCCESS(Status)) return Status;
97 
98  /*
99  * Make the palette handle public, so that it can be
100  * used by other threads calling GDI functions on it.
101  * Indeed, the palette handle comes from a console app
102  * calling ourselves, running in CSRSS.
103  */
105  &SetPaletteRequest->PaletteHandle,
106  sizeof(SetPaletteRequest->PaletteHandle));
107 
108  Status = ConDrvSetConsolePalette(Buffer->Header.Console,
109  Buffer,
110  SetPaletteRequest->PaletteHandle,
111  SetPaletteRequest->Usage);
112 
114  return Status;
115 }
#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 122 of file conoutput.c.

123 {
125  PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CursorInfoRequest;
127 
128  DPRINT("SrvGetConsoleCursorInfo\n");
129 
131  CursorInfoRequest->OutputHandle,
133  if (!NT_SUCCESS(Status)) return Status;
134 
135  Status = ConDrvGetConsoleCursorInfo(Buffer->Header.Console,
136  Buffer,
137  &CursorInfoRequest->Info);
138 
140  return Status;
141 }
#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 148 of file conoutput.c.

149 {
151  PCONSOLE_GETSETCURSORINFO CursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CursorInfoRequest;
153 
154  DPRINT("SrvSetConsoleCursorInfo\n");
155 
157  CursorInfoRequest->OutputHandle,
159  if (!NT_SUCCESS(Status)) return Status;
160 
161  Status = ConDrvSetConsoleCursorInfo(Buffer->Header.Console,
162  Buffer,
163  &CursorInfoRequest->Info);
164 
166  return Status;
167 }
#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 174 of file conoutput.c.

175 {
177  PCONSOLE_SETCURSORPOSITION SetCursorPositionRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorPositionRequest;
179 
180  DPRINT("SrvSetConsoleCursorPosition\n");
181 
183  SetCursorPositionRequest->OutputHandle,
185  if (!NT_SUCCESS(Status)) return Status;
186 
187  Status = ConDrvSetConsoleCursorPosition(Buffer->Header.Console,
188  Buffer,
189  &SetCursorPositionRequest->Position);
190 
192  return Status;
193 }
#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 196 of file conoutput.c.

197 {
199  PCONSOLE_CREATESCREENBUFFER CreateScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CreateScreenBufferRequest;
204 
206  TEXTMODE_BUFFER_INFO TextModeInfo = {{80, 25},
207  {80, 25},
210  TRUE,
212  GRAPHICS_BUFFER_INFO GraphicsInfo;
213  GraphicsInfo.Info = CreateScreenBufferRequest->GraphicsBufferInfo; // HACK for MSVC
214 
215  DPRINT("SrvCreateConsoleScreenBuffer\n");
216 
217  Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
218  if (!NT_SUCCESS(Status)) return Status;
219 
220  if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_TEXTMODE_BUFFER)
221  {
222  ScreenBufferInfo = &TextModeInfo;
223 
224  /*
225  * This is Windows behaviour, as described by MSDN and verified manually:
226  *
227  * The newly created screen buffer will copy some properties from the
228  * active screen buffer at the time that this function is called.
229  * The behavior is as follows:
230  * Font - copied from active screen buffer.
231  * Display Window Size - copied from active screen buffer.
232  * Buffer Size - matched to Display Window Size (NOT copied).
233  * Default Attributes (colors) - copied from active screen buffer.
234  * Default Popup Attributes (colors) - copied from active screen buffer.
235  */
236 
237  /* If we have an active screen buffer, use its attributes as the new ones */
238  if (Console->ActiveBuffer && GetType(Console->ActiveBuffer) == TEXTMODE_BUFFER)
239  {
241 
242  TextModeInfo.ScreenAttrib = Buffer->ScreenDefaultAttrib;
243  TextModeInfo.PopupAttrib = Buffer->PopupDefaultAttrib;
244 
245  TextModeInfo.CursorSize = Buffer->CursorInfo.dwSize;
246  TextModeInfo.IsCursorVisible = Buffer->CursorInfo.bVisible;
247 
248  /* Use the current view size */
249  TextModeInfo.ScreenBufferSize = Buffer->ViewSize;
250  TextModeInfo.ViewSize = Buffer->ViewSize;
251  }
252  else
253  {
254  /* Use the current console size */
255  TextModeInfo.ScreenBufferSize = Console->ConsoleSize;
256  TextModeInfo.ViewSize = Console->ConsoleSize;
257  }
258 
259  /* Normalize the screen buffer size if needed */
260  if (TextModeInfo.ScreenBufferSize.X == 0) TextModeInfo.ScreenBufferSize.X = 1;
261  if (TextModeInfo.ScreenBufferSize.Y == 0) TextModeInfo.ScreenBufferSize.Y = 1;
262  }
263  else if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_GRAPHICS_BUFFER)
264  {
265  /* Get information from the graphics buffer information structure */
266  if (!CsrValidateMessageBuffer(ApiMessage,
267  (PVOID*)&CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMapInfo,
268  CreateScreenBufferRequest->GraphicsBufferInfo.dwBitMapInfoLength,
269  sizeof(BYTE)))
270  {
272  goto Quit;
273  }
274 
275  ScreenBufferInfo = &GraphicsInfo;
276 
277  /* Initialize shared variables */
278  // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
279  CreateScreenBufferRequest->hMutex = GraphicsInfo.Info.hMutex = INVALID_HANDLE_VALUE;
280  // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
281  CreateScreenBufferRequest->lpBitMap = GraphicsInfo.Info.lpBitMap = NULL;
282 
283  /* A graphics screen buffer is never inheritable */
284  CreateScreenBufferRequest->InheritHandle = FALSE;
285  }
286 
288  (PCONSOLE)Console,
289  Process->ProcessHandle,
290  CreateScreenBufferRequest->ScreenBufferType,
292  if (!NT_SUCCESS(Status)) goto Quit;
293 
294  /* Insert the new handle inside the process handles table */
296 
297  Status = ConSrvInsertObject(ProcessData,
298  &CreateScreenBufferRequest->OutputHandle,
299  &Buff->Header,
300  CreateScreenBufferRequest->DesiredAccess,
301  CreateScreenBufferRequest->InheritHandle,
302  CreateScreenBufferRequest->ShareMode);
303 
305 
306  if (!NT_SUCCESS(Status)) goto Quit;
307 
308  if (CreateScreenBufferRequest->ScreenBufferType == CONSOLE_GRAPHICS_BUFFER)
309  {
311  /*
312  * Initialize the graphics buffer information structure
313  * and give it back to the client.
314  */
315  // CreateScreenBufferRequest->GraphicsBufferInfo.hMutex
316  CreateScreenBufferRequest->hMutex = Buffer->ClientMutex;
317  // CreateScreenBufferRequest->GraphicsBufferInfo.lpBitMap
318  CreateScreenBufferRequest->lpBitMap = Buffer->ClientBitMap;
319  }
320 
321 Quit:
323  return Status;
324 }
CONSOLE_GRAPHICS_BUFFER_INFO Info
Definition: conio.h:168
#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:399
BOOLEAN IsCursorVisible
Definition: conio.h:148
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
LPBITMAPINFO lpBitMapInfo
Definition: wincon.h:230
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:146
Status
Definition: gdiplustypes.h:24
#define DEFAULT_POPUP_ATTRIB
Definition: settings.c:30
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62
#define CONSOLE_GRAPHICS_BUFFER
Definition: wincon.h:63
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:145
RTL_CRITICAL_SECTION HandleTableLock
Definition: consrv.h:48

◆ CSR_API() [7/18]

CSR_API ( SrvSetConsoleActiveScreenBuffer  )

Definition at line 330 of file conoutput.c.

331 {
333  PCONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetScreenBufferRequest;
335 
336  DPRINT("SrvSetConsoleActiveScreenBuffer\n");
337 
339  SetScreenBufferRequest->OutputHandle,
341  if (!NT_SUCCESS(Status)) return Status;
342 
344  Buffer);
345 
347  return Status;
348 }
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 493 of file conoutput.c.

494 {
496  PCONSOLE_READOUTPUT ReadOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadOutputRequest;
498 
499  ULONG NumCells;
500  PCHAR_INFO CharInfo;
501 
502  DPRINT("SrvReadConsoleOutput\n");
503 
504  NumCells = ConioRectWidth(&ReadOutputRequest->ReadRegion) *
505  ConioRectHeight(&ReadOutputRequest->ReadRegion);
506 
507  /*
508  * For optimization purposes, Windows (and hence ReactOS, too, for
509  * compatibility reasons) uses a static buffer if no more than one
510  * cell is read. Otherwise a new buffer is used.
511  * The client-side expects that we know this behaviour.
512  */
513  if (NumCells <= 1)
514  {
515  /*
516  * Adjust the internal pointer, because its old value points to
517  * the static buffer in the original ApiMessage structure.
518  */
519  // ReadOutputRequest->CharInfo = &ReadOutputRequest->StaticBuffer;
520  CharInfo = &ReadOutputRequest->StaticBuffer;
521  }
522  else
523  {
524  if (!CsrValidateMessageBuffer(ApiMessage,
525  (PVOID*)&ReadOutputRequest->CharInfo,
526  NumCells,
527  sizeof(CHAR_INFO)))
528  {
530  }
531 
532  CharInfo = ReadOutputRequest->CharInfo;
533  }
534 
536  ReadOutputRequest->OutputHandle,
538  if (!NT_SUCCESS(Status)) return Status;
539 
540  Status = ConDrvReadConsoleOutput(Buffer->Header.Console,
541  Buffer,
542  ReadOutputRequest->Unicode,
543  CharInfo,
544  &ReadOutputRequest->ReadRegion);
545 
547  return Status;
548 }
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
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
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
PCHAR_INFO CharInfo
Definition: conmsg.h:590
#define ConSrvReleaseScreenBuffer(Buff, IsConsoleLocked)
Definition: conoutput.h:33
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:582
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 557 of file conoutput.c.

558 {
560  PCONSOLE_WRITEOUTPUT WriteOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteOutputRequest;
563 
564  ULONG NumCells;
565  PCHAR_INFO CharInfo;
566 
567  DPRINT("SrvWriteConsoleOutput\n");
568 
569  NumCells = ConioRectWidth(&WriteOutputRequest->WriteRegion) *
570  ConioRectHeight(&WriteOutputRequest->WriteRegion);
571 
573  WriteOutputRequest->OutputHandle,
575  if (!NT_SUCCESS(Status)) return Status;
576 
577  /*
578  * Validate the message buffer if we do not use a process' heap buffer
579  * (CsrAllocateCaptureBuffer succeeded because we haven't allocated
580  * a too large (>= 64 kB, size of the CSR heap) data buffer).
581  */
582  if (!WriteOutputRequest->UseVirtualMemory)
583  {
584  /*
585  * For optimization purposes, Windows (and hence ReactOS, too, for
586  * compatibility reasons) uses a static buffer if no more than one
587  * cell is written. Otherwise a new buffer is used.
588  * The client-side expects that we know this behaviour.
589  */
590  if (NumCells <= 1)
591  {
592  /*
593  * Adjust the internal pointer, because its old value points to
594  * the static buffer in the original ApiMessage structure.
595  */
596  // WriteOutputRequest->CharInfo = &WriteOutputRequest->StaticBuffer;
597  CharInfo = &WriteOutputRequest->StaticBuffer;
598  }
599  else
600  {
601  if (!CsrValidateMessageBuffer(ApiMessage,
602  (PVOID*)&WriteOutputRequest->CharInfo,
603  NumCells,
604  sizeof(CHAR_INFO)))
605  {
607  goto Quit;
608  }
609 
610  CharInfo = WriteOutputRequest->CharInfo;
611  }
612  }
613  else
614  {
615  /*
616  * This was not the case: we use a heap buffer. Retrieve its contents.
617  */
618  ULONG Size = NumCells * sizeof(CHAR_INFO);
619 
621  if (CharInfo == NULL)
622  {
624  goto Quit;
625  }
626 
627  Status = NtReadVirtualMemory(Process->ProcessHandle,
628  WriteOutputRequest->CharInfo,
629  CharInfo,
630  Size,
631  NULL);
632  if (!NT_SUCCESS(Status))
633  {
634  ConsoleFreeHeap(CharInfo);
635  // Status = STATUS_NO_MEMORY;
636  goto Quit;
637  }
638  }
639 
640  Status = ConDrvWriteConsoleOutput(Buffer->Header.Console,
641  Buffer,
642  WriteOutputRequest->Unicode,
643  CharInfo,
644  &WriteOutputRequest->WriteRegion);
645 
646  /* Free the temporary buffer if we used the process' heap buffer */
647  if (WriteOutputRequest->UseVirtualMemory && CharInfo)
648  ConsoleFreeHeap(CharInfo);
649 
650 Quit:
652  return Status;
653 }
#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 ConioRectWidth(Rect)
Definition: readwrite.c:24
#define GENERIC_WRITE
Definition: nt_native.h:90
struct _CHAR_INFO CHAR_INFO
smooth NULL
Definition: ftsmooth.c:416
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
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:651
CHAR_INFO StaticBuffer
Definition: conmsg.h:601
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
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
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
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 656 of file conoutput.c.

657 {
659  PCONSOLE_WRITECONSOLE WriteConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleRequest;
660 
661  DPRINT("SrvWriteConsole\n");
662 
663  /*
664  * For optimization purposes, Windows (and hence ReactOS, too, for
665  * compatibility reasons) uses a static buffer if no more than eighty
666  * bytes are written. Otherwise a new buffer is used.
667  * The client-side expects that we know this behaviour.
668  */
669  if (WriteConsoleRequest->UsingStaticBuffer &&
670  WriteConsoleRequest->NumBytes <= sizeof(WriteConsoleRequest->StaticBuffer))
671  {
672  /*
673  * Adjust the internal pointer, because its old value points to
674  * the static buffer in the original ApiMessage structure.
675  */
676  // WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer;
677  }
678  else
679  {
680  if (!CsrValidateMessageBuffer(ApiMessage,
681  (PVOID)&WriteConsoleRequest->Buffer,
682  WriteConsoleRequest->NumBytes,
683  sizeof(BYTE)))
684  {
686  }
687  }
688 
689  Status = DoWriteConsole(ApiMessage, CsrGetClientThread(), TRUE);
690 
691  if (Status == STATUS_PENDING) *ReplyCode = CsrReplyPending;
692 
693  return Status;
694 }
#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:403
#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 706 of file conoutput.c.

707 {
709  PCONSOLE_READOUTPUTCODE ReadOutputCodeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadOutputCodeRequest;
711  ULONG CodeSize;
712 
713  PVOID pCode;
714 
715  DPRINT("SrvReadConsoleOutputString\n");
716 
717  switch (ReadOutputCodeRequest->CodeType)
718  {
719  case CODE_ASCII:
720  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
721  break;
722 
723  case CODE_UNICODE:
724  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
725  break;
726 
727  case CODE_ATTRIBUTE:
728  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
729  break;
730 
731  default:
733  }
734 
735  /*
736  * For optimization purposes, Windows (and hence ReactOS, too, for
737  * compatibility reasons) uses a static buffer if no more than eighty
738  * bytes are read. Otherwise a new buffer is used.
739  * The client-side expects that we know this behaviour.
740  */
741  if (ReadOutputCodeRequest->NumCodes * CodeSize <= sizeof(ReadOutputCodeRequest->CodeStaticBuffer))
742  {
743  /*
744  * Adjust the internal pointer, because its old value points to
745  * the static buffer in the original ApiMessage structure.
746  */
747  // ReadOutputCodeRequest->pCode = ReadOutputCodeRequest->CodeStaticBuffer;
748  pCode = ReadOutputCodeRequest->CodeStaticBuffer;
749  }
750  else
751  {
752  if (!CsrValidateMessageBuffer(ApiMessage,
753  (PVOID*)&ReadOutputCodeRequest->pCode,
754  ReadOutputCodeRequest->NumCodes,
755  CodeSize))
756  {
758  }
759 
760  pCode = ReadOutputCodeRequest->pCode;
761  }
762 
764  ReadOutputCodeRequest->OutputHandle,
766  if (!NT_SUCCESS(Status))
767  {
768  ReadOutputCodeRequest->NumCodes = 0;
769  return Status;
770  }
771 
772  Status = ConDrvReadConsoleOutputString(Buffer->Header.Console,
773  Buffer,
774  ReadOutputCodeRequest->CodeType,
775  pCode,
776  ReadOutputCodeRequest->NumCodes,
777  &ReadOutputCodeRequest->Coord,
778  // &ReadOutputCodeRequest->EndCoord,
779  &ReadOutputCodeRequest->NumCodes);
780 
782  return Status;
783 }
#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:955
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [12/18]

CSR_API ( SrvWriteConsoleOutputString  )

Definition at line 795 of file conoutput.c.

796 {
798  PCONSOLE_WRITEOUTPUTCODE WriteOutputCodeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteOutputCodeRequest;
800  ULONG CodeSize;
801 
802  PVOID pCode;
803 
804  DPRINT("SrvWriteConsoleOutputString\n");
805 
806  switch (WriteOutputCodeRequest->CodeType)
807  {
808  case CODE_ASCII:
809  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, AsciiChar);
810  break;
811 
812  case CODE_UNICODE:
813  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, UnicodeChar);
814  break;
815 
816  case CODE_ATTRIBUTE:
817  CodeSize = RTL_FIELD_SIZE(CODE_ELEMENT, Attribute);
818  break;
819 
820  default:
822  }
823 
824  /*
825  * For optimization purposes, Windows (and hence ReactOS, too, for
826  * compatibility reasons) uses a static buffer if no more than eighty
827  * bytes are written. Otherwise a new buffer is used.
828  * The client-side expects that we know this behaviour.
829  */
830  if (WriteOutputCodeRequest->NumCodes * CodeSize <= sizeof(WriteOutputCodeRequest->CodeStaticBuffer))
831  {
832  /*
833  * Adjust the internal pointer, because its old value points to
834  * the static buffer in the original ApiMessage structure.
835  */
836  // WriteOutputCodeRequest->pCode = WriteOutputCodeRequest->CodeStaticBuffer;
837  pCode = WriteOutputCodeRequest->CodeStaticBuffer;
838  }
839  else
840  {
841  if (!CsrValidateMessageBuffer(ApiMessage,
842  (PVOID*)&WriteOutputCodeRequest->pCode,
843  WriteOutputCodeRequest->NumCodes,
844  CodeSize))
845  {
847  }
848 
849  pCode = WriteOutputCodeRequest->pCode;
850  }
851 
853  WriteOutputCodeRequest->OutputHandle,
855  if (!NT_SUCCESS(Status))
856  {
857  WriteOutputCodeRequest->NumCodes = 0;
858  return Status;
859  }
860 
861  Status = ConDrvWriteConsoleOutputString(Buffer->Header.Console,
862  Buffer,
863  WriteOutputCodeRequest->CodeType,
864  pCode,
865  WriteOutputCodeRequest->NumCodes,
866  &WriteOutputCodeRequest->Coord,
867  // &WriteOutputCodeRequest->EndCoord,
868  &WriteOutputCodeRequest->NumCodes);
869 
871  return Status;
872 }
#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:1174
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 883 of file conoutput.c.

884 {
886  PCONSOLE_FILLOUTPUTCODE FillOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputRequest;
888  CODE_TYPE CodeType = FillOutputRequest->CodeType;
889 
890  DPRINT("SrvFillConsoleOutput\n");
891 
892  if ( (CodeType != CODE_ASCII ) &&
893  (CodeType != CODE_UNICODE ) &&
894  (CodeType != CODE_ATTRIBUTE) )
895  {
897  }
898 
900  FillOutputRequest->OutputHandle,
902  if (!NT_SUCCESS(Status))
903  {
904  FillOutputRequest->NumCodes = 0;
905  return Status;
906  }
907 
908  Status = ConDrvFillConsoleOutput(Buffer->Header.Console,
909  Buffer,
910  CodeType,
911  FillOutputRequest->Code,
912  FillOutputRequest->NumCodes,
913  &FillOutputRequest->WriteCoord,
914  &FillOutputRequest->NumCodes);
915 
917  return Status;
918 }
#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:1264

◆ CSR_API() [14/18]

CSR_API ( SrvGetConsoleScreenBufferInfo  )

Definition at line 930 of file conoutput.c.

931 {
933  PCONSOLE_GETSCREENBUFFERINFO ScreenBufferInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScreenBufferInfoRequest;
935 
936  DPRINT("SrvGetConsoleScreenBufferInfo\n");
937 
939  ScreenBufferInfoRequest->OutputHandle,
941  if (!NT_SUCCESS(Status)) return Status;
942 
944  Buffer,
945  &ScreenBufferInfoRequest->ScreenBufferSize,
946  &ScreenBufferInfoRequest->CursorPosition,
947  &ScreenBufferInfoRequest->ViewOrigin,
948  &ScreenBufferInfoRequest->ViewSize,
949  &ScreenBufferInfoRequest->MaximumViewSize,
950  &ScreenBufferInfoRequest->Attributes);
951 
953  return Status;
954 }
#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:1393
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [15/18]

CSR_API ( SrvSetConsoleTextAttribute  )

Definition at line 961 of file conoutput.c.

962 {
964  PCONSOLE_SETTEXTATTRIB SetTextAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetTextAttribRequest;
966 
967  DPRINT("SrvSetConsoleTextAttribute\n");
968 
970  SetTextAttribRequest->OutputHandle,
972  if (!NT_SUCCESS(Status)) return Status;
973 
974  Status = ConDrvSetConsoleTextAttribute(Buffer->Header.Console,
975  Buffer,
976  SetTextAttribRequest->Attributes);
977 
979  return Status;
980 }
#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:1433
#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 987 of file conoutput.c.

988 {
990  PCONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetScreenBufferSizeRequest;
992 
993  DPRINT("SrvSetConsoleScreenBufferSize\n");
994 
996  SetScreenBufferSizeRequest->OutputHandle,
998  if (!NT_SUCCESS(Status)) return Status;
999 
1001  Buffer,
1002  &SetScreenBufferSizeRequest->Size);
1003 
1005  return Status;
1006 }
#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:1448
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [17/18]

CSR_API ( SrvScrollConsoleScreenBuffer  )

Definition at line 1018 of file conoutput.c.

1019 {
1020  NTSTATUS Status;
1021  PCONSOLE_SCROLLSCREENBUFFER ScrollScreenBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScrollScreenBufferRequest;
1023 
1024  DPRINT("SrvScrollConsoleScreenBuffer\n");
1025 
1027  ScrollScreenBufferRequest->OutputHandle,
1029  if (!NT_SUCCESS(Status)) return Status;
1030 
1031  Status = ConDrvScrollConsoleScreenBuffer(Buffer->Header.Console,
1032  Buffer,
1033  ScrollScreenBufferRequest->Unicode,
1034  &ScrollScreenBufferRequest->ScrollRectangle,
1035  ScrollScreenBufferRequest->UseClipRectangle,
1036  &ScrollScreenBufferRequest->ClipRectangle,
1037  &ScrollScreenBufferRequest->DestinationOrigin,
1038  ScrollScreenBufferRequest->Fill);
1039 
1041  return Status;
1042 }
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:1467
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34

◆ CSR_API() [18/18]

CSR_API ( SrvSetConsoleWindowInfo  )

Definition at line 1050 of file conoutput.c.

1051 {
1052  NTSTATUS Status;
1053  PCONSOLE_SETWINDOWINFO SetWindowInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetWindowInfoRequest;
1054  // PCONSOLE_SCREEN_BUFFER Buffer;
1056 
1057  DPRINT("SrvSetConsoleWindowInfo(0x%08x, %d, {L%d, T%d, R%d, B%d}) called\n",
1058  SetWindowInfoRequest->OutputHandle, SetWindowInfoRequest->Absolute,
1059  SetWindowInfoRequest->WindowRect.Left ,
1060  SetWindowInfoRequest->WindowRect.Top ,
1061  SetWindowInfoRequest->WindowRect.Right,
1062  SetWindowInfoRequest->WindowRect.Bottom);
1063 
1064  // ConSrvGetScreenBuffer
1066  SetWindowInfoRequest->OutputHandle,
1067  &Buffer, GENERIC_READ, TRUE);
1068  if (!NT_SUCCESS(Status)) return Status;
1069 
1070  Status = ConDrvSetConsoleWindowInfo(Buffer->Header.Console,
1071  Buffer,
1072  SetWindowInfoRequest->Absolute,
1073  &SetWindowInfoRequest->WindowRect);
1074 
1076  return Status;
1077 }
#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
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
SHORT Left
Definition: blue.h:32
#define ConSrvGetTextModeBuffer(ProcessData, Handle, Ptr, Access, LockConsole)
Definition: conoutput.h:12
SHORT Bottom
Definition: blue.h:35
#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:33
#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:1592
_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:34
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 403 of file conoutput.c.

406 {
408  PCONSOLE_WRITECONSOLE WriteConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleRequest;
410 
411  PVOID Buffer;
412  ULONG NrCharactersWritten = 0;
413  ULONG CharSize = (WriteConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR));
414 
416  WriteConsoleRequest->OutputHandle,
418  if (!NT_SUCCESS(Status)) return Status;
419 
420  /*
421  * For optimization purposes, Windows (and hence ReactOS, too, for
422  * compatibility reasons) uses a static buffer if no more than eighty
423  * bytes are written. Otherwise a new buffer is used.
424  * The client-side expects that we know this behaviour.
425  */
426  if (WriteConsoleRequest->UsingStaticBuffer &&
427  WriteConsoleRequest->NumBytes <= sizeof(WriteConsoleRequest->StaticBuffer))
428  {
429  /*
430  * Adjust the internal pointer, because its old value points to
431  * the static buffer in the original ApiMessage structure.
432  */
433  // WriteConsoleRequest->Buffer = WriteConsoleRequest->StaticBuffer;
434  Buffer = WriteConsoleRequest->StaticBuffer;
435  }
436  else
437  {
438  Buffer = WriteConsoleRequest->Buffer;
439  }
440 
441  DPRINT("Calling ConDrvWriteConsole\n");
442  Status = ConDrvWriteConsole(ScreenBuffer->Header.Console,
443  ScreenBuffer,
444  WriteConsoleRequest->Unicode,
445  Buffer,
446  WriteConsoleRequest->NumBytes / CharSize, // NrCharactersToWrite
447  &NrCharactersWritten);
448  DPRINT("ConDrvWriteConsole returned (%d ; Status = 0x%08x)\n",
449  NrCharactersWritten, Status);
450 
451  if (Status == STATUS_PENDING)
452  {
453  if (CreateWaitBlock)
454  {
456 
457  if (!CsrCreateWait(&Console->WriteWaitQueue,
459  ClientThread,
460  ApiMessage,
461  NULL))
462  {
463  /* Fail */
465  goto Quit;
466  }
467  }
468 
469  /* Wait until we un-pause the console */
470  // Status = STATUS_PENDING;
471  }
472  else
473  {
474  /* We read all what we wanted. Set the number of bytes written. */
475  WriteConsoleRequest->NumBytes = NrCharactersWritten * CharSize;
476  }
477 
478 Quit:
480  return Status;
481 }
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:361
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:776

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 361 of file conoutput.c.

368 {
370 
371  DPRINT("WriteConsoleThread - WaitContext = 0x%p, WaitArgument1 = 0x%p, WaitArgument2 = 0x%p, WaitFlags = %lu\n", WaitContext, WaitArgument1, WaitArgument2, WaitFlags);
372 
373  /*
374  * If we are notified of the process termination via a call
375  * to CsrNotifyWaitBlock triggered by CsrDestroyProcess or
376  * CsrDestroyThread, just return.
377  */
378  if (WaitFlags & CsrProcessTerminating)
379  {
381  goto Quit;
382  }
383 
384  Status = DoWriteConsole(WaitApiMessage, WaitThread, FALSE);
385 
386 Quit:
387  if (Status != STATUS_PENDING)
388  {
389  WaitApiMessage->Status = Status;
390  }
391 
392  return (Status == STATUS_PENDING ? FALSE : TRUE);
393 }
#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:403
#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().