ReactOS  0.4.13-dev-259-g5ca9c9c
text.c File Reference
#include <consrv.h>
#include <debug.h>
Include dependency graph for text.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ConsoleOutputUnicodeToAnsiChar(Console, dChar, sWChar)
 
#define ConsoleOutputAnsiToUnicodeChar(Console, dWChar, sChar)
 

Functions

CONSOLE_IO_OBJECT_TYPE TEXTMODE_BUFFER_GetType (PCONSOLE_SCREEN_BUFFER This)
 
VOID ClearLineBuffer (PTEXTMODE_SCREEN_BUFFER Buff)
 
NTSTATUS CONSOLE_SCREEN_BUFFER_Initialize (OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER_VTBL Vtbl, IN SIZE_T Size)
 
VOID CONSOLE_SCREEN_BUFFER_Destroy (IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
 
NTSTATUS TEXTMODE_BUFFER_Initialize (OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN HANDLE ProcessHandle, IN PTEXTMODE_BUFFER_INFO TextModeInfo)
 
VOID TEXTMODE_BUFFER_Destroy (IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
 
PCHAR_INFO ConioCoordToPointer (PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
 
static VOID ConioComputeUpdateRect (IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
 
static VOID ConioMoveRegion (PTEXTMODE_SCREEN_BUFFER ScreenBuffer, PSMALL_RECT SrcRegion, PSMALL_RECT DstRegion, PSMALL_RECT ClipRegion, CHAR_INFO FillChar)
 
NTSTATUS NTAPI ConDrvWriteConsoleInput (IN PCONSOLE Console, IN PCONSOLE_INPUT_BUFFER InputBuffer, IN BOOLEAN AppendToEnd, IN PINPUT_RECORD InputRecord, IN ULONG NumEventsToWrite, OUT PULONG NumEventsWritten OPTIONAL)
 
NTSTATUS ConioResizeBuffer (PCONSOLE Console, PTEXTMODE_SCREEN_BUFFER ScreenBuffer, COORD Size)
 
NTSTATUS NTAPI ConDrvChangeScreenBufferAttributes (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN USHORT NewScreenAttrib, IN USHORT NewPopupAttrib)
 
NTSTATUS NTAPI ConDrvReadConsoleOutput (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, OUT PCHAR_INFO CharInfo, IN OUT PSMALL_RECT ReadRegion)
 
NTSTATUS NTAPI ConDrvWriteConsoleOutput (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Unicode, IN PCHAR_INFO CharInfo, IN OUT PSMALL_RECT WriteRegion)
 
NTSTATUS NTAPI ConDrvWriteConsoleOutputVDM (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCHAR_CELL CharInfo, IN COORD CharInfoSize, IN PSMALL_RECT WriteRegion)
 
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 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)
 
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)
 
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)
 
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)
 
NTSTATUS NTAPI ConDrvSetConsoleTextAttribute (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN WORD Attributes)
 
NTSTATUS NTAPI ConDrvSetConsoleScreenBufferSize (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN PCOORD Size)
 
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)
 
NTSTATUS NTAPI ConDrvSetConsoleWindowInfo (IN PCONSOLE Console, IN PTEXTMODE_SCREEN_BUFFER Buffer, IN BOOLEAN Absolute, IN PSMALL_RECT WindowRect)
 

Variables

static CONSOLE_SCREEN_BUFFER_VTBL TextVtbl
 

Macro Definition Documentation

◆ ConsoleOutputAnsiToUnicodeChar

#define ConsoleOutputAnsiToUnicodeChar (   Console,
  dWChar,
  sChar 
)
Value:
ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1)
uint32_t ULONG_PTR
Definition: typedefs.h:63
UINT OutputCodePage
Definition: console.c:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console

Definition at line 29 of file text.c.

◆ ConsoleOutputUnicodeToAnsiChar

#define ConsoleOutputUnicodeToAnsiChar (   Console,
  dChar,
  sWChar 
)
Value:
ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
WideCharToMultiByte((Console)->OutputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
UINT OutputCodePage
Definition: console.c:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console

Definition at line 25 of file text.c.

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file text.c.

Function Documentation

◆ ClearLineBuffer()

static VOID FASTCALL ClearLineBuffer ( PTEXTMODE_SCREEN_BUFFER  Buff)

Definition at line 146 of file text.c.

147 {
148  PCHAR_INFO Ptr = ConioCoordToPointer(Buff, 0, Buff->CursorPosition.Y);
149  SHORT Pos;
150 
151  for (Pos = 0; Pos < Buff->ScreenBufferSize.X; Pos++, Ptr++)
152  {
153  /* Fill the cell */
154  Ptr->Char.UnicodeChar = L' ';
155  Ptr->Attributes = Buff->ScreenDefaultAttrib;
156  }
157 }
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
ush Pos
Definition: deflate.h:92
short SHORT
Definition: pedump.c:59
static const WCHAR L[]
Definition: oid.c:1250

Referenced by ConioNextLine(), and TEXTMODE_BUFFER_Initialize().

◆ ConDrvChangeScreenBufferAttributes()

NTSTATUS NTAPI ConDrvChangeScreenBufferAttributes ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN USHORT  NewScreenAttrib,
IN USHORT  NewPopupAttrib 
)

Definition at line 383 of file text.c.

387 {
388  ULONG X, Y, Length;
389  PCHAR_INFO Ptr;
390 
391  COORD TopLeft = {0};
392  ULONG NumCodesToWrite;
393  USHORT OldScreenAttrib, OldPopupAttrib;
394 
395  if (Console == NULL || Buffer == NULL)
396  {
398  }
399 
400  /* Validity check */
401  ASSERT(Console == Buffer->Header.Console);
402 
403  NumCodesToWrite = Buffer->ScreenBufferSize.X * Buffer->ScreenBufferSize.Y;
404  OldScreenAttrib = Buffer->ScreenDefaultAttrib;
405  OldPopupAttrib = Buffer->PopupDefaultAttrib;
406 
407  X = TopLeft.X;
408  Y = (TopLeft.Y + Buffer->VirtualY) % Buffer->ScreenBufferSize.Y;
409  Length = NumCodesToWrite;
410 
411  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work
412  // Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X]; // May work
413 
414  while (Length--)
415  {
416  // Ptr = ConioCoordToPointer(Buffer, X, Y); // Doesn't work either
417  Ptr = &Buffer->Buffer[X + Y * Buffer->ScreenBufferSize.X];
418 
419  /*
420  * Change the current colors only if they are the old ones.
421  */
422 
423  /* Foreground color */
424  if ((Ptr->Attributes & 0x0F) == (OldScreenAttrib & 0x0F))
425  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewScreenAttrib & 0x0F);
426  if ((Ptr->Attributes & 0x0F) == (OldPopupAttrib & 0x0F))
427  Ptr->Attributes = (Ptr->Attributes & 0xFFF0) | (NewPopupAttrib & 0x0F);
428 
429  /* Background color */
430  if ((Ptr->Attributes & 0xF0) == (OldScreenAttrib & 0xF0))
431  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewScreenAttrib & 0xF0);
432  if ((Ptr->Attributes & 0xF0) == (OldPopupAttrib & 0xF0))
433  Ptr->Attributes = (Ptr->Attributes & 0xFF0F) | (NewPopupAttrib & 0xF0);
434 
435  // ++Ptr;
436 
437  if (++X == Buffer->ScreenBufferSize.X)
438  {
439  X = 0;
440 
441  if (++Y == Buffer->ScreenBufferSize.Y)
442  {
443  Y = 0;
444  }
445  }
446  }
447 
448  /* Save foreground and background colors for both screen and popup */
449  Buffer->ScreenDefaultAttrib = (NewScreenAttrib & 0x00FF);
450  Buffer->PopupDefaultAttrib = (NewPopupAttrib & 0x00FF);
451 
452  /* Refresh the display if needed */
453  if ((PCONSOLE_SCREEN_BUFFER)Buffer == Console->ActiveBuffer)
454  {
456  ConioComputeUpdateRect(Buffer, &UpdateRect, &TopLeft, NumCodesToWrite);
458  }
459 
460  return STATUS_SUCCESS;
461 }
#define Y(I)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define TermDrawRegion(Console, Region)
Definition: term.h:22
static VOID ConioComputeUpdateRect(IN PTEXTMODE_SCREEN_BUFFER Buff, IN OUT PSMALL_RECT UpdateRect, IN PCOORD Start, IN UINT Length)
Definition: text.c:160
while(1)
Definition: macro.lex.yy.c:740
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
ULONG X
Definition: bl.h:1340
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: bl.h:1338
unsigned short USHORT
Definition: pedump.c:61
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:2745
ULONG Y
Definition: bl.h:1341
#define X(b, s)

Referenced by ConSrvApplyUserSettings().

◆ ConDrvFillConsoleOutput()

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

Definition at line 978 of file text.c.

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

Referenced by CSR_API(), and DrawBox().

◆ ConDrvGetConsoleScreenBufferInfo()

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

Definition at line 1059 of file text.c.

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

Referenced by CSR_API().

◆ ConDrvReadConsoleOutput()

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

Definition at line 467 of file text.c.

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

Referenced by CreatePopupWindow(), and CSR_API().

◆ ConDrvReadConsoleOutputString()

NTSTATUS NTAPI ConDrvReadConsoleOutputString ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN CODE_TYPE  CodeType,
OUT PVOID  StringBuffer,
IN ULONG  NumCodesToRead,
IN PCOORD  ReadCoord,
OUT PULONG NumCodesRead  OPTIONAL 
)

Definition at line 727 of file text.c.

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

Referenced by CSR_API().

◆ ConDrvScrollConsoleScreenBuffer()

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

Definition at line 1133 of file text.c.

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

◆ ConDrvSetConsoleScreenBufferSize()

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

Definition at line 1114 of file text.c.

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

◆ ConDrvSetConsoleTextAttribute()

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

Definition at line 1099 of file text.c.

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

◆ ConDrvSetConsoleWindowInfo()

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

Definition at line 1221 of file text.c.

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

◆ ConDrvWriteConsole()

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

Definition at line 655 of file text.c.

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

◆ ConDrvWriteConsoleInput()

NTSTATUS NTAPI ConDrvWriteConsoleInput ( IN PCONSOLE  Console,
IN PCONSOLE_INPUT_BUFFER  InputBuffer,
IN BOOLEAN  AppendToEnd,
IN PINPUT_RECORD  InputRecord,
IN ULONG  NumEventsToWrite,
OUT PULONG NumEventsWritten  OPTIONAL 
)

Definition at line 325 of file coninput.c.

331 {
332  if (Console == NULL || InputBuffer == NULL /* || InputRecord == NULL */)
334 
335  /* Validity checks */
336  ASSERT(Console == InputBuffer->Header.Console);
337  ASSERT((InputRecord != NULL) || (InputRecord == NULL && NumEventsToWrite == 0));
338 
339  /* Now, add the events */
340  if (NumEventsWritten) *NumEventsWritten = 0;
341 
342  // FIXME: If we add back UNICODE support, it's here that we need to do the translation.
343 
344  return AddInputEvents(Console,
345  InputRecord,
346  NumEventsToWrite,
347  NumEventsWritten,
348  AppendToEnd);
349 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
CHAR InputBuffer[80]
Definition: conmgr.c:33
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static NTSTATUS AddInputEvents(PCONSOLE Console, PINPUT_RECORD InputRecords, ULONG NumEventsToWrite, PULONG NumEventsWritten, BOOLEAN AppendToEnd)
Definition: coninput.c:21
CConsole Console

Referenced by ConioResizeBuffer().

◆ ConDrvWriteConsoleOutput()

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

Definition at line 531 of file text.c.

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

Referenced by CSR_API(), and DestroyPopupWindow().

◆ ConDrvWriteConsoleOutputString()

NTSTATUS NTAPI ConDrvWriteConsoleOutputString ( IN PCONSOLE  Console,
IN PTEXTMODE_SCREEN_BUFFER  Buffer,
IN CODE_TYPE  CodeType,
IN PVOID  StringBuffer,
IN ULONG  NumCodesToWrite,
IN PCOORD  WriteCoord,
OUT PULONG NumCodesWritten  OPTIONAL 
)

Definition at line 840 of file text.c.

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

Referenced by CSR_API().

◆ ConDrvWriteConsoleOutputVDM()

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

Definition at line 600 of file text.c.

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

Referenced by CSR_API().

◆ ConioComputeUpdateRect()

static VOID ConioComputeUpdateRect ( IN PTEXTMODE_SCREEN_BUFFER  Buff,
IN OUT PSMALL_RECT  UpdateRect,
IN PCOORD  Start,
IN UINT  Length 
)
static

Definition at line 160 of file text.c.

164 {
165  if ((UINT)Buff->ScreenBufferSize.X <= Start->X + Length)
166  {
167  UpdateRect->Left = 0;
168  UpdateRect->Right = Buff->ScreenBufferSize.X - 1;
169  }
170  else
171  {
172  UpdateRect->Left = Start->X;
173  UpdateRect->Right = Start->X + Length - 1;
174  }
175  UpdateRect->Top = Start->Y;
176  UpdateRect->Bottom = Start->Y + (Start->X + Length - 1) / Buff->ScreenBufferSize.X;
177  if (Buff->ScreenBufferSize.Y <= UpdateRect->Bottom)
178  {
179  UpdateRect->Bottom = Buff->ScreenBufferSize.Y - 1;
180  }
181 }
if(!(yy_init))
Definition: macro.lex.yy.c:714
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
Definition: partlist.h:33
unsigned int UINT
Definition: ndis.h:50
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529

Referenced by ConDrvChangeScreenBufferAttributes(), ConDrvFillConsoleOutput(), and ConDrvWriteConsoleOutputString().

◆ ConioCoordToPointer()

PCHAR_INFO ConioCoordToPointer ( PTEXTMODE_SCREEN_BUFFER  Buff,
ULONG  X,
ULONG  Y 
)

Definition at line 140 of file text.c.

141 {
142  return &Buff->Buffer[((Y + Buff->VirtualY) % Buff->ScreenBufferSize.Y) * Buff->ScreenBufferSize.X + X];
143 }
#define Y(I)
PCHAR_INFO Buffer
Definition: conio.h:154
#define X(b, s)

Referenced by ClearLineBuffer(), ConDrvReadConsoleOutput(), ConDrvWriteConsoleOutput(), ConDrvWriteConsoleOutputVDM(), ConioMoveRegion(), ConioResizeBuffer(), ConioWriteConsole(), CopyBlock(), CopyLines(), GuiCopyFromTextModeBuffer(), GuiPaintTextModeBuffer(), and OnMouse().

◆ ConioMoveRegion()

static VOID ConioMoveRegion ( PTEXTMODE_SCREEN_BUFFER  ScreenBuffer,
PSMALL_RECT  SrcRegion,
PSMALL_RECT  DstRegion,
PSMALL_RECT  ClipRegion,
CHAR_INFO  FillChar 
)
static

Definition at line 188 of file text.c.

193 {
194  int Width = ConioRectWidth(SrcRegion);
195  int Height = ConioRectHeight(SrcRegion);
196  int SX, SY;
197  int DX, DY;
198  int XDelta, YDelta;
199  int i, j;
200 
201  SY = SrcRegion->Top;
202  DY = DstRegion->Top;
203  YDelta = 1;
204  if (SY < DY)
205  {
206  /* Moving down: work from bottom up */
207  SY = SrcRegion->Bottom;
208  DY = DstRegion->Bottom;
209  YDelta = -1;
210  }
211  for (i = 0; i < Height; i++)
212  {
215 
216  SX = SrcRegion->Left;
217  DX = DstRegion->Left;
218  XDelta = 1;
219  if (SX < DX)
220  {
221  /* Moving right: work from right to left */
222  SX = SrcRegion->Right;
223  DX = DstRegion->Right;
224  XDelta = -1;
225  }
226  for (j = 0; j < Width; j++)
227  {
228  CHAR_INFO Cell = SRow[SX];
229  if (SX >= ClipRegion->Left && SX <= ClipRegion->Right &&
230  SY >= ClipRegion->Top && SY <= ClipRegion->Bottom)
231  {
232  SRow[SX] = FillChar;
233  }
234  if (DX >= ClipRegion->Left && DX <= ClipRegion->Right &&
235  DY >= ClipRegion->Top && DY <= ClipRegion->Bottom)
236  {
237  DRow[DX] = Cell;
238  }
239  SX += XDelta;
240  DX += XDelta;
241  }
242  SY += YDelta;
243  DY += YDelta;
244  }
245 }
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
SHORT Right
Definition: wincon.h:178
SHORT Left
Definition: wincon.h:176
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DX
Definition: i386-dis.c:416
#define ConioRectWidth(Rect)
Definition: readwrite.c:24
#define ConioRectHeight(Rect)
Definition: readwrite.c:22
struct zzzz Cell
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
Definition: bzip2.c:1694
SHORT Bottom
Definition: wincon.h:179
SHORT Top
Definition: wincon.h:177
static LPHIST_ENTRY Bottom
Definition: history.c:54
HANDLE ScreenBuffer
Definition: notevil.c:37

Referenced by ConDrvScrollConsoleScreenBuffer().

◆ ConioResizeBuffer()

NTSTATUS ConioResizeBuffer ( PCONSOLE  Console,
PTEXTMODE_SCREEN_BUFFER  ScreenBuffer,
COORD  Size 
)

Definition at line 257 of file text.c.

260 {
262  DWORD Offset = 0;
263  PCHAR_INFO ptr;
264  WORD CurrentAttribute;
265  USHORT CurrentY;
266  PCHAR_INFO OldBuffer;
267  DWORD i;
268  DWORD diff;
269 
270  /* Buffer size is not allowed to be smaller than the view size */
271  if (Size.X < ScreenBuffer->ViewSize.X || Size.Y < ScreenBuffer->ViewSize.Y)
273 
274  if (Size.X == ScreenBuffer->ScreenBufferSize.X && Size.Y == ScreenBuffer->ScreenBufferSize.Y)
275  {
276  // FIXME: Trigger a buffer resize event ??
277  return STATUS_SUCCESS;
278  }
279 
280  if (Console->FixedSize)
281  {
282  /*
283  * The console is in fixed-size mode, so we cannot resize anything
284  * at the moment. However, keep those settings somewhere so that
285  * we can try to set them up when we will be allowed to do so.
286  */
287  ScreenBuffer->OldScreenBufferSize = Size;
288  return STATUS_NOT_SUPPORTED; // STATUS_SUCCESS
289  }
290 
292  if (!Buffer) return STATUS_NO_MEMORY;
293 
294  DPRINT("Resizing (%d,%d) to (%d,%d)\n", ScreenBuffer->ScreenBufferSize.X, ScreenBuffer->ScreenBufferSize.Y, Size.X, Size.Y);
295  OldBuffer = ScreenBuffer->Buffer;
296 
297  for (CurrentY = 0; CurrentY < ScreenBuffer->ScreenBufferSize.Y && CurrentY < Size.Y; CurrentY++)
298  {
299  ptr = ConioCoordToPointer(ScreenBuffer, 0, CurrentY);
300  if (Size.X <= ScreenBuffer->ScreenBufferSize.X)
301  {
302  /* Reduce size */
303  RtlCopyMemory(Buffer + Offset, ptr, Size.X * sizeof(CHAR_INFO));
304  Offset += Size.X;
305  }
306  else
307  {
308  /* Enlarge size */
309  RtlCopyMemory(Buffer + Offset, ptr, ScreenBuffer->ScreenBufferSize.X * sizeof(CHAR_INFO));
310  Offset += ScreenBuffer->ScreenBufferSize.X;
311 
312  /* The attribute to be used is the one of the last cell of the current line */
313  CurrentAttribute = ConioCoordToPointer(ScreenBuffer,
314  ScreenBuffer->ScreenBufferSize.X - 1,
315  CurrentY)->Attributes;
316 
317  diff = Size.X - ScreenBuffer->ScreenBufferSize.X;
318 
319  /* Zero-out the new part of the buffer */
320  for (i = 0; i < diff; i++)
321  {
322  ptr = Buffer + Offset;
323  ptr->Char.UnicodeChar = L' ';
324  ptr->Attributes = CurrentAttribute;
325  ++Offset;
326  }
327  }
328  }
329 
330  if (Size.Y > ScreenBuffer->ScreenBufferSize.Y)
331  {
332  diff = Size.X * (Size.Y - ScreenBuffer->ScreenBufferSize.Y);
333 
334  /* Zero-out the new part of the buffer */
335  for (i = 0; i < diff; i++)
336  {
337  ptr = Buffer + Offset;
338  ptr->Char.UnicodeChar = L' ';
339  ptr->Attributes = ScreenBuffer->ScreenDefaultAttrib;
340  ++Offset;
341  }
342  }
343 
345  ConsoleFreeHeap(OldBuffer);
346  ScreenBuffer->ScreenBufferSize = ScreenBuffer->OldScreenBufferSize = Size;
347  ScreenBuffer->VirtualY = 0;
348 
349  /* Ensure cursor and window are within buffer */
350  if (ScreenBuffer->CursorPosition.X >= Size.X)
351  ScreenBuffer->CursorPosition.X = Size.X - 1;
352  if (ScreenBuffer->CursorPosition.Y >= Size.Y)
353  ScreenBuffer->CursorPosition.Y = Size.Y - 1;
354  if (ScreenBuffer->ViewOrigin.X > Size.X - ScreenBuffer->ViewSize.X)
355  ScreenBuffer->ViewOrigin.X = Size.X - ScreenBuffer->ViewSize.X;
356  if (ScreenBuffer->ViewOrigin.Y > Size.Y - ScreenBuffer->ViewSize.Y)
357  ScreenBuffer->ViewOrigin.Y = Size.Y - ScreenBuffer->ViewSize.Y;
358 
359  /*
360  * Trigger a buffer resize event
361  */
362  if (Console->InputBuffer.Mode & ENABLE_WINDOW_INPUT)
363  {
364  ULONG NumEventsWritten;
365  INPUT_RECORD er;
366 
368  er.Event.WindowBufferSizeEvent.dwSize = ScreenBuffer->ScreenBufferSize;
369 
370  // ConioProcessInputEvent(Console, &er);
372  &Console->InputBuffer,
373  TRUE,
374  &er,
375  1,
376  &NumEventsWritten);
377  }
378 
379  return STATUS_SUCCESS;
380 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
#define WINDOW_BUFFER_SIZE_EVENT
Definition: wincon.h:124
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent
Definition: wincon.h:265
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
static PVOID ptr
Definition: dispmode.c:27
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
union _INPUT_RECORD::@3145 Event
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
WORD Attributes
Definition: wincon.h:172
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
#define ENABLE_WINDOW_INPUT
Definition: wincon.h:78
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
unsigned short USHORT
Definition: pedump.c:61
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
NTSTATUS NTAPI ConDrvWriteConsoleInput(IN PCONSOLE Console, IN PCONSOLE_INPUT_BUFFER InputBuffer, IN BOOLEAN AppendToEnd, IN PINPUT_RECORD InputRecord, IN ULONG NumEventsToWrite, OUT PULONG NumEventsWritten OPTIONAL)
Definition: coninput.c:325
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
CConsole Console
WORD EventType
Definition: wincon.h:261
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
HANDLE ScreenBuffer
Definition: notevil.c:37
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by ConDrvSetConsoleScreenBufferSize(), and ConSrvApplyUserSettings().

◆ CONSOLE_SCREEN_BUFFER_Destroy()

VOID CONSOLE_SCREEN_BUFFER_Destroy ( IN OUT PCONSOLE_SCREEN_BUFFER  Buffer)

Definition at line 55 of file conoutput.c.

56 {
57  if (Buffer->Header.Type == TEXTMODE_BUFFER)
58  {
60  }
61  else if (Buffer->Header.Type == GRAPHICS_BUFFER)
62  {
64  }
65  else if (Buffer->Header.Type == SCREEN_BUFFER)
66  {
67  /* Free the palette handle */
68  if (Buffer->PaletteHandle != NULL) DeleteObject(Buffer->PaletteHandle);
69 
70  /* Free the screen buffer memory */
72  }
73  // else
74  // do_nothing;
75 }
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define TEXTMODE_BUFFER
Definition: pccons.c:21
VOID TEXTMODE_BUFFER_Destroy(IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
Definition: text.c:123
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
VOID GRAPHICS_BUFFER_Destroy(IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
Definition: graphics.c:249

Referenced by TEXTMODE_BUFFER_Destroy(), and TEXTMODE_BUFFER_Initialize().

◆ CONSOLE_SCREEN_BUFFER_Initialize()

NTSTATUS CONSOLE_SCREEN_BUFFER_Initialize ( OUT PCONSOLE_SCREEN_BUFFER Buffer,
IN PCONSOLE  Console,
IN PCONSOLE_SCREEN_BUFFER_VTBL  Vtbl,
IN SIZE_T  Size 
)

Definition at line 37 of file conoutput.c.

41 {
42  if (Buffer == NULL || Console == NULL)
44 
47 
48  /* Initialize the header with the default type */
49  ConSrvInitObject(&(*Buffer)->Header, SCREEN_BUFFER, Console);
50  (*Buffer)->Vtbl = Vtbl;
51  return STATUS_SUCCESS;
52 }
#define max(a, b)
Definition: svc.c:63
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
VOID ConSrvInitObject(IN OUT PCONSOLE_IO_OBJECT Object, IN CONSOLE_IO_OBJECT_TYPE Type, IN PCONSOLE Console)
Definition: handle.c:294
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by TEXTMODE_BUFFER_Initialize().

◆ TEXTMODE_BUFFER_Destroy()

VOID TEXTMODE_BUFFER_Destroy ( IN OUT PCONSOLE_SCREEN_BUFFER  Buffer)

Definition at line 123 of file text.c.

124 {
126 
127  /*
128  * IMPORTANT !! Reinitialize the type so that we don't enter a recursive
129  * infinite loop when calling CONSOLE_SCREEN_BUFFER_Destroy.
130  */
131  Buffer->Header.Type = SCREEN_BUFFER;
132 
133  ConsoleFreeHeap(Buff->Buffer);
134 
136 }
Definition: bufpool.h:45
VOID CONSOLE_SCREEN_BUFFER_Destroy(IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:55
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
PCHAR_INFO Buffer
Definition: conio.h:154
struct _TEXTMODE_SCREEN_BUFFER * PTEXTMODE_SCREEN_BUFFER

◆ TEXTMODE_BUFFER_GetType()

CONSOLE_IO_OBJECT_TYPE TEXTMODE_BUFFER_GetType ( PCONSOLE_SCREEN_BUFFER  This)

Definition at line 36 of file text.c.

37 {
38  // return This->Header.Type;
39  return TEXTMODE_BUFFER;
40 }
#define TEXTMODE_BUFFER
Definition: pccons.c:21

◆ TEXTMODE_BUFFER_Initialize()

NTSTATUS TEXTMODE_BUFFER_Initialize ( OUT PCONSOLE_SCREEN_BUFFER Buffer,
IN PCONSOLE  Console,
IN HANDLE  ProcessHandle,
IN PTEXTMODE_BUFFER_INFO  TextModeInfo 
)

Definition at line 62 of file text.c.

66 {
68  PTEXTMODE_SCREEN_BUFFER NewBuffer = NULL;
69 
71 
72  if (Console == NULL || Buffer == NULL || TextModeInfo == NULL)
74 
75  *Buffer = NULL;
76 
78  Console,
79  &TextVtbl,
80  sizeof(TEXTMODE_SCREEN_BUFFER));
81  if (!NT_SUCCESS(Status)) return Status;
82  NewBuffer->Header.Type = TEXTMODE_BUFFER;
83 
84  NewBuffer->Buffer = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
85  TextModeInfo->ScreenBufferSize.X *
86  TextModeInfo->ScreenBufferSize.Y *
87  sizeof(CHAR_INFO));
88  if (NewBuffer->Buffer == NULL)
89  {
92  }
93 
94  NewBuffer->ScreenBufferSize = NewBuffer->OldScreenBufferSize
95  = TextModeInfo->ScreenBufferSize;
96  NewBuffer->ViewSize = NewBuffer->OldViewSize
97  = Console->ConsoleSize;
98 
99  NewBuffer->ViewOrigin.X = NewBuffer->ViewOrigin.Y = 0;
100  NewBuffer->VirtualY = 0;
101 
102  NewBuffer->CursorBlinkOn = NewBuffer->ForceCursorOff = FALSE;
103  NewBuffer->CursorInfo.bVisible = (TextModeInfo->IsCursorVisible && (TextModeInfo->CursorSize != 0));
104  NewBuffer->CursorInfo.dwSize = min(max(TextModeInfo->CursorSize, 0), 100);
105 
106  NewBuffer->ScreenDefaultAttrib = TextModeInfo->ScreenAttrib;
107  NewBuffer->PopupDefaultAttrib = TextModeInfo->PopupAttrib;
108 
109  /* Initialize buffer to be empty with default attributes */
110  for (NewBuffer->CursorPosition.Y = 0 ; NewBuffer->CursorPosition.Y < NewBuffer->ScreenBufferSize.Y; NewBuffer->CursorPosition.Y++)
111  {
112  ClearLineBuffer(NewBuffer);
113  }
114  NewBuffer->CursorPosition.X = NewBuffer->CursorPosition.Y = 0;
115 
117 
118  *Buffer = (PCONSOLE_SCREEN_BUFFER)NewBuffer;
119  return STATUS_SUCCESS;
120 }
#define max(a, b)
Definition: svc.c:63
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
BOOLEAN CursorBlinkOn
Definition: conio.h:99
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
COORD CursorPosition
Definition: conio.h:98
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
#define TEXTMODE_BUFFER
Definition: pccons.c:21
COORD OldScreenBufferSize
Definition: conio.h:90
CONSOLE_IO_OBJECT Header
Definition: conio.h:82
#define ENABLE_WRAP_AT_EOL_OUTPUT
Definition: blue.h:45
COORD ScreenBufferSize
Definition: conio.h:87
struct _CONSOLE_SCREEN_BUFFER * PCONSOLE_SCREEN_BUFFER
Definition: conio.h:70
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
VOID CONSOLE_SCREEN_BUFFER_Destroy(IN OUT PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:55
ULONG X
Definition: bl.h:1340
NTSTATUS CONSOLE_SCREEN_BUFFER_Initialize(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN PCONSOLE_SCREEN_BUFFER_VTBL Vtbl, IN SIZE_T Size)
Definition: conoutput.c:37
BOOLEAN bVisible
Definition: blue.h:41
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
BOOLEAN ForceCursorOff
Definition: conio.h:100
Status
Definition: gdiplustypes.h:24
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:44
static CONSOLE_SCREEN_BUFFER_VTBL TextVtbl
Definition: text.c:42
#define min(a, b)
Definition: monoChain.cc:55
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
CConsole Console
CONSOLE_IO_OBJECT_TYPE Type
Definition: conio.h:50
VOID ClearLineBuffer(PTEXTMODE_SCREEN_BUFFER Buff)
Definition: text.c:146
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
return STATUS_SUCCESS
Definition: btrfs.c:2745
CONSOLE_CURSOR_INFO CursorInfo
Definition: conio.h:102
ULONG Y
Definition: bl.h:1341

Referenced by ConDrvCreateScreenBuffer().

Variable Documentation

◆ TextVtbl

CONSOLE_SCREEN_BUFFER_VTBL TextVtbl
static
Initial value:
=
{
}
CONSOLE_IO_OBJECT_TYPE TEXTMODE_BUFFER_GetType(PCONSOLE_SCREEN_BUFFER This)
Definition: text.c:36

Definition at line 42 of file text.c.

Referenced by TEXTMODE_BUFFER_Initialize().