ReactOS  0.4.15-dev-1207-g698a8e6
terminal.c File Reference
#include <consrv.h>
#include "concfg/font.h"
#include <debug.h>
Include dependency graph for terminal.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar)
 
#define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar)
 
#define TAB_WIDTH   8
 

Typedefs

typedef NTSTATUS(NTAPIFRONTEND_LOAD) (IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
 
typedef NTSTATUS(NTAPIFRONTEND_UNLOAD) (IN OUT PFRONTEND FrontEnd)
 

Functions

NTSTATUS NTAPI GuiLoadFrontEnd (IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
 
NTSTATUS NTAPI GuiUnloadFrontEnd (IN OUT PFRONTEND FrontEnd)
 
static NTSTATUS ConSrvLoadFrontEnd (IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
 
static NTSTATUS ConSrvUnloadFrontEnd (IN PFRONTEND FrontEnd)
 
NTSTATUS NTAPI ConSrvInitTerminal (IN OUT PTERMINAL Terminal, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
 
NTSTATUS NTAPI ConSrvDeinitTerminal (IN OUT PTERMINAL Terminal)
 
static NTSTATUS NTAPI ConSrvTermInitTerminal (IN OUT PTERMINAL This, IN PCONSOLE Console)
 
static VOID NTAPI ConSrvTermDeinitTerminal (IN OUT PTERMINAL This)
 
static NTSTATUS NTAPI ConSrvTermReadStream (IN OUT PTERMINAL This, IN BOOLEAN Unicode, OUT PVOID Buffer, IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl, IN PVOID Parameter OPTIONAL, IN ULONG NumCharsToRead, OUT PULONG NumCharsRead OPTIONAL)
 
VOID ClearLineBuffer (PTEXTMODE_SCREEN_BUFFER Buff)
 
static VOID ConioNextLine (PTEXTMODE_SCREEN_BUFFER Buff, PSMALL_RECT UpdateRect, PUINT ScrolledLines)
 
static NTSTATUS ConioWriteConsole (PFRONTEND FrontEnd, PTEXTMODE_SCREEN_BUFFER Buff, PWCHAR Buffer, DWORD Length, BOOL Attrib)
 
static NTSTATUS NTAPI ConSrvTermWriteStream (IN OUT PTERMINAL This, PTEXTMODE_SCREEN_BUFFER Buff, PWCHAR Buffer, DWORD Length, BOOL Attrib)
 
VOID ConioDrawConsole (PCONSRV_CONSOLE Console)
 
static VOID NTAPI ConSrvTermDrawRegion (IN OUT PTERMINAL This, SMALL_RECT *Region)
 
static BOOL NTAPI ConSrvTermSetCursorInfo (IN OUT PTERMINAL This, PCONSOLE_SCREEN_BUFFER ScreenBuffer)
 
static BOOL NTAPI ConSrvTermSetScreenInfo (IN OUT PTERMINAL This, PCONSOLE_SCREEN_BUFFER ScreenBuffer, SHORT OldCursorX, SHORT OldCursorY)
 
static VOID NTAPI ConSrvTermResizeTerminal (IN OUT PTERMINAL This)
 
static VOID NTAPI ConSrvTermSetActiveScreenBuffer (IN OUT PTERMINAL This)
 
static VOID NTAPI ConSrvTermReleaseScreenBuffer (IN OUT PTERMINAL This, IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
 
static VOID NTAPI ConSrvTermGetLargestConsoleWindowSize (IN OUT PTERMINAL This, PCOORD pSize)
 
static BOOL NTAPI ConSrvTermSetPalette (IN OUT PTERMINAL This, HPALETTE PaletteHandle, UINT PaletteUsage)
 
static INT NTAPI ConSrvTermShowMouseCursor (IN OUT PTERMINAL This, BOOL Show)
 

Variables

struct {
   CHAR   FrontEndName [80]
 
   FRONTEND_LOAD   FrontEndLoad
 
   FRONTEND_UNLOAD   FrontEndUnload
 
FrontEndLoadingMethods []
 
static TERMINAL_VTBL ConSrvTermVtbl
 

Macro Definition Documentation

◆ ConsoleInputAnsiCharToUnicodeChar

#define ConsoleInputAnsiCharToUnicodeChar (   Console,
  dWChar,
  sChar 
)
Value:
do { \
ASSERT((ULONG_PTR)(dWChar) != (ULONG_PTR)(sChar)); \
MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1); \
} while (0)
uint32_t ULONG_PTR
Definition: typedefs.h:65
UINT InputCodePage
Definition: console.c:25
CConsole Console

Definition at line 42 of file terminal.c.

◆ ConsoleInputUnicodeCharToAnsiChar

#define ConsoleInputUnicodeCharToAnsiChar (   Console,
  dChar,
  sWChar 
)
Value:
do { \
ASSERT((ULONG_PTR)(dChar) != (ULONG_PTR)(sWChar)); \
WideCharToMultiByte((Console)->InputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL); \
} while (0)
uint32_t ULONG_PTR
Definition: typedefs.h:65
smooth NULL
Definition: ftsmooth.c:416
UINT InputCodePage
Definition: console.c:25
CConsole Console

Definition at line 36 of file terminal.c.

◆ NDEBUG

#define NDEBUG

Definition at line 19 of file terminal.c.

◆ TAB_WIDTH

#define TAB_WIDTH   8

Definition at line 473 of file terminal.c.

Typedef Documentation

◆ FRONTEND_LOAD

typedef NTSTATUS(NTAPI * FRONTEND_LOAD) (IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)

Definition at line 112 of file terminal.c.

◆ FRONTEND_UNLOAD

typedef NTSTATUS(NTAPI * FRONTEND_UNLOAD) (IN OUT PFRONTEND FrontEnd)

Definition at line 118 of file terminal.c.

Function Documentation

◆ ClearLineBuffer()

VOID ClearLineBuffer ( PTEXTMODE_SCREEN_BUFFER  Buff)

Definition at line 151 of file text.c.

152 {
153  PCHAR_INFO Ptr = ConioCoordToPointer(Buff, 0, Buff->CursorPosition.Y);
154  SHORT Pos;
155 
156  for (Pos = 0; Pos < Buff->ScreenBufferSize.X; Pos++, Ptr++)
157  {
158  /* Fill the cell */
159  Ptr->Char.UnicodeChar = L' ';
160  Ptr->Attributes = Buff->ScreenDefaultAttrib;
161  }
162 }
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
_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
USHORT ScreenDefaultAttrib
Definition: conio.h:131

Referenced by ConioNextLine(), and TEXTMODE_BUFFER_Initialize().

◆ ConioDrawConsole()

VOID ConioDrawConsole ( PCONSRV_CONSOLE  Console)

Definition at line 860 of file terminal.c.

861 {
863  PCONSOLE_SCREEN_BUFFER ActiveBuffer = Console->ActiveBuffer;
864 
865  if (!ActiveBuffer) return;
866 
867  ConioInitRect(&Region, 0, 0,
868  ActiveBuffer->ViewSize.Y - 1,
869  ActiveBuffer->ViewSize.X - 1);
871  // Console->FrontEndIFace.Vtbl->DrawRegion(&Console->FrontEndIFace, &Region);
872 }
#define TermDrawRegion(Console, Region)
Definition: term.h:22
ULONG X
Definition: bl.h:1340
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
CConsole Console
ULONG Y
Definition: bl.h:1341

Referenced by ConioProcessKey().

◆ ConioNextLine()

static VOID ConioNextLine ( PTEXTMODE_SCREEN_BUFFER  Buff,
PSMALL_RECT  UpdateRect,
PUINT  ScrolledLines 
)
static

Definition at line 480 of file terminal.c.

481 {
482  /* If we hit bottom, slide the viewable screen */
483  if (++Buff->CursorPosition.Y == Buff->ScreenBufferSize.Y)
484  {
485  Buff->CursorPosition.Y--;
486  if (++Buff->VirtualY == Buff->ScreenBufferSize.Y)
487  {
488  Buff->VirtualY = 0;
489  }
490  (*ScrolledLines)++;
491  ClearLineBuffer(Buff);
492  if (UpdateRect->Top != 0)
493  {
494  UpdateRect->Top--;
495  }
496  }
497  UpdateRect->Left = 0;
498  UpdateRect->Right = Buff->ScreenBufferSize.X - 1;
499  UpdateRect->Bottom = Buff->CursorPosition.Y;
500 }
VOID ClearLineBuffer(PTEXTMODE_SCREEN_BUFFER Buff)
Definition: text.c:151
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529

Referenced by ConioWriteConsole().

◆ ConioWriteConsole()

static NTSTATUS ConioWriteConsole ( PFRONTEND  FrontEnd,
PTEXTMODE_SCREEN_BUFFER  Buff,
PWCHAR  Buffer,
DWORD  Length,
BOOL  Attrib 
)
static

Definition at line 503 of file terminal.c.

508 {
509  PCONSRV_CONSOLE Console = FrontEnd->Console;
510 
511  UINT i;
512  PCHAR_INFO Ptr;
514  SHORT CursorStartX, CursorStartY;
515  UINT ScrolledLines;
516  BOOLEAN bFullwidth;
517  BOOLEAN bCJK = Console->IsCJK;
518 
519  /* If nothing to write, bail out now */
520  if (Length == 0)
521  return STATUS_SUCCESS;
522 
523  CursorStartX = Buff->CursorPosition.X;
524  CursorStartY = Buff->CursorPosition.Y;
525  UpdateRect.Left = Buff->ScreenBufferSize.X;
526  UpdateRect.Top = Buff->CursorPosition.Y;
527  UpdateRect.Right = -1;
528  UpdateRect.Bottom = Buff->CursorPosition.Y;
529  ScrolledLines = 0;
530 
531  for (i = 0; i < Length; i++)
532  {
533  /*
534  * If we are in processed mode, interpret special characters and
535  * display them correctly. Otherwise, just put them into the buffer.
536  */
537  if (Buff->Mode & ENABLE_PROCESSED_OUTPUT)
538  {
539  /* --- CR --- */
540  if (Buffer[i] == L'\r')
541  {
542  Buff->CursorPosition.X = 0;
543  CursorStartX = Buff->CursorPosition.X;
544  UpdateRect.Left = min(UpdateRect.Left , Buff->CursorPosition.X);
545  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
546  continue;
547  }
548  /* --- LF --- */
549  else if (Buffer[i] == L'\n')
550  {
551  Buff->CursorPosition.X = 0; // TODO: Make this behaviour optional!
552  CursorStartX = Buff->CursorPosition.X;
553  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
554  continue;
555  }
556  /* --- BS --- */
557  else if (Buffer[i] == L'\b')
558  {
559  /* Only handle BS if we are not on the first position of the first line */
560  if (Buff->CursorPosition.X == 0 && Buff->CursorPosition.Y == 0)
561  continue;
562 
563  if (Buff->CursorPosition.X == 0)
564  {
565  /* Slide virtual position up */
566  Buff->CursorPosition.X = Buff->ScreenBufferSize.X - 1;
567  Buff->CursorPosition.Y--;
568  // TODO? : Update CursorStartY = Buff->CursorPosition.Y;
569  UpdateRect.Top = min(UpdateRect.Top, Buff->CursorPosition.Y);
570  }
571  else
572  {
573  Buff->CursorPosition.X--;
574  }
575  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
576 
577  if (Ptr->Attributes & COMMON_LVB_LEADING_BYTE)
578  {
579  /*
580  * The cursor just moved on the leading byte of the same
581  * current character. We should go one position before to
582  * go to the actual previous character to erase.
583  */
584 
585  /* Only handle BS if we are not on the first position of the first line */
586  if (Buff->CursorPosition.X == 0 && Buff->CursorPosition.Y == 0)
587  continue;
588 
589  if (Buff->CursorPosition.X == 0)
590  {
591  /* Slide virtual position up */
592  Buff->CursorPosition.X = Buff->ScreenBufferSize.X - 1;
593  Buff->CursorPosition.Y--;
594  // TODO? : Update CursorStartY = Buff->CursorPosition.Y;
595  UpdateRect.Top = min(UpdateRect.Top, Buff->CursorPosition.Y);
596  }
597  else
598  {
599  Buff->CursorPosition.X--;
600  }
601  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
602  }
603 
604  if (Ptr->Attributes & COMMON_LVB_TRAILING_BYTE)
605  {
606  /* The cursor is on the trailing byte of a full-width character */
607 
608  /* Delete its trailing byte... */
609  Ptr->Char.UnicodeChar = L' ';
610  if (Attrib)
611  Ptr->Attributes = Buff->ScreenDefaultAttrib;
612  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
613 
614  if (Buff->CursorPosition.X > 0)
615  Buff->CursorPosition.X--;
616  /* ... and now its leading byte */
617  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
618  }
619 
620  Ptr->Char.UnicodeChar = L' ';
621  if (Attrib)
622  Ptr->Attributes = Buff->ScreenDefaultAttrib;
623  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
624 
625  UpdateRect.Left = min(UpdateRect.Left , Buff->CursorPosition.X);
626  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
627  continue;
628  }
629  /* --- TAB --- */
630  else if (Buffer[i] == L'\t')
631  {
632  UINT EndX;
633 
634  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
635 
636  if (Ptr->Attributes & COMMON_LVB_TRAILING_BYTE)
637  {
638  /*
639  * The cursor is on the trailing byte of a full-width character.
640  * Go back one position to be on its leading byte.
641  */
642  if (Buff->CursorPosition.X > 0)
643  Buff->CursorPosition.X--;
644  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
645  }
646 
647  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
648 
649  EndX = (Buff->CursorPosition.X + TAB_WIDTH) & ~(TAB_WIDTH - 1);
650  EndX = min(EndX, (UINT)Buff->ScreenBufferSize.X);
651 
652  while ((UINT)Buff->CursorPosition.X < EndX)
653  {
654  Ptr->Char.UnicodeChar = L' ';
655  if (Attrib)
656  Ptr->Attributes = Buff->ScreenDefaultAttrib;
657  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
658 
659  ++Ptr;
660  Buff->CursorPosition.X++;
661  }
662  if (Buff->CursorPosition.X < Buff->ScreenBufferSize.X)
663  {
664  /* If the following cell is the trailing byte of a full-width character, reset it */
665  if (Ptr->Attributes & COMMON_LVB_TRAILING_BYTE)
666  {
667  Ptr->Char.UnicodeChar = L' ';
668  if (Attrib)
669  Ptr->Attributes = Buff->ScreenDefaultAttrib;
670  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
671  }
672  }
673  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
674 
675  if (Buff->CursorPosition.X >= Buff->ScreenBufferSize.X)
676  {
677  if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT)
678  {
679  /* Wrapping mode: Go to next line */
680  Buff->CursorPosition.X = 0;
681  CursorStartX = Buff->CursorPosition.X;
682  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
683  }
684  else
685  {
686  /* The cursor wraps back to its starting position on the same line */
687  Buff->CursorPosition.X = CursorStartX;
688  }
689  }
690  continue;
691  }
692  /* --- BEL ---*/
693  else if (Buffer[i] == L'\a')
694  {
695  FrontEnd->Vtbl->RingBell(FrontEnd);
696  continue;
697  }
698  }
699  UpdateRect.Left = min(UpdateRect.Left , Buff->CursorPosition.X);
700  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
701 
702  /* For Chinese, Japanese and Korean */
703  bFullwidth = (bCJK && IS_FULL_WIDTH(Buffer[i]));
704 
705  /* Check whether we can insert the full-width character */
706  if (bFullwidth)
707  {
708  /* It spans two cells and should all fit on the current line */
709  if (Buff->CursorPosition.X >= Buff->ScreenBufferSize.X - 1)
710  {
711  if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT)
712  {
713  /* Wrapping mode: Go to next line */
714  Buff->CursorPosition.X = 0;
715  CursorStartX = Buff->CursorPosition.X;
716  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
717  }
718  else
719  {
720  /* The cursor wraps back to its starting position on the same line */
721  Buff->CursorPosition.X = CursorStartX;
722  }
723  }
724 
725  /*
726  * Now be sure we can fit the full-width character.
727  * If the screenbuffer is one cell wide we cannot display
728  * the full-width character, so just skip it.
729  */
730  if (Buff->CursorPosition.X >= Buff->ScreenBufferSize.X - 1)
731  {
732  DPRINT1("Cannot display full-width character! CursorPosition.X = %d, ScreenBufferSize.X = %d\n",
733  Buff->CursorPosition.X, Buff->ScreenBufferSize.X);
734  continue;
735  }
736  }
737 
738  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
739 
740  /*
741  * Check whether we are overwriting part of a full-width character,
742  * in which case we need to invalidate it.
743  */
744  if (Ptr->Attributes & COMMON_LVB_TRAILING_BYTE)
745  {
746  /*
747  * The cursor is on the trailing byte of a full-width character.
748  * Go back one position to kill the previous leading byte.
749  */
750  if (Buff->CursorPosition.X > 0)
751  {
752  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X - 1, Buff->CursorPosition.Y);
753  Ptr->Char.UnicodeChar = L' ';
754  if (Attrib)
755  Ptr->Attributes = Buff->ScreenDefaultAttrib;
756  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
757  }
758  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
759  }
760 
761  /* Insert the character */
762  if (bFullwidth)
763  {
764  ASSERT(Buff->CursorPosition.X < Buff->ScreenBufferSize.X - 1);
765 
766  /* Set the leading byte */
767  Ptr->Char.UnicodeChar = Buffer[i];
768  if (Attrib)
769  Ptr->Attributes = Buff->ScreenDefaultAttrib;
770  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
771  Ptr->Attributes |= COMMON_LVB_LEADING_BYTE;
772 
773  /* Set the trailing byte */
774  Buff->CursorPosition.X++;
775  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
776  // Ptr->Char.UnicodeChar = Buffer[i]; // L' ';
777  if (Attrib)
778  Ptr->Attributes = Buff->ScreenDefaultAttrib;
779  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
780  Ptr->Attributes |= COMMON_LVB_TRAILING_BYTE;
781  }
782  else
783  {
784  Ptr->Char.UnicodeChar = Buffer[i];
785  if (Attrib)
786  Ptr->Attributes = Buff->ScreenDefaultAttrib;
787  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
788  }
789 
790  ++Ptr;
791  Buff->CursorPosition.X++;
792 
793  if (Buff->CursorPosition.X < Buff->ScreenBufferSize.X)
794  {
795  /* If the following cell is the trailing byte of a full-width character, reset it */
796  if (Ptr->Attributes & COMMON_LVB_TRAILING_BYTE)
797  {
798  Ptr->Char.UnicodeChar = L' ';
799  if (Attrib)
800  Ptr->Attributes = Buff->ScreenDefaultAttrib;
801  Ptr->Attributes &= ~COMMON_LVB_SBCSDBCS;
802  }
803  }
804 
805  if (Buff->CursorPosition.X >= Buff->ScreenBufferSize.X)
806  {
807  if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT)
808  {
809  /* Wrapping mode: Go to next line */
810  Buff->CursorPosition.X = 0;
811  CursorStartX = Buff->CursorPosition.X;
812  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
813  }
814  else
815  {
816  /* The cursor wraps back to its starting position on the same line */
817  Buff->CursorPosition.X = CursorStartX;
818  }
819  }
820  }
821 
822  if (!ConioIsRectEmpty(&UpdateRect) && (PCONSOLE_SCREEN_BUFFER)Buff == Console->ActiveBuffer)
823  {
824  // TermWriteStream(Console, &UpdateRect, CursorStartX, CursorStartY,
825  // ScrolledLines, Buffer, Length);
826  FrontEnd->Vtbl->WriteStream(FrontEnd,
827  &UpdateRect,
828  CursorStartX,
829  CursorStartY,
830  ScrolledLines,
831  Buffer,
832  Length);
833  }
834 
835  return STATUS_SUCCESS;
836 }
#define max(a, b)
Definition: svc.c:63
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:143
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define COMMON_LVB_SBCSDBCS
Definition: wincon.h:56
struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:101
#define ENABLE_WRAP_AT_EOL_OUTPUT
Definition: blue.h:54
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
unsigned char BOOLEAN
Definition: bufpool.h:45
#define TAB_WIDTH
Definition: terminal.c:473
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
USHORT ScreenDefaultAttrib
Definition: conio.h:131
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:53
static VOID ConioNextLine(PTEXTMODE_SCREEN_BUFFER Buff, PSMALL_RECT UpdateRect, PUINT ScrolledLines)
Definition: terminal.c:480
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
CConsole Console
#define DPRINT1
Definition: precomp.h:8
#define COMMON_LVB_LEADING_BYTE
Definition: wincon.h:48
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
#define COMMON_LVB_TRAILING_BYTE
Definition: wincon.h:49
#define ConioIsRectEmpty(Rect)
Definition: rect.h:28
return STATUS_SUCCESS
Definition: btrfs.c:3014
#define IS_FULL_WIDTH(wch)
Definition: conio.h:333

Referenced by ConSrvTermWriteStream().

◆ ConSrvDeinitTerminal()

NTSTATUS NTAPI ConSrvDeinitTerminal ( IN OUT PTERMINAL  Terminal)

Definition at line 237 of file terminal.c.

238 {
240  PFRONTEND FrontEnd = Terminal->Context;
241 
242  /* Reset the ConSrv terminal */
243  Terminal->Context = NULL;
244  Terminal->Vtbl = NULL;
245 
246  /* Unload the frontend */
247  if (FrontEnd != NULL)
248  {
249  Status = ConSrvUnloadFrontEnd(FrontEnd);
250  ConsoleFreeHeap(FrontEnd);
251  }
252 
253  return Status;
254 }
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS ConSrvUnloadFrontEnd(IN PFRONTEND FrontEnd)
Definition: terminal.c:193
smooth NULL
Definition: ftsmooth.c:416
PVOID Context
Definition: conio_winsrv.h:102
Status
Definition: gdiplustypes.h:24
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by ConSrvInitConsole().

◆ ConSrvInitTerminal()

NTSTATUS NTAPI ConSrvInitTerminal ( IN OUT PTERMINAL  Terminal,
IN OUT PCONSOLE_STATE_INFO  ConsoleInfo,
IN OUT PCONSOLE_INIT_INFO  ConsoleInitInfo,
IN HANDLE  ConsoleLeaderProcessHandle 
)

Definition at line 204 of file terminal.c.

208 {
210  PFRONTEND FrontEnd;
211 
212  /* Load a suitable frontend for the ConSrv terminal */
213  FrontEnd = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*FrontEnd));
214  if (!FrontEnd) return STATUS_NO_MEMORY;
215 
216  Status = ConSrvLoadFrontEnd(FrontEnd,
217  ConsoleInfo,
218  ConsoleInitInfo,
219  ConsoleLeaderProcessHandle);
220  if (!NT_SUCCESS(Status))
221  {
222  DPRINT1("CONSRV: Failed to initialize a frontend, Status = 0x%08lx\n", Status);
223  ConsoleFreeHeap(FrontEnd);
224  return Status;
225  }
226  DPRINT("CONSRV: Frontend initialized\n");
227 
228  /* Initialize the ConSrv terminal */
229  Terminal->Vtbl = &ConSrvTermVtbl;
230  // Terminal->Console will be initialized by ConDrvAttachTerminal
231  Terminal->Context = FrontEnd; /* We store the frontend pointer in the terminal private context */
232 
233  return STATUS_SUCCESS;
234 }
LONG NTSTATUS
Definition: precomp.h:26
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static TERMINAL_VTBL ConSrvTermVtbl
Definition: terminal.c:201
Status
Definition: gdiplustypes.h:24
static NTSTATUS ConSrvLoadFrontEnd(IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
Definition: terminal.c:154
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define DPRINT1
Definition: precomp.h:8
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
return STATUS_SUCCESS
Definition: btrfs.c:3014

Referenced by ConSrvInitConsole().

◆ ConSrvLoadFrontEnd()

static NTSTATUS ConSrvLoadFrontEnd ( IN OUT PFRONTEND  FrontEnd,
IN OUT PCONSOLE_STATE_INFO  ConsoleInfo,
IN OUT PCONSOLE_INIT_INFO  ConsoleInitInfo,
IN HANDLE  ConsoleLeaderProcessHandle 
)
static

Definition at line 154 of file terminal.c.

158 {
160  ULONG i;
161 
162  /*
163  * Choose an adequate terminal front-end to load, and load it
164  */
165  for (i = 0; i < ARRAYSIZE(FrontEndLoadingMethods); ++i)
166  {
167  DPRINT("CONSRV: Trying to load %s frontend...\n",
169  Status = FrontEndLoadingMethods[i].FrontEndLoad(FrontEnd,
170  ConsoleInfo,
171  ConsoleInitInfo,
172  ConsoleLeaderProcessHandle);
173  if (NT_SUCCESS(Status))
174  {
175  /* Save the unload callback */
176  FrontEnd->UnloadFrontEnd = FrontEndLoadingMethods[i].FrontEndUnload;
177 
178  DPRINT("CONSRV: %s frontend loaded successfully\n",
180  break;
181  }
182  else
183  {
184  DPRINT1("CONSRV: Loading %s frontend failed, Status = 0x%08lx , continuing...\n",
186  }
187  }
188 
189  return Status;
190 }
LONG NTSTATUS
Definition: precomp.h:26
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
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
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
CHAR FrontEndName[80]
Definition: terminal.c:140
Status
Definition: gdiplustypes.h:24
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:3014
static struct @4276 FrontEndLoadingMethods[]

Referenced by ConSrvInitTerminal().

◆ ConSrvTermDeinitTerminal()

static VOID NTAPI ConSrvTermDeinitTerminal ( IN OUT PTERMINAL  This)
static

Definition at line 286 of file terminal.c.

287 {
288  PFRONTEND FrontEnd = This->Context;
289  FrontEnd->Vtbl->DeinitFrontEnd(FrontEnd);
290 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98

◆ ConSrvTermDrawRegion()

static VOID NTAPI ConSrvTermDrawRegion ( IN OUT PTERMINAL  This,
SMALL_RECT Region 
)
static

Definition at line 875 of file terminal.c.

877 {
878  PFRONTEND FrontEnd = This->Context;
879  FrontEnd->Vtbl->DrawRegion(FrontEnd, Region);
880 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98

◆ ConSrvTermGetLargestConsoleWindowSize()

static VOID NTAPI ConSrvTermGetLargestConsoleWindowSize ( IN OUT PTERMINAL  This,
PCOORD  pSize 
)
static

Definition at line 926 of file terminal.c.

928 {
929  PFRONTEND FrontEnd = This->Context;
930  FrontEnd->Vtbl->GetLargestConsoleWindowSize(FrontEnd, pSize);
931 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98

◆ ConSrvTermInitTerminal()

static NTSTATUS NTAPI ConSrvTermInitTerminal ( IN OUT PTERMINAL  This,
IN PCONSOLE  Console 
)
static

HACK HACK!! Copy FrontEnd into the console!!

HACK HACK!! Be sure FrontEndIFace is correctly updated in the console!!

Definition at line 260 of file terminal.c.

262 {
264  PFRONTEND FrontEnd = This->Context;
265  PCONSRV_CONSOLE ConSrvConsole = (PCONSRV_CONSOLE)Console;
266 
267  /* Initialize the console pointer for our frontend */
268  FrontEnd->Console = ConSrvConsole;
269 
271  DPRINT("Using FrontEndIFace HACK(1), should be removed after proper implementation!\n");
272  ConSrvConsole->FrontEndIFace = *FrontEnd;
273 
274  Status = FrontEnd->Vtbl->InitFrontEnd(FrontEnd, ConSrvConsole);
275  if (!NT_SUCCESS(Status))
276  DPRINT1("InitFrontEnd failed, Status = 0x%08lx\n", Status);
277 
279  DPRINT("Using FrontEndIFace HACK(2), should be removed after proper implementation!\n");
280  ConSrvConsole->FrontEndIFace = *FrontEnd;
281 
282  return Status;
283 }
LONG NTSTATUS
Definition: precomp.h:26
FRONTEND FrontEndIFace
Definition: conio_winsrv.h:128
struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:101
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98
Status
Definition: gdiplustypes.h:24
struct _CONSRV_CONSOLE * PCONSRV_CONSOLE
CConsole Console
#define DPRINT1
Definition: precomp.h:8

◆ ConSrvTermReadStream()

static NTSTATUS NTAPI ConSrvTermReadStream ( IN OUT PTERMINAL  This,
IN BOOLEAN  Unicode,
OUT PVOID  Buffer,
IN OUT PCONSOLE_READCONSOLE_CONTROL  ReadControl,
IN PVOID Parameter  OPTIONAL,
IN ULONG  NumCharsToRead,
OUT PULONG NumCharsRead  OPTIONAL 
)
static
Parameters
BufferPWCHAR Buffer,*

Definition at line 297 of file terminal.c.

305 {
306  PFRONTEND FrontEnd = This->Context;
307  PCONSRV_CONSOLE Console = FrontEnd->Console;
308  PCONSOLE_INPUT_BUFFER InputBuffer = &Console->InputBuffer;
309  PUNICODE_STRING ExeName = Parameter;
310 
311  // STATUS_PENDING : Wait if more to read ; STATUS_SUCCESS : Don't wait.
313 
314  PLIST_ENTRY CurrentEntry;
316  ULONG i = 0;
317 
318  /* Validity checks */
319  // ASSERT(Console == InputBuffer->Header.Console);
320  ASSERT((Buffer != NULL) || (Buffer == NULL && NumCharsToRead == 0));
321 
322  /* We haven't read anything (yet) */
323 
324  if (InputBuffer->Mode & ENABLE_LINE_INPUT)
325  {
326  /* COOKED mode, call the line discipline */
327 
328  if (Console->LineBuffer == NULL)
329  {
330  /* Start a new line */
331  Console->LineMaxSize = max(256, NumCharsToRead);
332 
333  /*
334  * Fixup ReadControl->nInitialChars in case the number of initial
335  * characters is bigger than the number of characters to be read.
336  * It will always be, lesser than or equal to Console->LineMaxSize.
337  */
338  ReadControl->nInitialChars = min(ReadControl->nInitialChars, NumCharsToRead);
339 
340  Console->LineBuffer = ConsoleAllocHeap(0, Console->LineMaxSize * sizeof(WCHAR));
341  if (Console->LineBuffer == NULL) return STATUS_NO_MEMORY;
342 
343  Console->LinePos = Console->LineSize = ReadControl->nInitialChars;
344  Console->LineComplete = Console->LineUpPressed = FALSE;
345  Console->LineInsertToggle = Console->InsertMode;
346  Console->LineWakeupMask = ReadControl->dwCtrlWakeupMask;
347 
348  /*
349  * Pre-fill the buffer with the nInitialChars from the user buffer.
350  * Since pre-filling is only allowed in Unicode, we don't need to
351  * worry about ANSI <-> Unicode conversion.
352  */
353  memcpy(Console->LineBuffer, Buffer, Console->LineSize * sizeof(WCHAR));
354  if (Console->LineSize >= Console->LineMaxSize)
355  {
356  Console->LineComplete = TRUE;
357  Console->LinePos = 0;
358  }
359  }
360 
361  /* If we don't have a complete line yet, process the pending input */
362  while (!Console->LineComplete && !IsListEmpty(&InputBuffer->InputEvents))
363  {
364  /* Remove an input event from the queue */
365  _InterlockedDecrement((PLONG)&InputBuffer->NumberOfEvents);
366  CurrentEntry = RemoveHeadList(&InputBuffer->InputEvents);
367  if (IsListEmpty(&InputBuffer->InputEvents))
368  {
369  NtClearEvent(InputBuffer->ActiveEvent);
370  }
371  Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
372 
373  /* Only pay attention to key down */
374  if (Input->InputEvent.EventType == KEY_EVENT &&
375  Input->InputEvent.Event.KeyEvent.bKeyDown)
376  {
377  LineInputKeyDown(Console, ExeName,
378  &Input->InputEvent.Event.KeyEvent);
379  ReadControl->dwControlKeyState = Input->InputEvent.Event.KeyEvent.dwControlKeyState;
380  }
382  }
383 
384  /* Check if we have a complete line to read from */
385  if (Console->LineComplete)
386  {
387  /*
388  * Console->LinePos keeps the next position of the character to read
389  * in the line buffer across the different calls of the function,
390  * so that the line buffer can be read by chunks after all the input
391  * has been buffered.
392  */
393 
394  while (i < NumCharsToRead && Console->LinePos < Console->LineSize)
395  {
396  WCHAR Char = Console->LineBuffer[Console->LinePos++];
397 
398  if (Unicode)
399  {
400  ((PWCHAR)Buffer)[i] = Char;
401  }
402  else
403  {
405  }
406  ++i;
407  }
408 
409  if (Console->LinePos >= Console->LineSize)
410  {
411  /* The entire line has been read */
412  ConsoleFreeHeap(Console->LineBuffer);
413  Console->LineBuffer = NULL;
414  Console->LinePos = Console->LineMaxSize = Console->LineSize = 0;
415  // Console->LineComplete = Console->LineUpPressed = FALSE;
416  Console->LineComplete = FALSE;
417  }
418 
420  }
421  }
422  else
423  {
424  /* RAW mode */
425 
426  /* Character input */
427  while (i < NumCharsToRead && !IsListEmpty(&InputBuffer->InputEvents))
428  {
429  /* Remove an input event from the queue */
430  _InterlockedDecrement((PLONG)&InputBuffer->NumberOfEvents);
431  CurrentEntry = RemoveHeadList(&InputBuffer->InputEvents);
432  if (IsListEmpty(&InputBuffer->InputEvents))
433  {
434  NtClearEvent(InputBuffer->ActiveEvent);
435  }
436  Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
437 
438  /* Only pay attention to valid characters, on key down */
439  if (Input->InputEvent.EventType == KEY_EVENT &&
440  Input->InputEvent.Event.KeyEvent.bKeyDown &&
441  Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar != L'\0')
442  {
443  WCHAR Char = Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar;
444 
445  if (Unicode)
446  {
447  ((PWCHAR)Buffer)[i] = Char;
448  }
449  else
450  {
452  }
453  ++i;
454 
455  /* Did read something */
457  }
459  }
460  }
461 
462  // FIXME: Only set if Status == STATUS_SUCCESS ???
463  if (NumCharsRead) *NumCharsRead = i;
464 
465  return Status;
466 }
signed char * PCHAR
Definition: retypes.h:7
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
Definition: arc.h:84
uint16_t * PWCHAR
Definition: typedefs.h:56
_In_ PVOID Parameter
Definition: ldrtypes.h:241
VOID LineInputKeyDown(PCONSRV_CONSOLE Console, PUNICODE_STRING ExeName, KEY_EVENT_RECORD *KeyEvent)
Definition: lineinput.c:147
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:101
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 FALSE
Definition: types.h:117
#define KEY_EVENT
Definition: wincon.h:128
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
Definition: bufpool.h:45
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define STATUS_PENDING
Definition: ntstatus.h:82
#define ENABLE_LINE_INPUT
Definition: wincon.h:79
CHAR InputBuffer[80]
Definition: conmgr.c:33
#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar)
Definition: terminal.c:36
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: typedefs.h:119
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
NTSTATUS NTAPI NtClearEvent(IN HANDLE EventHandle)
Definition: event.c:69
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:3014
signed int * PLONG
Definition: retypes.h:5

◆ ConSrvTermReleaseScreenBuffer()

static VOID NTAPI ConSrvTermReleaseScreenBuffer ( IN OUT PTERMINAL  This,
IN PCONSOLE_SCREEN_BUFFER  ScreenBuffer 
)
static

Definition at line 918 of file terminal.c.

920 {
921  PFRONTEND FrontEnd = This->Context;
922  FrontEnd->Vtbl->ReleaseScreenBuffer(FrontEnd, ScreenBuffer);
923 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98
HANDLE ScreenBuffer
Definition: notevil.c:37

◆ ConSrvTermResizeTerminal()

static VOID NTAPI ConSrvTermResizeTerminal ( IN OUT PTERMINAL  This)
static

Definition at line 904 of file terminal.c.

905 {
906  PFRONTEND FrontEnd = This->Context;
907  FrontEnd->Vtbl->ResizeTerminal(FrontEnd);
908 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98

◆ ConSrvTermSetActiveScreenBuffer()

static VOID NTAPI ConSrvTermSetActiveScreenBuffer ( IN OUT PTERMINAL  This)
static

Definition at line 911 of file terminal.c.

912 {
913  PFRONTEND FrontEnd = This->Context;
914  FrontEnd->Vtbl->SetActiveScreenBuffer(FrontEnd);
915 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98

◆ ConSrvTermSetCursorInfo()

static BOOL NTAPI ConSrvTermSetCursorInfo ( IN OUT PTERMINAL  This,
PCONSOLE_SCREEN_BUFFER  ScreenBuffer 
)
static

Definition at line 883 of file terminal.c.

885 {
886  PFRONTEND FrontEnd = This->Context;
887  return FrontEnd->Vtbl->SetCursorInfo(FrontEnd, ScreenBuffer);
888 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98
HANDLE ScreenBuffer
Definition: notevil.c:37

◆ ConSrvTermSetPalette()

static BOOL NTAPI ConSrvTermSetPalette ( IN OUT PTERMINAL  This,
HPALETTE  PaletteHandle,
UINT  PaletteUsage 
)
static

Definition at line 934 of file terminal.c.

937 {
938  PFRONTEND FrontEnd = This->Context;
939  return FrontEnd->Vtbl->SetPalette(FrontEnd, PaletteHandle, PaletteUsage);
940 }
static HPALETTE PaletteHandle
Definition: svga.c:215
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98

◆ ConSrvTermSetScreenInfo()

static BOOL NTAPI ConSrvTermSetScreenInfo ( IN OUT PTERMINAL  This,
PCONSOLE_SCREEN_BUFFER  ScreenBuffer,
SHORT  OldCursorX,
SHORT  OldCursorY 
)
static

Definition at line 891 of file terminal.c.

895 {
896  PFRONTEND FrontEnd = This->Context;
897  return FrontEnd->Vtbl->SetScreenInfo(FrontEnd,
898  ScreenBuffer,
899  OldCursorX,
900  OldCursorY);
901 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98
HANDLE ScreenBuffer
Definition: notevil.c:37

◆ ConSrvTermShowMouseCursor()

static INT NTAPI ConSrvTermShowMouseCursor ( IN OUT PTERMINAL  This,
BOOL  Show 
)
static

Definition at line 943 of file terminal.c.

945 {
946  PFRONTEND FrontEnd = This->Context;
947  return FrontEnd->Vtbl->ShowMouseCursor(FrontEnd, Show);
948 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:98

◆ ConSrvTermWriteStream()

static NTSTATUS NTAPI ConSrvTermWriteStream ( IN OUT PTERMINAL  This,
PTEXTMODE_SCREEN_BUFFER  Buff,
PWCHAR  Buffer,
DWORD  Length,
BOOL  Attrib 
)
static

Definition at line 841 of file terminal.c.

846 {
847  PFRONTEND FrontEnd = This->Context;
848  return ConioWriteConsole(FrontEnd,
849  Buff,
850  Buffer,
851  Length,
852  Attrib);
853 }
static NTSTATUS ConioWriteConsole(PFRONTEND FrontEnd, PTEXTMODE_SCREEN_BUFFER Buff, PWCHAR Buffer, DWORD Length, BOOL Attrib)
Definition: terminal.c:503
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101

◆ ConSrvUnloadFrontEnd()

static NTSTATUS ConSrvUnloadFrontEnd ( IN PFRONTEND  FrontEnd)
static

Definition at line 193 of file terminal.c.

194 {
195  if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
196  // return FrontEnd->Vtbl->UnloadFrontEnd(FrontEnd);
197  return FrontEnd->UnloadFrontEnd(FrontEnd);
198 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416

Referenced by ConSrvDeinitTerminal().

◆ GuiLoadFrontEnd()

NTSTATUS NTAPI GuiLoadFrontEnd ( IN OUT PFRONTEND  FrontEnd,
IN OUT PCONSOLE_STATE_INFO  ConsoleInfo,
IN OUT PCONSOLE_INIT_INFO  ConsoleInitInfo,
IN HANDLE  ConsoleLeaderProcessHandle 
)

Definition at line 1177 of file guiterm.c.

1181 {
1182  PCONSOLE_START_INFO ConsoleStartInfo;
1183  PGUI_INIT_INFO GuiInitInfo;
1184  USEROBJECTFLAGS UserObjectFlags;
1185 
1186  if (FrontEnd == NULL || ConsoleInfo == NULL || ConsoleInitInfo == NULL)
1187  return STATUS_INVALID_PARAMETER;
1188 
1189  ConsoleStartInfo = ConsoleInitInfo->ConsoleStartInfo;
1190 
1191  /*
1192  * Initialize a private initialization info structure for later use.
1193  * It must be freed by a call to GuiUnloadFrontEnd or GuiInitFrontEnd.
1194  */
1195  GuiInitInfo = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*GuiInitInfo));
1196  if (GuiInitInfo == NULL) return STATUS_NO_MEMORY;
1197 
1198  /* Initialize GUI terminal emulator common functionalities */
1199  if (!GuiInit(ConsoleInitInfo, ConsoleLeaderProcessHandle, GuiInitInfo))
1200  {
1201  ConsoleFreeHeap(GuiInitInfo);
1202  return STATUS_UNSUCCESSFUL;
1203  }
1204 
1205  GuiInitInfo->IsWindowVisible = ConsoleInitInfo->IsWindowVisible;
1206  if (GuiInitInfo->IsWindowVisible)
1207  {
1208  /* Don't show the console if the window station is not interactive */
1209  if (GetUserObjectInformationW(GuiInitInfo->WinSta,
1210  UOI_FLAGS,
1211  &UserObjectFlags,
1212  sizeof(UserObjectFlags),
1213  NULL))
1214  {
1215  if (!(UserObjectFlags.dwFlags & WSF_VISIBLE))
1216  GuiInitInfo->IsWindowVisible = FALSE;
1217  }
1218  }
1219 
1220  /*
1221  * Load terminal settings
1222  */
1223 #if 0
1224  /* Impersonate the caller in order to retrieve settings in its context */
1225  // if (!CsrImpersonateClient(NULL))
1226  // return STATUS_UNSUCCESSFUL;
1228 
1229  /* 1. Load the default settings */
1230  GuiConsoleGetDefaultSettings(&GuiInitInfo->TermInfo);
1231 #endif
1232 
1233  GuiInitInfo->TermInfo.ShowWindow = SW_SHOWNORMAL;
1234 
1235  if (GuiInitInfo->IsWindowVisible)
1236  {
1237  /* 2. Load the remaining console settings via the registry */
1238  if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
1239  {
1240 #if 0
1241  /* Load the terminal information from the registry */
1242  GuiConsoleReadUserSettings(&GuiInitInfo->TermInfo);
1243 #endif
1244 
1245  /*
1246  * Now, update them with the properties the user might gave to us
1247  * via the STARTUPINFO structure before calling CreateProcess
1248  * (and which was transmitted via the ConsoleStartInfo structure).
1249  * We therefore overwrite the values read in the registry.
1250  */
1251  if (ConsoleStartInfo->dwStartupFlags & STARTF_USESHOWWINDOW)
1252  {
1253  GuiInitInfo->TermInfo.ShowWindow = ConsoleStartInfo->wShowWindow;
1254  }
1255  if (ConsoleStartInfo->dwStartupFlags & STARTF_USEPOSITION)
1256  {
1257  ConsoleInfo->AutoPosition = FALSE;
1258  ConsoleInfo->WindowPosition.x = ConsoleStartInfo->dwWindowOrigin.X;
1259  ConsoleInfo->WindowPosition.y = ConsoleStartInfo->dwWindowOrigin.Y;
1260  }
1261  if (ConsoleStartInfo->dwStartupFlags & STARTF_RUNFULLSCREEN)
1262  {
1263  ConsoleInfo->FullScreen = TRUE;
1264  }
1265  }
1266  }
1267 
1268 #if 0
1269  /* Revert impersonation */
1270  CsrRevertToSelf();
1271 #endif
1272 
1273  // Font data
1274  StringCchCopyNW(GuiInitInfo->TermInfo.FaceName, ARRAYSIZE(GuiInitInfo->TermInfo.FaceName),
1275  ConsoleInfo->FaceName, ARRAYSIZE(ConsoleInfo->FaceName));
1276  GuiInitInfo->TermInfo.FontFamily = ConsoleInfo->FontFamily;
1277  GuiInitInfo->TermInfo.FontSize = ConsoleInfo->FontSize;
1278  GuiInitInfo->TermInfo.FontWeight = ConsoleInfo->FontWeight;
1279 
1280  // Display
1281  GuiInitInfo->TermInfo.FullScreen = ConsoleInfo->FullScreen;
1282  GuiInitInfo->TermInfo.AutoPosition = ConsoleInfo->AutoPosition;
1283  GuiInitInfo->TermInfo.WindowOrigin = ConsoleInfo->WindowPosition;
1284 
1285  /* Initialize the icon handles */
1286  // if (ConsoleStartInfo->hIcon != NULL)
1287  GuiInitInfo->hIcon = ConsoleStartInfo->hIcon;
1288  // else
1289  // GuiInitInfo->hIcon = ghDefaultIcon;
1290 
1291  // if (ConsoleStartInfo->hIconSm != NULL)
1292  GuiInitInfo->hIconSm = ConsoleStartInfo->hIconSm;
1293  // else
1294  // GuiInitInfo->hIconSm = ghDefaultIconSm;
1295 
1296  // ASSERT(GuiInitInfo->hIcon && GuiInitInfo->hIconSm);
1297 
1298  /* Finally, initialize the frontend structure */
1299  FrontEnd->Vtbl = &GuiVtbl;
1300  FrontEnd->Context = NULL;
1301  FrontEnd->Context2 = GuiInitInfo;
1302 
1303  return STATUS_SUCCESS;
1304 }
static FRONTEND_VTBL GuiVtbl
Definition: guiterm.c:1147
VOID GuiConsoleGetDefaultSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:38
#define STARTF_RUNFULLSCREEN
Definition: winbase.h:477
STRSAFEAPI StringCchCopyNW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc, size_t cchToCopy)
Definition: strsafe.h:236
BOOL WINAPI GetUserObjectInformationW(_In_ HANDLE hObj, _In_ int nIndex, _Out_writes_bytes_opt_(nLength) PVOID pvInfo, _In_ DWORD nLength, _Out_opt_ LPDWORD lpnLengthNeeded)
HICON hIcon
Definition: guiterm.c:39
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1056
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define STARTF_USEPOSITION
Definition: winbase.h:474
BOOLEAN IsWindowVisible
Definition: guiterm.c:41
HICON hIconSm
Definition: guiterm.c:40
#define FALSE
Definition: types.h:117
GUI_CONSOLE_INFO TermInfo
Definition: guiterm.c:42
HWINSTA WinSta
Definition: guiterm.c:37
smooth NULL
Definition: ftsmooth.c:416
#define STARTF_USESHOWWINDOW
Definition: winbase.h:472
#define WSF_VISIBLE
Definition: winuser.h:2427
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static BOOL GuiInit(IN PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle, IN OUT PGUI_INIT_INFO GuiInitInfo)
Definition: guiterm.c:284
#define SW_SHOWNORMAL
Definition: winuser.h:764
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define UOI_FLAGS
Definition: winuser.h:1073
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:931
return STATUS_SUCCESS
Definition: btrfs.c:3014
BOOL GuiConsoleReadUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:24

◆ GuiUnloadFrontEnd()

NTSTATUS NTAPI GuiUnloadFrontEnd ( IN OUT PFRONTEND  FrontEnd)

Definition at line 1307 of file guiterm.c.

1308 {
1309  if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
1310 
1311  if (FrontEnd->Context ) GuiDeinitFrontEnd(FrontEnd);
1312  if (FrontEnd->Context2) ConsoleFreeHeap(FrontEnd->Context2);
1313 
1314  return STATUS_SUCCESS;
1315 }
static VOID NTAPI GuiDeinitFrontEnd(IN OUT PFRONTEND This)
Definition: guiterm.c:594
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
return STATUS_SUCCESS
Definition: btrfs.c:3014

Variable Documentation

◆ ConSrvTermVtbl

static TERMINAL_VTBL ConSrvTermVtbl
static
Initial value:
=
{
}
static NTSTATUS NTAPI ConSrvTermWriteStream(IN OUT PTERMINAL This, PTEXTMODE_SCREEN_BUFFER Buff, PWCHAR Buffer, DWORD Length, BOOL Attrib)
Definition: terminal.c:841
static NTSTATUS NTAPI ConSrvTermReadStream(IN OUT PTERMINAL This, IN BOOLEAN Unicode, OUT PVOID Buffer, IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl, IN PVOID Parameter OPTIONAL, IN ULONG NumCharsToRead, OUT PULONG NumCharsRead OPTIONAL)
Definition: terminal.c:297
static VOID NTAPI ConSrvTermResizeTerminal(IN OUT PTERMINAL This)
Definition: terminal.c:904
static BOOL NTAPI ConSrvTermSetPalette(IN OUT PTERMINAL This, HPALETTE PaletteHandle, UINT PaletteUsage)
Definition: terminal.c:934
static VOID NTAPI ConSrvTermGetLargestConsoleWindowSize(IN OUT PTERMINAL This, PCOORD pSize)
Definition: terminal.c:926
static BOOL NTAPI ConSrvTermSetCursorInfo(IN OUT PTERMINAL This, PCONSOLE_SCREEN_BUFFER ScreenBuffer)
Definition: terminal.c:883
static BOOL NTAPI ConSrvTermSetScreenInfo(IN OUT PTERMINAL This, PCONSOLE_SCREEN_BUFFER ScreenBuffer, SHORT OldCursorX, SHORT OldCursorY)
Definition: terminal.c:891
static VOID NTAPI ConSrvTermDeinitTerminal(IN OUT PTERMINAL This)
Definition: terminal.c:286
static VOID NTAPI ConSrvTermDrawRegion(IN OUT PTERMINAL This, SMALL_RECT *Region)
Definition: terminal.c:875
static VOID NTAPI ConSrvTermReleaseScreenBuffer(IN OUT PTERMINAL This, IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
Definition: terminal.c:918
static VOID NTAPI ConSrvTermSetActiveScreenBuffer(IN OUT PTERMINAL This)
Definition: terminal.c:911
static INT NTAPI ConSrvTermShowMouseCursor(IN OUT PTERMINAL This, BOOL Show)
Definition: terminal.c:943
static NTSTATUS NTAPI ConSrvTermInitTerminal(IN OUT PTERMINAL This, IN PCONSOLE Console)
Definition: terminal.c:260

Definition at line 201 of file terminal.c.

Referenced by ConSrvInitTerminal().

◆ FrontEndLoad

FRONTEND_LOAD FrontEndLoad

Definition at line 141 of file terminal.c.

◆ FrontEndLoadingMethods

struct { ... } FrontEndLoadingMethods[]
Initial value:
=
{
}
NTSTATUS NTAPI GuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd)
Definition: guiterm.c:1307
NTSTATUS NTAPI GuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
Definition: guiterm.c:1177

Referenced by ConSrvLoadFrontEnd().

◆ FrontEndName

CHAR FrontEndName[80]

Definition at line 140 of file terminal.c.

Referenced by ConSrvLoadFrontEnd().

◆ FrontEndUnload

FRONTEND_UNLOAD FrontEndUnload

Definition at line 142 of file terminal.c.