ReactOS  0.4.14-dev-593-g1793dcc
terminal.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Console Server DLL
4  * FILE: win32ss/user/winsrv/consrv/frontends/terminal.c
5  * PURPOSE: ConSrv terminal.
6  * PROGRAMMERS: Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include <consrv.h>
12 
13 // #include "frontends/gui/guiterm.h"
14 #ifdef TUITERM_COMPILE
15 #include "frontends/tui/tuiterm.h"
16 #endif
17 
18 #define NDEBUG
19 #include <debug.h>
20 
21 
22 
23 
24 
25 /********** HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK ************/
26 
27 /* GLOBALS ********************************************************************/
28 
29 /*
30  * From MSDN:
31  * "The lpMultiByteStr and lpWideCharStr pointers must not be the same.
32  * If they are the same, the function fails, and GetLastError returns
33  * ERROR_INVALID_PARAMETER."
34  */
35 #define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar) \
36  ASSERT((ULONG_PTR)dChar != (ULONG_PTR)sWChar); \
37  WideCharToMultiByte((Console)->InputCodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL)
38 
39 #define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar) \
40  ASSERT((ULONG_PTR)dWChar != (ULONG_PTR)sChar); \
41  MultiByteToWideChar((Console)->InputCodePage, 0, (sChar), 1, (dWChar), 1)
42 
43 /* PRIVATE FUNCTIONS **********************************************************/
44 
45 #if 0
46 
47 static VOID
49 {
50  if (InputEvent->EventType == KEY_EVENT)
51  {
52  WCHAR UnicodeChar = InputEvent->Event.KeyEvent.uChar.UnicodeChar;
53  InputEvent->Event.KeyEvent.uChar.UnicodeChar = 0;
55  &InputEvent->Event.KeyEvent.uChar.AsciiChar,
56  &UnicodeChar);
57  }
58 }
59 
60 static VOID
62 {
63  if (InputEvent->EventType == KEY_EVENT)
64  {
65  CHAR AsciiChar = InputEvent->Event.KeyEvent.uChar.AsciiChar;
66  InputEvent->Event.KeyEvent.uChar.AsciiChar = 0;
68  &InputEvent->Event.KeyEvent.uChar.UnicodeChar,
69  &AsciiChar);
70  }
71 }
72 
73 #endif
74 
75 /********** HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK ************/
76 
77 
78 
79 
80 
81 
82 
83 
84 /* CONSRV TERMINAL FRONTENDS INTERFACE ****************************************/
85 
86 /***************/
87 #ifdef TUITERM_COMPILE
89 TuiLoadFrontEnd(IN OUT PFRONTEND FrontEnd,
91  IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo,
92  IN HANDLE ConsoleLeaderProcessHandle);
94 TuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd);
95 #endif
96 
100  IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo,
101  IN HANDLE ConsoleLeaderProcessHandle);
104 /***************/
105 
106 typedef
109  IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo,
110  IN HANDLE ConsoleLeaderProcessHandle);
111 
112 typedef
114 
115 /*
116  * If we are not in GUI-mode, start the text-mode terminal emulator.
117  * If we fail, try to start the GUI-mode terminal emulator.
118  *
119  * Try to open the GUI-mode terminal emulator. Two cases are possible:
120  * - We are in GUI-mode, therefore GuiMode == TRUE, the previous test-case
121  * failed and we start GUI-mode terminal emulator.
122  * - We are in text-mode, therefore GuiMode == FALSE, the previous test-case
123  * succeeded BUT we failed at starting text-mode terminal emulator.
124  * Then GuiMode was switched to TRUE in order to try to open the GUI-mode
125  * terminal emulator (Win32k will automatically switch to graphical mode,
126  * therefore no additional code is needed).
127  */
128 
129 /*
130  * NOTE: Each entry of the table should be retrieved when loading a front-end
131  * (examples of the CSR servers which register some data for CSRSS).
132  */
133 static struct
134 {
139 {
140 #ifdef TUITERM_COMPILE
141  {"TUI", TuiLoadFrontEnd, TuiUnloadFrontEnd},
142 #endif
144 
145 // {"Not found", 0, NULL}
146 };
147 
148 static NTSTATUS
151  IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo,
152  IN HANDLE ConsoleLeaderProcessHandle)
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 }
186 
187 static NTSTATUS
189 {
190  if (FrontEnd == NULL) return STATUS_INVALID_PARAMETER;
191  // return FrontEnd->Vtbl->UnloadFrontEnd(FrontEnd);
192  return FrontEnd->UnloadFrontEnd(FrontEnd);
193 }
194 
195 // See after...
197 
201  IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo,
202  IN HANDLE ConsoleLeaderProcessHandle)
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 }
230 
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 }
250 
251 
252 /* CONSRV TERMINAL INTERFACE **************************************************/
253 
254 static NTSTATUS NTAPI
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 }
278 
279 static VOID NTAPI
281 {
282  PFRONTEND FrontEnd = This->Context;
283  FrontEnd->Vtbl->DeinitFrontEnd(FrontEnd);
284 }
285 
286 
287 
288 /************ Line discipline ***************/
289 
290 static NTSTATUS NTAPI
292  IN BOOLEAN Unicode,
294  OUT PVOID Buffer,
295  IN OUT PCONSOLE_READCONSOLE_CONTROL ReadControl,
297  IN ULONG NumCharsToRead,
298  OUT PULONG NumCharsRead OPTIONAL)
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 }
459 
460 
461 
462 
463 /* GLOBALS ********************************************************************/
464 
465 #define TAB_WIDTH 8
466 
467 // See condrv/text.c
468 /*static*/ VOID
470 
471 static VOID
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 }
493 
494 static NTSTATUS
497  PWCHAR Buffer,
498  DWORD Length,
499  BOOL Attrib)
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 }
640 
641 
642 
643 static NTSTATUS NTAPI
646  PWCHAR Buffer,
647  DWORD Length,
648  BOOL Attrib)
649 {
650  PFRONTEND FrontEnd = This->Context;
651  return ConioWriteConsole(FrontEnd,
652  Buff,
653  Buffer,
654  Length,
655  Attrib);
656 }
657 
658 /************ Line discipline ***************/
659 
660 
661 
662 VOID
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 }
676 
677 static VOID NTAPI
680 {
681  PFRONTEND FrontEnd = This->Context;
682  FrontEnd->Vtbl->DrawRegion(FrontEnd, Region);
683 }
684 
685 static BOOL NTAPI
688 {
689  PFRONTEND FrontEnd = This->Context;
690  return FrontEnd->Vtbl->SetCursorInfo(FrontEnd, ScreenBuffer);
691 }
692 
693 static BOOL NTAPI
696  SHORT OldCursorX,
697  SHORT OldCursorY)
698 {
699  PFRONTEND FrontEnd = This->Context;
700  return FrontEnd->Vtbl->SetScreenInfo(FrontEnd,
701  ScreenBuffer,
702  OldCursorX,
703  OldCursorY);
704 }
705 
706 static VOID NTAPI
708 {
709  PFRONTEND FrontEnd = This->Context;
710  FrontEnd->Vtbl->ResizeTerminal(FrontEnd);
711 }
712 
713 static VOID NTAPI
715 {
716  PFRONTEND FrontEnd = This->Context;
717  FrontEnd->Vtbl->SetActiveScreenBuffer(FrontEnd);
718 }
719 
720 static VOID NTAPI
723 {
724  PFRONTEND FrontEnd = This->Context;
725  FrontEnd->Vtbl->ReleaseScreenBuffer(FrontEnd, ScreenBuffer);
726 }
727 
728 static VOID NTAPI
730  PCOORD pSize)
731 {
732  PFRONTEND FrontEnd = This->Context;
733  FrontEnd->Vtbl->GetLargestConsoleWindowSize(FrontEnd, pSize);
734 }
735 
736 static BOOL NTAPI
738  HPALETTE PaletteHandle,
739  UINT PaletteUsage)
740 {
741  PFRONTEND FrontEnd = This->Context;
742  return FrontEnd->Vtbl->SetPalette(FrontEnd, PaletteHandle, PaletteUsage);
743 }
744 
745 static INT NTAPI
747  BOOL Show)
748 {
749  PFRONTEND FrontEnd = This->Context;
750  return FrontEnd->Vtbl->ShowMouseCursor(FrontEnd, Show);
751 }
752 
754 {
757 
760 
770 };
771 
772 #if 0
773 VOID
775 {
776  if (!Console) return;
777 
778  /* Reinitialize the frontend interface */
779  RtlZeroMemory(&Console->FrontEndIFace, sizeof(Console->FrontEndIFace));
780  Console->FrontEndIFace.Vtbl = &ConSrvTermVtbl;
781 }
782 #endif
783 
784 /* EOF */
signed char * PCHAR
Definition: retypes.h:7
#define IN
Definition: typedefs.h:38
#define max(a, b)
Definition: svc.c:63
VOID ClearLineBuffer(PTEXTMODE_SCREEN_BUFFER Buff)
Definition: text.c:146
#define TRUE
Definition: types.h:120
WCHAR UnicodeChar
Definition: wincon.h:230
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PCHAR_INFO ConioCoordToPointer(PTEXTMODE_SCREEN_BUFFER Buff, ULONG X, ULONG Y)
Definition: text.c:140
char CHAR
Definition: xmlstorage.h:175
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
VOID ConioDrawConsole(PCONSRV_CONSOLE Console)
Definition: terminal.c:663
LONG NTSTATUS
Definition: precomp.h:26
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
#define TermDrawRegion(Console, Region)
Definition: term.h:22
Definition: arc.h:84
static NTSTATUS NTAPI ConSrvTermWriteStream(IN OUT PTERMINAL This, PTEXTMODE_SCREEN_BUFFER Buff, PWCHAR Buffer, DWORD Length, BOOL Attrib)
Definition: terminal.c:644
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
union _KEY_EVENT_RECORD::@3176 uChar
static VOID ConioInputEventToUnicode(PCONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:68
uint16_t * PWCHAR
Definition: typedefs.h:54
static HPALETTE PaletteHandle
Definition: svga.c:215
_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
union _INPUT_RECORD::@3177 Event
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
int32_t INT
Definition: typedefs.h:56
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
NTSTATUS NTAPI ConSrvInitTerminal(IN OUT PTERMINAL Terminal, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
Definition: terminal.c:199
CHAR InputBuffer[80]
Definition: conmgr.c:33
struct _CONSRV_CONSOLE * Console
Definition: conio_winsrv.h:120
static VOID NTAPI ConSrvTermResizeTerminal(IN OUT PTERMINAL This)
Definition: terminal.c:707
NTSTATUS NTAPI GuiUnloadFrontEnd(IN OUT PFRONTEND FrontEnd)
Definition: guiterm.c:1307
static NTSTATUS ConioWriteConsole(PFRONTEND FrontEnd, PTEXTMODE_SCREEN_BUFFER Buff, PWCHAR Buffer, DWORD Length, BOOL Attrib)
Definition: terminal.c:495
static VOID ConioInputEventToAnsi(PCONSOLE Console, PINPUT_RECORD InputEvent)
Definition: coninput.c:55
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
NTSTATUS(NTAPI * FRONTEND_LOAD)(IN OUT PFRONTEND FrontEnd, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
Definition: terminal.c:107
static BOOL NTAPI ConSrvTermSetPalette(IN OUT PTERMINAL This, HPALETTE PaletteHandle, UINT PaletteUsage)
Definition: terminal.c:737
#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
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
static NTSTATUS ConSrvUnloadFrontEnd(IN PFRONTEND FrontEnd)
Definition: terminal.c:188
unsigned int BOOL
Definition: ntddk_ex.h:94
short SHORT
Definition: pedump.c:59
#define KEY_EVENT
Definition: wincon.h:122
static VOID NTAPI ConSrvTermGetLargestConsoleWindowSize(IN OUT PTERMINAL This, PCOORD pSize)
Definition: terminal.c:729
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
PVOID Context
Definition: conio_winsrv.h:121
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
void DPRINT(...)
Definition: polytest.cpp:61
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
ULONG X
Definition: bl.h:1340
static BOOL NTAPI ConSrvTermSetCursorInfo(IN OUT PTERMINAL This, PCONSOLE_SCREEN_BUFFER ScreenBuffer)
Definition: terminal.c:686
#define TAB_WIDTH
Definition: terminal.c:465
NTSTATUS(NTAPI * FRONTEND_UNLOAD)(IN OUT PFRONTEND FrontEnd)
Definition: terminal.c:113
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
NTSTATUS NTAPI ConSrvDeinitTerminal(IN OUT PTERMINAL Terminal)
Definition: terminal.c:232
KEY_EVENT_RECORD KeyEvent
Definition: wincon.h:263
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL NTAPI ConSrvTermSetScreenInfo(IN OUT PTERMINAL This, PCONSOLE_SCREEN_BUFFER ScreenBuffer, SHORT OldCursorX, SHORT OldCursorY)
Definition: terminal.c:694
#define ENABLE_LINE_INPUT
Definition: wincon.h:76
PFRONTEND_VTBL Vtbl
Definition: conio_winsrv.h:117
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
CHAR FrontEndName[80]
Definition: terminal.c:135
#define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar)
Definition: terminal.c:35
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static TERMINAL_VTBL ConSrvTermVtbl
Definition: terminal.c:196
FRONTEND_UNLOAD FrontEndUnload
Definition: terminal.c:137
static const WCHAR L[]
Definition: oid.c:1250
static VOID NTAPI ConSrvTermDeinitTerminal(IN OUT PTERMINAL This)
Definition: terminal.c:280
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
#define NTSTATUS
Definition: precomp.h:20
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: typedefs.h:117
Definition: bl.h:1338
#define ConioInitRect(Rect, top, left, bottom, right)
Definition: rect.h:20
Status
Definition: gdiplustypes.h:24
#define ENABLE_PROCESSED_OUTPUT
Definition: blue.h:44
static struct @4161 FrontEndLoadingMethods[]
static VOID ConioNextLine(PTEXTMODE_SCREEN_BUFFER Buff, PSMALL_RECT UpdateRect, PUINT ScrolledLines)
Definition: terminal.c:472
static VOID NTAPI ConSrvTermDrawRegion(IN OUT PTERMINAL This, SMALL_RECT *Region)
Definition: terminal.c:678
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
VOID ResetFrontEnd(IN PCONSOLE Console)
unsigned int * PULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
static VOID NTAPI ConSrvTermReleaseScreenBuffer(IN OUT PTERMINAL This, IN PCONSOLE_SCREEN_BUFFER ScreenBuffer)
Definition: terminal.c:721
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
BOOL WINAPI DECLSPEC_HOTPATCH ResetEvent(IN HANDLE hEvent)
Definition: synch.c:714
static VOID NTAPI ConSrvTermSetActiveScreenBuffer(IN OUT PTERMINAL This)
Definition: terminal.c:714
CConsole Console
WORD EventType
Definition: wincon.h:261
#define DPRINT1
Definition: precomp.h:8
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
HANDLE ScreenBuffer
Definition: notevil.c:37
#define OUT
Definition: typedefs.h:39
static INT NTAPI ConSrvTermShowMouseCursor(IN OUT PTERMINAL This, BOOL Show)
Definition: terminal.c:746
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static int UpdateRect(TreeListData *pData, unsigned uItem, unsigned uSub)
Definition: treelist.c:1529
FRONTEND_LOAD FrontEndLoad
Definition: terminal.c:136
#define ConioIsRectEmpty(Rect)
Definition: rect.h:28
#define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar)
Definition: terminal.c:39
return STATUS_SUCCESS
Definition: btrfs.c:2938
ULONG Y
Definition: bl.h:1341
unsigned int * PUINT
Definition: ndis.h:50
static NTSTATUS NTAPI ConSrvTermInitTerminal(IN OUT PTERMINAL This, IN PCONSOLE Console)
Definition: terminal.c:255
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68