ReactOS  0.4.14-dev-114-gc8cbd56
terminal.c File Reference
#include <consrv.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:
ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
uint32_t ULONG_PTR
Definition: typedefs.h:63
UINT InputCodePage
Definition: console.c:25
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console

Definition at line 39 of file terminal.c.

◆ ConsoleInputUnicodeCharToAnsiChar

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

Definition at line 35 of file terminal.c.

◆ NDEBUG

#define NDEBUG

Definition at line 18 of file terminal.c.

◆ TAB_WIDTH

#define TAB_WIDTH   8

Definition at line 465 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 107 of file terminal.c.

◆ FRONTEND_UNLOAD

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

Definition at line 113 of file terminal.c.

Function Documentation

◆ ClearLineBuffer()

VOID 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().

◆ ConioDrawConsole()

VOID ConioDrawConsole ( PCONSRV_CONSOLE  Console)

Definition at line 663 of file terminal.c.

664 {
666  PCONSOLE_SCREEN_BUFFER ActiveBuffer = Console->ActiveBuffer;
667 
668  if (!ActiveBuffer) return;
669 
670  ConioInitRect(&Region, 0, 0,
671  ActiveBuffer->ViewSize.Y - 1,
672  ActiveBuffer->ViewSize.X - 1);
674  // Console->FrontEndIFace.Vtbl->DrawRegion(&Console->FrontEndIFace, &Region);
675 }
#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 ConDrvProcessKey(), and ConioProcessKey().

◆ ConioNextLine()

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

Definition at line 472 of file terminal.c.

473 {
474  /* If we hit bottom, slide the viewable screen */
475  if (++Buff->CursorPosition.Y == Buff->ScreenBufferSize.Y)
476  {
477  Buff->CursorPosition.Y--;
478  if (++Buff->VirtualY == Buff->ScreenBufferSize.Y)
479  {
480  Buff->VirtualY = 0;
481  }
482  (*ScrolledLines)++;
483  ClearLineBuffer(Buff);
484  if (UpdateRect->Top != 0)
485  {
486  UpdateRect->Top--;
487  }
488  }
489  UpdateRect->Left = 0;
490  UpdateRect->Right = Buff->ScreenBufferSize.X - 1;
491  UpdateRect->Bottom = Buff->CursorPosition.Y;
492 }
VOID ClearLineBuffer(PTEXTMODE_SCREEN_BUFFER Buff)
Definition: text.c:146
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 495 of file terminal.c.

500 {
501  PCONSRV_CONSOLE Console = FrontEnd->Console;
502 
503  UINT i;
504  PCHAR_INFO Ptr;
506  SHORT CursorStartX, CursorStartY;
507  UINT ScrolledLines;
508 
509  CursorStartX = Buff->CursorPosition.X;
510  CursorStartY = Buff->CursorPosition.Y;
511  UpdateRect.Left = Buff->ScreenBufferSize.X;
512  UpdateRect.Top = Buff->CursorPosition.Y;
513  UpdateRect.Right = -1;
514  UpdateRect.Bottom = Buff->CursorPosition.Y;
515  ScrolledLines = 0;
516 
517  for (i = 0; i < Length; i++)
518  {
519  /*
520  * If we are in processed mode, interpret special characters and
521  * display them correctly. Otherwise, just put them into the buffer.
522  */
523  if (Buff->Mode & ENABLE_PROCESSED_OUTPUT)
524  {
525  /* --- CR --- */
526  if (Buffer[i] == L'\r')
527  {
528  Buff->CursorPosition.X = 0;
529  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
530  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
531  continue;
532  }
533  /* --- LF --- */
534  else if (Buffer[i] == L'\n')
535  {
536  Buff->CursorPosition.X = 0;
537  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
538  continue;
539  }
540  /* --- BS --- */
541  else if (Buffer[i] == L'\b')
542  {
543  /* Only handle BS if we're not on the first pos of the first line */
544  if (0 != Buff->CursorPosition.X || 0 != Buff->CursorPosition.Y)
545  {
546  if (0 == Buff->CursorPosition.X)
547  {
548  /* slide virtual position up */
549  Buff->CursorPosition.X = Buff->ScreenBufferSize.X - 1;
550  Buff->CursorPosition.Y--;
551  UpdateRect.Top = min(UpdateRect.Top, Buff->CursorPosition.Y);
552  }
553  else
554  {
555  Buff->CursorPosition.X--;
556  }
557  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
558  Ptr->Char.UnicodeChar = L' ';
559  Ptr->Attributes = Buff->ScreenDefaultAttrib;
560  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
561  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
562  }
563  continue;
564  }
565  /* --- TAB --- */
566  else if (Buffer[i] == L'\t')
567  {
568  UINT EndX;
569 
570  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
571  EndX = (Buff->CursorPosition.X + TAB_WIDTH) & ~(TAB_WIDTH - 1);
572  EndX = min(EndX, (UINT)Buff->ScreenBufferSize.X);
573  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
574  while ((UINT)Buff->CursorPosition.X < EndX)
575  {
576  Ptr->Char.UnicodeChar = L' ';
577  Ptr->Attributes = Buff->ScreenDefaultAttrib;
578  ++Ptr;
579  Buff->CursorPosition.X++;
580  }
581  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X - 1);
582  if (Buff->CursorPosition.X == Buff->ScreenBufferSize.X)
583  {
584  if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT)
585  {
586  Buff->CursorPosition.X = 0;
587  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
588  }
589  else
590  {
591  Buff->CursorPosition.X--;
592  }
593  }
594  continue;
595  }
596  /* --- BEL ---*/
597  else if (Buffer[i] == L'\a')
598  {
599  FrontEnd->Vtbl->RingBell(FrontEnd);
600  continue;
601  }
602  }
603  UpdateRect.Left = min(UpdateRect.Left, Buff->CursorPosition.X);
604  UpdateRect.Right = max(UpdateRect.Right, Buff->CursorPosition.X);
605 
606  Ptr = ConioCoordToPointer(Buff, Buff->CursorPosition.X, Buff->CursorPosition.Y);
607  Ptr->Char.UnicodeChar = Buffer[i];
608  if (Attrib) Ptr->Attributes = Buff->ScreenDefaultAttrib;
609 
610  Buff->CursorPosition.X++;
611  if (Buff->CursorPosition.X == Buff->ScreenBufferSize.X)
612  {
613  if (Buff->Mode & ENABLE_WRAP_AT_EOL_OUTPUT)
614  {
615  Buff->CursorPosition.X = 0;
616  ConioNextLine(Buff, &UpdateRect, &ScrolledLines);
617  }
618  else
619  {
620  Buff->CursorPosition.X = CursorStartX;
621  }
622  }
623  }
624 
625  if (!ConioIsRectEmpty(&UpdateRect) && (PCONSOLE_SCREEN_BUFFER)Buff == Console->ActiveBuffer)
626  {
627  // TermWriteStream(Console, &UpdateRect, CursorStartX, CursorStartY,
628  // ScrolledLines, Buffer, Length);
629  FrontEnd->Vtbl->WriteStream(FrontEnd,
630  &UpdateRect,
631  CursorStartX,
632  CursorStartY,
633  ScrolledLines,
634  Buffer,
635  Length);
636  }
637 
638  return STATUS_SUCCESS;
639 }
#define max(a, b)
Definition: svc.c:63
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 PCONSRV_CONSOLE
Definition: conio.h:27
struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:120
#define ENABLE_WRAP_AT_EOL_OUTPUT
Definition: blue.h:45
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
Definition: bufpool.h:45
#define TAB_WIDTH
Definition: terminal.c:465
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:44
static VOID ConioNextLine(PTEXTMODE_SCREEN_BUFFER Buff, PSMALL_RECT UpdateRect, PUINT ScrolledLines)
Definition: terminal.c:472
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
CConsole Console
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
#define ConioIsRectEmpty(Rect)
Definition: rect.h:28
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by ConSrvTermWriteStream(), LineInputEdit(), and LineInputKeyDown().

◆ ConSrvDeinitTerminal()

NTSTATUS NTAPI ConSrvDeinitTerminal ( IN OUT PTERMINAL  Terminal)

Definition at line 232 of file terminal.c.

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

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 199 of file terminal.c.

203 {
205  PFRONTEND FrontEnd;
206 
207  /* Load a suitable frontend for the ConSrv terminal */
208  FrontEnd = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*FrontEnd));
209  if (!FrontEnd) return STATUS_NO_MEMORY;
210 
211  Status = ConSrvLoadFrontEnd(FrontEnd,
212  ConsoleInfo,
213  ConsoleInitInfo,
214  ConsoleLeaderProcessHandle);
215  if (!NT_SUCCESS(Status))
216  {
217  DPRINT1("CONSRV: Failed to initialize a frontend, Status = 0x%08lx\n", Status);
218  ConsoleFreeHeap(FrontEnd);
219  return Status;
220  }
221  DPRINT("CONSRV: Frontend initialized\n");
222 
223  /* Initialize the ConSrv terminal */
224  Terminal->Vtbl = &ConSrvTermVtbl;
225  // Terminal->Console will be initialized by ConDrvAttachTerminal
226  Terminal->Context = FrontEnd; /* We store the frontend pointer in the terminal private context */
227 
228  return STATUS_SUCCESS;
229 }
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:196
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:149
Status
Definition: gdiplustypes.h:24
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define DPRINT1
Definition: precomp.h:8
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
return STATUS_SUCCESS
Definition: btrfs.c:2966

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 149 of file terminal.c.

153 {
155  ULONG i;
156 
157  /*
158  * Choose an adequate terminal front-end to load, and load it
159  */
160  for (i = 0; i < ARRAYSIZE(FrontEndLoadingMethods); ++i)
161  {
162  DPRINT("CONSRV: Trying to load %s frontend...\n",
164  Status = FrontEndLoadingMethods[i].FrontEndLoad(FrontEnd,
165  ConsoleInfo,
166  ConsoleInitInfo,
167  ConsoleLeaderProcessHandle);
168  if (NT_SUCCESS(Status))
169  {
170  /* Save the unload callback */
171  FrontEnd->UnloadFrontEnd = FrontEndLoadingMethods[i].FrontEndUnload;
172 
173  DPRINT("CONSRV: %s frontend loaded successfully\n",
175  break;
176  }
177  else
178  {
179  DPRINT1("CONSRV: Loading %s frontend failed, Status = 0x%08lx , continuing...\n",
181  }
182  }
183 
184  return Status;
185 }
static struct @4142 FrontEndLoadingMethods[]
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:135
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:2966

Referenced by ConSrvInitTerminal().

◆ ConSrvTermDeinitTerminal()

static VOID NTAPI ConSrvTermDeinitTerminal ( IN OUT PTERMINAL  This)
static

Definition at line 280 of file terminal.c.

281 {
282  PFRONTEND FrontEnd = This->Context;
283  FrontEnd->Vtbl->DeinitFrontEnd(FrontEnd);
284 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117

◆ ConSrvTermDrawRegion()

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

Definition at line 678 of file terminal.c.

680 {
681  PFRONTEND FrontEnd = This->Context;
682  FrontEnd->Vtbl->DrawRegion(FrontEnd, Region);
683 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117

◆ ConSrvTermGetLargestConsoleWindowSize()

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

Definition at line 729 of file terminal.c.

731 {
732  PFRONTEND FrontEnd = This->Context;
733  FrontEnd->Vtbl->GetLargestConsoleWindowSize(FrontEnd, pSize);
734 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117

◆ 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 255 of file terminal.c.

257 {
259  PFRONTEND FrontEnd = This->Context;
260 
261  /* Initialize the console pointer for our frontend */
262  FrontEnd->Console = Console;
263 
265  DPRINT("Using FrontEndIFace HACK(1), should be removed after proper implementation!\n");
266  Console->FrontEndIFace = *FrontEnd;
267 
268  Status = FrontEnd->Vtbl->InitFrontEnd(FrontEnd, FrontEnd->Console);
269  if (!NT_SUCCESS(Status))
270  DPRINT1("InitFrontEnd failed, Status = 0x%08lx\n", Status);
271 
273  DPRINT("Using FrontEndIFace HACK(2), should be removed after proper implementation!\n");
274  Console->FrontEndIFace = *FrontEnd;
275 
276  return Status;
277 }
LONG NTSTATUS
Definition: precomp.h:26
struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:120
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117
Status
Definition: gdiplustypes.h:24
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 291 of file terminal.c.

299 {
300  PFRONTEND FrontEnd = This->Context;
301  PCONSRV_CONSOLE Console = FrontEnd->Console;
302  PCONSOLE_INPUT_BUFFER InputBuffer = &Console->InputBuffer;
303  PUNICODE_STRING ExeName = Parameter;
304 
305  // STATUS_PENDING : Wait if more to read ; STATUS_SUCCESS : Don't wait.
307 
308  PLIST_ENTRY CurrentEntry;
310  ULONG i = 0;
311 
312  /* Validity checks */
313  // ASSERT(Console == InputBuffer->Header.Console);
314  ASSERT((Buffer != NULL) || (Buffer == NULL && NumCharsToRead == 0));
315 
316  /* We haven't read anything (yet) */
317 
318  if (InputBuffer->Mode & ENABLE_LINE_INPUT)
319  {
320  /* COOKED mode, call the line discipline */
321 
322  if (Console->LineBuffer == NULL)
323  {
324  /* Start a new line */
325  Console->LineMaxSize = max(256, NumCharsToRead);
326 
327  /*
328  * Fixup ReadControl->nInitialChars in case the number of initial
329  * characters is bigger than the number of characters to be read.
330  * It will always be, lesser than or equal to Console->LineMaxSize.
331  */
332  ReadControl->nInitialChars = min(ReadControl->nInitialChars, NumCharsToRead);
333 
334  Console->LineBuffer = ConsoleAllocHeap(0, Console->LineMaxSize * sizeof(WCHAR));
335  if (Console->LineBuffer == NULL) return STATUS_NO_MEMORY;
336 
337  Console->LinePos = Console->LineSize = ReadControl->nInitialChars;
338  Console->LineComplete = Console->LineUpPressed = FALSE;
339  Console->LineInsertToggle = Console->InsertMode;
340  Console->LineWakeupMask = ReadControl->dwCtrlWakeupMask;
341 
342  /*
343  * Pre-fill the buffer with the nInitialChars from the user buffer.
344  * Since pre-filling is only allowed in Unicode, we don't need to
345  * worry about ANSI <-> Unicode conversion.
346  */
347  memcpy(Console->LineBuffer, Buffer, Console->LineSize * sizeof(WCHAR));
348  if (Console->LineSize >= Console->LineMaxSize)
349  {
350  Console->LineComplete = TRUE;
351  Console->LinePos = 0;
352  }
353  }
354 
355  /* If we don't have a complete line yet, process the pending input */
356  while (!Console->LineComplete && !IsListEmpty(&InputBuffer->InputEvents))
357  {
358  /* Remove an input event from the queue */
359  CurrentEntry = RemoveHeadList(&InputBuffer->InputEvents);
360  if (IsListEmpty(&InputBuffer->InputEvents))
361  {
362  ResetEvent(InputBuffer->ActiveEvent);
363  }
364  Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
365 
366  /* Only pay attention to key down */
367  if (Input->InputEvent.EventType == KEY_EVENT &&
368  Input->InputEvent.Event.KeyEvent.bKeyDown)
369  {
370  LineInputKeyDown(Console, ExeName,
371  &Input->InputEvent.Event.KeyEvent);
372  ReadControl->dwControlKeyState = Input->InputEvent.Event.KeyEvent.dwControlKeyState;
373  }
375  }
376 
377  /* Check if we have a complete line to read from */
378  if (Console->LineComplete)
379  {
380  /*
381  * Console->LinePos keeps the next position of the character to read
382  * in the line buffer across the different calls of the function,
383  * so that the line buffer can be read by chunks after all the input
384  * has been buffered.
385  */
386 
387  while (i < NumCharsToRead && Console->LinePos < Console->LineSize)
388  {
389  WCHAR Char = Console->LineBuffer[Console->LinePos++];
390 
391  if (Unicode)
392  {
393  ((PWCHAR)Buffer)[i] = Char;
394  }
395  else
396  {
398  }
399  ++i;
400  }
401 
402  if (Console->LinePos >= Console->LineSize)
403  {
404  /* The entire line has been read */
405  ConsoleFreeHeap(Console->LineBuffer);
406  Console->LineBuffer = NULL;
407  Console->LinePos = Console->LineMaxSize = Console->LineSize = 0;
408  // Console->LineComplete = Console->LineUpPressed = FALSE;
409  Console->LineComplete = FALSE;
410  }
411 
413  }
414  }
415  else
416  {
417  /* RAW mode */
418 
419  /* Character input */
420  while (i < NumCharsToRead && !IsListEmpty(&InputBuffer->InputEvents))
421  {
422  /* Remove an input event from the queue */
423  CurrentEntry = RemoveHeadList(&InputBuffer->InputEvents);
424  if (IsListEmpty(&InputBuffer->InputEvents))
425  {
426  ResetEvent(InputBuffer->ActiveEvent);
427  }
428  Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
429 
430  /* Only pay attention to valid characters, on key down */
431  if (Input->InputEvent.EventType == KEY_EVENT &&
432  Input->InputEvent.Event.KeyEvent.bKeyDown &&
433  Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar != L'\0')
434  {
435  WCHAR Char = Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar;
436 
437  if (Unicode)
438  {
439  ((PWCHAR)Buffer)[i] = Char;
440  }
441  else
442  {
444  }
445  ++i;
446 
447  /* Did read something */
449  }
451  }
452  }
453 
454  // FIXME: Only set if Status == STATUS_SUCCESS ???
455  if (NumCharsRead) *NumCharsRead = i;
456 
457  return Status;
458 }
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:54
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID LineInputKeyDown(PCONSRV_CONSOLE Console, PUNICODE_STRING ExeName, KEY_EVENT_RECORD *KeyEvent)
Definition: lineinput.c:166
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
CHAR InputBuffer[80]
Definition: conmgr.c:33
struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:120
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 KEY_EVENT
Definition: wincon.h:122
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:76
#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar)
Definition: terminal.c:35
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define min(a, b)
Definition: monoChain.cc:55
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ ConSrvTermReleaseScreenBuffer()

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

Definition at line 721 of file terminal.c.

723 {
724  PFRONTEND FrontEnd = This->Context;
725  FrontEnd->Vtbl->ReleaseScreenBuffer(FrontEnd, ScreenBuffer);
726 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117
HANDLE ScreenBuffer
Definition: notevil.c:37

◆ ConSrvTermResizeTerminal()

static VOID NTAPI ConSrvTermResizeTerminal ( IN OUT PTERMINAL  This)
static

Definition at line 707 of file terminal.c.

708 {
709  PFRONTEND FrontEnd = This->Context;
710  FrontEnd->Vtbl->ResizeTerminal(FrontEnd);
711 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117

◆ ConSrvTermSetActiveScreenBuffer()

static VOID NTAPI ConSrvTermSetActiveScreenBuffer ( IN OUT PTERMINAL  This)
static

Definition at line 714 of file terminal.c.

715 {
716  PFRONTEND FrontEnd = This->Context;
717  FrontEnd->Vtbl->SetActiveScreenBuffer(FrontEnd);
718 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117

◆ ConSrvTermSetCursorInfo()

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

Definition at line 686 of file terminal.c.

688 {
689  PFRONTEND FrontEnd = This->Context;
690  return FrontEnd->Vtbl->SetCursorInfo(FrontEnd, ScreenBuffer);
691 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117
HANDLE ScreenBuffer
Definition: notevil.c:37

◆ ConSrvTermSetPalette()

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

Definition at line 737 of file terminal.c.

740 {
741  PFRONTEND FrontEnd = This->Context;
742  return FrontEnd->Vtbl->SetPalette(FrontEnd, PaletteHandle, PaletteUsage);
743 }
static HPALETTE PaletteHandle
Definition: svga.c:215
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117

◆ ConSrvTermSetScreenInfo()

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

Definition at line 694 of file terminal.c.

698 {
699  PFRONTEND FrontEnd = This->Context;
700  return FrontEnd->Vtbl->SetScreenInfo(FrontEnd,
701  ScreenBuffer,
702  OldCursorX,
703  OldCursorY);
704 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117
HANDLE ScreenBuffer
Definition: notevil.c:37

◆ ConSrvTermShowMouseCursor()

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

Definition at line 746 of file terminal.c.

748 {
749  PFRONTEND FrontEnd = This->Context;
750  return FrontEnd->Vtbl->ShowMouseCursor(FrontEnd, Show);
751 }
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117

◆ ConSrvTermWriteStream()

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

Definition at line 644 of file terminal.c.

649 {
650  PFRONTEND FrontEnd = This->Context;
651  return ConioWriteConsole(FrontEnd,
652  Buff,
653  Buffer,
654  Length,
655  Attrib);
656 }
static NTSTATUS ConioWriteConsole(PFRONTEND FrontEnd, PTEXTMODE_SCREEN_BUFFER Buff, PWCHAR Buffer, DWORD Length, BOOL Attrib)
Definition: terminal.c:495
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 188 of file terminal.c.

189 {
190  if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
191  // return FrontEnd->Vtbl->UnloadFrontEnd(FrontEnd);
192  return FrontEnd->UnloadFrontEnd(FrontEnd);
193 }
#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 infos 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 }
#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
#define TRUE
Definition: types.h:120
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 STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1048
#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
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
static FRONTEND_VTBL GuiVtbl
Definition: guiterm.c:1147
#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:246
#define UOI_FLAGS
Definition: winuser.h:1073
WCHAR FaceName[LF_FACESIZE]
Definition: guisettings.h:18
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:925
return STATUS_SUCCESS
Definition: btrfs.c:2966
BOOL GuiConsoleReadUserSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:24
VOID GuiConsoleGetDefaultSettings(IN OUT PGUI_CONSOLE_INFO TermInfo)
Definition: guisettings.c:38

◆ 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 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
static VOID NTAPI GuiDeinitFrontEnd(IN OUT PFRONTEND This)
Definition: guiterm.c:594
return STATUS_SUCCESS
Definition: btrfs.c:2966

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:644
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:291
static VOID NTAPI ConSrvTermResizeTerminal(IN OUT PTERMINAL This)
Definition: terminal.c:707
static BOOL NTAPI ConSrvTermSetPalette(IN OUT PTERMINAL This, HPALETTE PaletteHandle, UINT PaletteUsage)
Definition: terminal.c:737
static VOID NTAPI ConSrvTermGetLargestConsoleWindowSize(IN OUT PTERMINAL This, PCOORD pSize)
Definition: terminal.c:729
static BOOL NTAPI ConSrvTermSetCursorInfo(IN OUT PTERMINAL This, PCONSOLE_SCREEN_BUFFER ScreenBuffer)
Definition: terminal.c:686
static BOOL NTAPI ConSrvTermSetScreenInfo(IN OUT PTERMINAL This, PCONSOLE_SCREEN_BUFFER ScreenBuffer, SHORT OldCursorX, SHORT OldCursorY)
Definition: terminal.c:694
static VOID NTAPI ConSrvTermDeinitTerminal(IN OUT PTERMINAL This)
Definition: terminal.c:280
static VOID NTAPI ConSrvTermDrawRegion(IN OUT PTERMINAL This, SMALL_RECT *Region)
Definition: terminal.c:678
static VOID NTAPI ConSrvTermReleaseScreenBuffer(IN OUT PTERMINAL This, IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
Definition: terminal.c:721
static VOID NTAPI ConSrvTermSetActiveScreenBuffer(IN OUT PTERMINAL This)
Definition: terminal.c:714
static INT NTAPI ConSrvTermShowMouseCursor(IN OUT PTERMINAL This, BOOL Show)
Definition: terminal.c:746
static NTSTATUS NTAPI ConSrvTermInitTerminal(IN OUT PTERMINAL This, IN PCONSOLE Console)
Definition: terminal.c:255

Definition at line 196 of file terminal.c.

Referenced by ConSrvInitTerminal().

◆ FrontEndLoad

FRONTEND_LOAD FrontEndLoad

Definition at line 136 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 135 of file terminal.c.

Referenced by ConSrvLoadFrontEnd().

◆ FrontEndUnload

FRONTEND_UNLOAD FrontEndUnload

Definition at line 137 of file terminal.c.