ReactOS  0.4.14-dev-1112-g2b067d6
console.c File Reference
#include <consrv.h>
#include <coninput.h>
#include "../../concfg/font.h"
#include <debug.h>
Include dependency graph for console.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define ConDrvLockConsoleListExclusive()   RtlAcquireResourceExclusive(&ListLock, TRUE)
 
#define ConDrvLockConsoleListShared()   RtlAcquireResourceShared(&ListLock, TRUE)
 
#define ConDrvUnlockConsoleList()   RtlReleaseResource(&ListLock)
 
#define CONSOLE_VALID_INPUT_MODES
 
#define CONSOLE_VALID_OUTPUT_MODES   ( ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT )
 

Functions

static NTSTATUS ConDrvInsertConsole (IN PCONSOLE Console)
 
static NTSTATUS RemoveConsole (IN PCONSOLE Console)
 
VOID NTAPI ConDrvPause (PCONSOLE Console)
 
VOID NTAPI ConDrvUnpause (PCONSOLE Console)
 
BOOLEAN NTAPI ConDrvValidateConsoleState (IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState)
 
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe (IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
 
VOID NTAPI ConDrvInitConsoleSupport (VOID)
 
VOID ResetTerminal (IN PCONSOLE Console)
 
NTSTATUS NTAPI ConDrvInitConsole (OUT PCONSOLE *NewConsole, IN PCONSOLE_INFO ConsoleInfo)
 
NTSTATUS NTAPI ConDrvAttachTerminal (IN PCONSOLE Console, IN PTERMINAL Terminal)
 
NTSTATUS NTAPI ConDrvDetachTerminal (IN PCONSOLE Console)
 
VOID NTAPI ConDrvDeleteConsole (IN PCONSOLE Console)
 
NTSTATUS NTAPI ConDrvGetConsoleMode (IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, OUT PULONG ConsoleMode)
 
NTSTATUS NTAPI ConDrvSetConsoleMode (IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, IN ULONG ConsoleMode)
 
NTSTATUS NTAPI ConDrvGetConsoleCP (IN PCONSOLE Console, OUT PUINT CodePage, IN BOOLEAN OutputCP)
 
NTSTATUS NTAPI ConDrvSetConsoleCP (IN PCONSOLE Console, IN UINT CodePage, IN BOOLEAN OutputCP)
 

Variables

static ULONG CurrentConsoleID = 0
 
static LIST_ENTRY ConDrvConsoleList
 
static RTL_RESOURCE ListLock
 

Macro Definition Documentation

◆ ConDrvLockConsoleListExclusive

#define ConDrvLockConsoleListExclusive ( )    RtlAcquireResourceExclusive(&ListLock, TRUE)

Definition at line 29 of file console.c.

◆ ConDrvLockConsoleListShared

#define ConDrvLockConsoleListShared ( )    RtlAcquireResourceShared(&ListLock, TRUE)

Definition at line 32 of file console.c.

◆ ConDrvUnlockConsoleList

#define ConDrvUnlockConsoleList ( )    RtlReleaseResource(&ListLock)

Definition at line 35 of file console.c.

◆ CONSOLE_VALID_INPUT_MODES

#define CONSOLE_VALID_INPUT_MODES
Value:
ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT | \
ENABLE_MOUSE_INPUT )
#define ENABLE_LINE_INPUT
Definition: wincon.h:79
#define ENABLE_WINDOW_INPUT
Definition: wincon.h:81
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:78

◆ CONSOLE_VALID_OUTPUT_MODES

#define CONSOLE_VALID_OUTPUT_MODES   ( ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT )

◆ NDEBUG

#define NDEBUG

Definition at line 18 of file console.c.

Function Documentation

◆ ConDrvAttachTerminal()

NTSTATUS NTAPI ConDrvAttachTerminal ( IN PCONSOLE  Console,
IN PTERMINAL  Terminal 
)

Definition at line 274 of file console.c.

276 {
278 
279  if (Console == NULL || Terminal == NULL)
281 
282  /* FIXME: Lock the console before ?? */
283 
284  /*
285  * Attach the terminal to the console. Use now the TermIFace of the console,
286  * and not the user-defined temporary Terminal pointer.
287  */
288  Console->TermIFace = *Terminal;
289  Console->TermIFace.Console = Console;
290 
291  /* Initialize the terminal AFTER having attached it to the console */
292  DPRINT("Finish initialization of terminal\n");
293  Status = Console->TermIFace.Vtbl->InitTerminal(&Console->TermIFace, Console);
294  if (!NT_SUCCESS(Status))
295  {
296  DPRINT1("Terminal initialization failed, Status = 0x%08lx\n", Status);
297 
298  /* We failed, detach the terminal from the console */
299  Terminal->Console = NULL; // For the caller
301  return Status;
302  }
303 
304  /* Copy buffer contents to screen */
305  // Terminal.Draw();
306 
307  DPRINT("Terminal initialization done\n");
308  return STATUS_SUCCESS;
309 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID ResetTerminal(IN PCONSOLE Console)
Definition: dummyterm.c:156
Status
Definition: gdiplustypes.h:24
CConsole Console
#define DPRINT1
Definition: precomp.h:8
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by ConSrvInitConsole().

◆ ConDrvDeleteConsole()

VOID NTAPI ConDrvDeleteConsole ( IN PCONSOLE  Console)

Definition at line 332 of file console.c.

333 {
334  DPRINT("ConDrvDeleteConsole(0x%p)\n", Console);
335 
336  /*
337  * Forbid validation of any console by other threads
338  * during the deletion of this console.
339  */
341 
342  /*
343  * If the console is already being destroyed, i.e. not running
344  * or finishing to be initialized, just return.
345  */
348  {
349  /* Unlock the console list and return */
351  return;
352  }
353 
354  /*
355  * We are about to be destroyed. Signal it to other people
356  * so that they can terminate what they are doing, and that
357  * they cannot longer validate the console.
358  */
359  Console->State = CONSOLE_TERMINATING;
360 
361  /*
362  * Allow other threads to finish their job: basically, unlock
363  * all other calls to EnterCriticalSection(&Console->Lock); by
364  * ConDrvValidateConsoleUnsafe functions so that they just see
365  * that we are not in CONSOLE_RUNNING state anymore, or unlock
366  * other concurrent calls to ConDrvDeleteConsole so that they
367  * can see that we are in fact already deleting the console.
368  */
371 
372  /* Deregister the terminal */
373  DPRINT("Deregister terminal\n");
375  DPRINT("Terminal deregistered\n");
376 
377  /***
378  * Check that the console is in terminating state before continuing
379  * (the cleanup code must not change the state of the console...
380  * ...unless to cancel console deletion ?).
381  ***/
382 
384 
386  {
388  return;
389  }
390 
391  /* We are now in destruction */
393 
394  /* We really delete the console. Reset the count to be sure. */
395  Console->ReferenceCount = 0;
396 
397  /* Remove the console from the list */
399 
400  /* Delete the last screen buffer */
401  ConDrvDeleteScreenBuffer(Console->ActiveBuffer);
402  Console->ActiveBuffer = NULL;
403  if (!IsListEmpty(&Console->BufferList))
404  {
405  /***ConDrvUnlockConsoleList();***/
406  ASSERTMSG("BUGBUGBUG!! screen buffer list not empty\n", FALSE);
407  }
408 
409  /* Deinitialize the input buffer */
411 
412  if (Console->UnpauseEvent) CloseHandle(Console->UnpauseEvent);
413 
414  DPRINT("ConDrvDeleteConsole - Unlocking\n");
416  DPRINT("ConDrvDeleteConsole - Destroying lock\n");
418  DPRINT("ConDrvDeleteConsole - Lock destroyed ; freeing console\n");
419 
421  DPRINT("ConDrvDeleteConsole - Console destroyed\n");
422 
423  /* Unlock the console list and return */
425 }
#define ConDrvUnlockConsoleList()
Definition: console.c:35
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:406
#define ConDrvLockConsoleListExclusive()
Definition: console.c:29
VOID NTAPI ConDrvDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:123
NTSTATUS NTAPI ConDrvDetachTerminal(IN PCONSOLE Console)
Definition: console.c:312
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
VOID NTAPI ConDrvDeinitInputBuffer(IN PCONSOLE Console)
Definition: coninput.c:221
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
static NTSTATUS RemoveConsole(IN PCONSOLE Console)
Definition: console.c:61
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by ConDrvInitConsole(), ConDrvReleaseConsole(), ConSrvDeleteConsole(), and ConSrvInitConsole().

◆ ConDrvDetachTerminal()

NTSTATUS NTAPI ConDrvDetachTerminal ( IN PCONSOLE  Console)

Definition at line 312 of file console.c.

313 {
314  if (Console == NULL) return STATUS_INVALID_PARAMETER;
315 
316  /* FIXME: Lock the console before ?? */
317 
318  /* Deinitialize the terminal BEFORE detaching it from the console */
319  Console->TermIFace.Vtbl->DeinitTerminal(&Console->TermIFace/*, Console*/);
320 
321  /*
322  * Detach the terminal from the console:
323  * reinitialize the terminal interface.
324  */
326 
327  DPRINT("Terminal unregistered\n");
328  return STATUS_SUCCESS;
329 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
VOID ResetTerminal(IN PCONSOLE Console)
Definition: dummyterm.c:156
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by ConDrvDeleteConsole().

◆ ConDrvGetConsoleCP()

NTSTATUS NTAPI ConDrvGetConsoleCP ( IN PCONSOLE  Console,
OUT PUINT  CodePage,
IN BOOLEAN  OutputCP 
)

Definition at line 518 of file console.c.

521 {
522  if (Console == NULL || CodePage == NULL)
524 
525  *CodePage = (OutputCP ? Console->OutputCodePage : Console->InputCodePage);
526 
527  return STATUS_SUCCESS;
528 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by CSR_API().

◆ ConDrvGetConsoleMode()

NTSTATUS NTAPI ConDrvGetConsoleMode ( IN PCONSOLE  Console,
IN PCONSOLE_IO_OBJECT  Object,
OUT PULONG  ConsoleMode 
)

Definition at line 431 of file console.c.

434 {
436 
437  if (Console == NULL || Object == NULL || ConsoleMode == NULL)
439 
440  /* Validity check */
441  ASSERT(Console == Object->Console);
442 
443  /*** FIXME: */ *ConsoleMode = 0; /***/
444 
445  if (INPUT_BUFFER == Object->Type)
446  {
448  *ConsoleMode = InputBuffer->Mode;
449  }
450  else if (TEXTMODE_BUFFER == Object->Type || GRAPHICS_BUFFER == Object->Type)
451  {
453  *ConsoleMode = Buffer->Mode;
454  }
455  else
456  {
458  }
459 
460  return Status;
461 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
CHAR InputBuffer[80]
Definition: conmgr.c:33
struct _CONSOLE_INPUT_BUFFER * PCONSOLE_INPUT_BUFFER
struct _CONSOLE_SCREEN_BUFFER * PCONSOLE_SCREEN_BUFFER
Definition: conio.h:70
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by CSR_API().

◆ ConDrvInitConsole()

NTSTATUS NTAPI ConDrvInitConsole ( OUT PCONSOLE NewConsole,
IN PCONSOLE_INFO  ConsoleInfo 
)

Definition at line 163 of file console.c.

165 {
167  // CONSOLE_INFO CapturedConsoleInfo;
170  PCONSOLE_SCREEN_BUFFER NewBuffer;
171 
172  if (NewConsole == NULL || ConsoleInfo == NULL)
174 
175  *NewConsole = NULL;
176 
177  /*
178  * Allocate a new console
179  */
181  if (NULL == Console)
182  {
183  DPRINT1("Not enough memory for console creation.\n");
184  return STATUS_NO_MEMORY;
185  }
186 
187  /*
188  * Set and fix the screen buffer size if needed.
189  * The rule is: ScreenBufferSize >= ConsoleSize
190  */
191  if (ConsoleInfo->ScreenBufferSize.X == 0) ConsoleInfo->ScreenBufferSize.X = 1;
192  if (ConsoleInfo->ScreenBufferSize.Y == 0) ConsoleInfo->ScreenBufferSize.Y = 1;
193  if (ConsoleInfo->ScreenBufferSize.X < ConsoleInfo->ConsoleSize.X)
194  ConsoleInfo->ScreenBufferSize.X = ConsoleInfo->ConsoleSize.X;
195  if (ConsoleInfo->ScreenBufferSize.Y < ConsoleInfo->ConsoleSize.Y)
196  ConsoleInfo->ScreenBufferSize.Y = ConsoleInfo->ConsoleSize.Y;
197 
198  /*
199  * Initialize the console
200  */
201  Console->State = CONSOLE_INITIALIZING;
202  Console->ReferenceCount = 0;
204 
205  /* Initialize the terminal interface */
207 
208  Console->ConsoleSize = ConsoleInfo->ConsoleSize;
209  Console->FixedSize = FALSE; // Value by default; is reseted by the terminals if needed.
210 
211  /* Initialize the input buffer */
212  Status = ConDrvInitInputBuffer(Console, 0 /* ConsoleInfo->InputBufferSize */);
213  if (!NT_SUCCESS(Status))
214  {
215  DPRINT1("ConDrvInitInputBuffer: failed, Status = 0x%08lx\n", Status);
218  return Status;
219  }
220 
221  /* Set-up the code page */
222  if (IsValidCodePage(ConsoleInfo->CodePage))
223  Console->InputCodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
224 
225  Console->IsCJK = IsCJKCodePage(Console->OutputCodePage);
226 
227  /* Initialize a new text-mode screen buffer with default settings */
228  ScreenBufferInfo.ScreenBufferSize = ConsoleInfo->ScreenBufferSize;
229  ScreenBufferInfo.ViewSize = ConsoleInfo->ConsoleSize;
230  ScreenBufferInfo.ScreenAttrib = ConsoleInfo->ScreenAttrib;
231  ScreenBufferInfo.PopupAttrib = ConsoleInfo->PopupAttrib;
232  ScreenBufferInfo.CursorSize = ConsoleInfo->CursorSize;
233  ScreenBufferInfo.IsCursorVisible = TRUE;
234 
235  InitializeListHead(&Console->BufferList);
236  Status = ConDrvCreateScreenBuffer(&NewBuffer,
237  Console,
238  NULL,
241  if (!NT_SUCCESS(Status))
242  {
243  DPRINT1("ConDrvCreateScreenBuffer: failed, Status = 0x%08lx\n", Status);
247  return Status;
248  }
249  /* Make the new screen buffer active */
250  Console->ActiveBuffer = NewBuffer;
251  Console->UnpauseEvent = NULL;
252 
253  DPRINT("Console initialized\n");
254 
255  /* All went right, so add the console to the list */
257  if (!NT_SUCCESS(Status))
258  {
259  /* Fail */
261  return Status;
262  }
263 
264  /* The initialization is finished */
265  DPRINT("Change state\n");
266  Console->State = CONSOLE_RUNNING;
267 
268  /* Return the newly created console to the caller and a success code too */
269  *NewConsole = Console;
270  return STATUS_SUCCESS;
271 }
#define TRUE
Definition: types.h:120
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
NTSTATUS ConDrvCreateScreenBuffer(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN HANDLE ProcessHandle OPTIONAL, IN ULONG BufferType, IN PVOID ScreenBufferInfo)
Definition: conoutput.c:79
#define IsCJKCodePage(CodePage)
Definition: font.h:23
VOID NTAPI ConDrvDeleteConsole(IN PCONSOLE Console)
Definition: console.c:332
VOID NTAPI ConDrvDeinitInputBuffer(IN PCONSOLE Console)
Definition: coninput.c:221
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
static NTSTATUS ConDrvInsertConsole(IN PCONSOLE Console)
Definition: console.c:40
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID ResetTerminal(IN PCONSOLE Console)
Definition: dummyterm.c:156
Status
Definition: gdiplustypes.h:24
BOOL WINAPI IsValidCodePage(UINT CodePage)
Definition: nls.c:1479
NTSTATUS NTAPI ConDrvInitInputBuffer(IN PCONSOLE Console, IN ULONG InputBufferSize)
Definition: coninput.c:192
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:62
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
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
CConsole Console
#define DPRINT1
Definition: precomp.h:8
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by ConSrvInitConsole().

◆ ConDrvInitConsoleSupport()

VOID NTAPI ConDrvInitConsoleSupport ( VOID  )

Definition at line 150 of file console.c.

151 {
152  DPRINT("CONSRV: ConDrvInitConsoleSupport()\n");
153 
154  /* Initialize the console list and its lock */
157 }
static RTL_RESOURCE ListLock
Definition: console.c:27
void DPRINT(...)
Definition: polytest.cpp:61
NTSYSAPI VOID NTAPI RtlInitializeResource(_In_ PRTL_RESOURCE Resource)
static LIST_ENTRY ConDrvConsoleList
Definition: console.c:26
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944

Referenced by CSR_SERVER_DLL_INIT().

◆ ConDrvInsertConsole()

static NTSTATUS ConDrvInsertConsole ( IN PCONSOLE  Console)
static

Definition at line 40 of file console.c.

41 {
42  ASSERT(Console);
43 
44  /* All went right, so add the console to the list */
46 
47  DPRINT("Insert in the list\n");
49 
50  // FIXME: Move this code to the caller function!!
51  /* Get a new console ID */
54 
55  /* Unlock the console list and return success */
57  return STATUS_SUCCESS;
58 }
#define ConDrvUnlockConsoleList()
Definition: console.c:35
#define ConDrvLockConsoleListExclusive()
Definition: console.c:29
long __cdecl _InterlockedExchange(_Interlocked_operand_ long volatile *_Target, long _Value)
#define InsertTailList(ListHead, Entry)
long __cdecl _InterlockedIncrement(_Interlocked_operand_ long volatile *_Addend)
void DPRINT(...)
Definition: polytest.cpp:61
static LIST_ENTRY ConDrvConsoleList
Definition: console.c:26
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static ULONG CurrentConsoleID
Definition: console.c:23
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2938
signed int * PLONG
Definition: retypes.h:5

Referenced by ConDrvInitConsole().

◆ ConDrvPause()

VOID NTAPI ConDrvPause ( PCONSOLE  Console)

Definition at line 80 of file console.c.

81 {
82  /* In case we already have a pause event, just exit... */
83  if (Console->UnpauseEvent) return;
84 
85  /* ... otherwise create it */
86  NtCreateEvent(&Console->UnpauseEvent, EVENT_ALL_ACCESS,
88 }
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:100
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
smooth NULL
Definition: ftsmooth.c:416
CConsole Console

Referenced by ConioPause().

◆ ConDrvSetConsoleCP()

NTSTATUS NTAPI ConDrvSetConsoleCP ( IN PCONSOLE  Console,
IN UINT  CodePage,
IN BOOLEAN  OutputCP 
)

Definition at line 531 of file console.c.

534 {
535  if (Console == NULL || !IsValidCodePage(CodePage))
537 
538  if (OutputCP)
539  {
540  Console->OutputCodePage = CodePage;
541  Console->IsCJK = IsCJKCodePage(CodePage);
542  }
543  else
544  {
545  Console->InputCodePage = CodePage;
546  }
547 
548  return STATUS_SUCCESS;
549 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define IsCJKCodePage(CodePage)
Definition: font.h:23
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI IsValidCodePage(UINT CodePage)
Definition: nls.c:1479
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by CSR_API().

◆ ConDrvSetConsoleMode()

NTSTATUS NTAPI ConDrvSetConsoleMode ( IN PCONSOLE  Console,
IN PCONSOLE_IO_OBJECT  Object,
IN ULONG  ConsoleMode 
)

Definition at line 464 of file console.c.

467 {
468 #define CONSOLE_VALID_INPUT_MODES ( ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | \
469  ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT | \
470  ENABLE_MOUSE_INPUT )
471 #define CONSOLE_VALID_OUTPUT_MODES ( ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT )
472 
474 
475  if (Console == NULL || Object == NULL)
477 
478  /* Validity check */
479  ASSERT(Console == Object->Console);
480 
481  if (INPUT_BUFFER == Object->Type)
482  {
484 
485  /* Only the presence of valid mode flags is allowed */
486  if (ConsoleMode & ~CONSOLE_VALID_INPUT_MODES)
487  {
489  }
490  else
491  {
492  InputBuffer->Mode = (ConsoleMode & CONSOLE_VALID_INPUT_MODES);
493  }
494  }
495  else if (TEXTMODE_BUFFER == Object->Type || GRAPHICS_BUFFER == Object->Type)
496  {
498 
499  /* Only the presence of valid mode flags is allowed */
500  if (ConsoleMode & ~CONSOLE_VALID_OUTPUT_MODES)
501  {
503  }
504  else
505  {
506  Buffer->Mode = (ConsoleMode & CONSOLE_VALID_OUTPUT_MODES);
507  }
508  }
509  else
510  {
512  }
513 
514  return Status;
515 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define TEXTMODE_BUFFER
Definition: pccons.c:21
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
CHAR InputBuffer[80]
Definition: conmgr.c:33
struct _CONSOLE_INPUT_BUFFER * PCONSOLE_INPUT_BUFFER
struct _CONSOLE_SCREEN_BUFFER * PCONSOLE_SCREEN_BUFFER
Definition: conio.h:70
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define CONSOLE_VALID_INPUT_MODES
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
CConsole Console
#define CONSOLE_VALID_OUTPUT_MODES
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by CSR_API().

◆ ConDrvUnpause()

VOID NTAPI ConDrvUnpause ( PCONSOLE  Console)

Definition at line 91 of file console.c.

92 {
93  /* In case we already freed the event, just exit... */
94  if (!Console->UnpauseEvent) return;
95 
96  /* ... otherwise set and free it */
97  NtSetEvent(Console->UnpauseEvent, NULL);
98  NtClose(Console->UnpauseEvent);
99  Console->UnpauseEvent = NULL;
100 }
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:458
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
CConsole Console

Referenced by ConioUnpause().

◆ ConDrvValidateConsoleState()

BOOLEAN NTAPI ConDrvValidateConsoleState ( IN PCONSOLE  Console,
IN CONSOLE_STATE  ExpectedState 
)

Definition at line 108 of file console.c.

110 {
111  // if (!Console) return FALSE;
112 
113  /* The console must be locked */
114  // ASSERT(Console_locked);
115 
116  return (Console->State == ExpectedState);
117 }
CConsole Console

Referenced by ConDrvConsoleProcessCtrlEvent(), ConDrvValidateConsoleUnsafe(), ConSrvConsoleProcessCtrlEvent(), and ConSrvSetConsoleProcessFocus().

◆ ConDrvValidateConsoleUnsafe()

BOOLEAN NTAPI ConDrvValidateConsoleUnsafe ( IN PCONSOLE  Console,
IN CONSOLE_STATE  ExpectedState,
IN BOOLEAN  LockConsole 
)

Definition at line 120 of file console.c.

123 {
124  if (!Console) return FALSE;
125 
126  /*
127  * Lock the console to forbid possible console's state changes
128  * (which must be done when the console is already locked).
129  * If we don't want to lock it, it's because the lock is already
130  * held. So there must be no problems.
131  */
132  if (LockConsole) EnterCriticalSection(&Console->Lock);
133 
134  // ASSERT(Console_locked);
135 
136  /* Check whether the console's state is what we expect */
137  if (!ConDrvValidateConsoleState(Console, ExpectedState))
138  {
139  if (LockConsole) LeaveCriticalSection(&Console->Lock);
140  return FALSE;
141  }
142 
143  return TRUE;
144 }
BOOLEAN NTAPI ConDrvValidateConsoleState(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState)
Definition: console.c:108
#define TRUE
Definition: types.h:120
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
CConsole Console
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by ConDrvDeleteConsole(), ConDrvValidateConsole(), ConSrvGetObject(), ConSrvValidateConsole(), GuiApplyUserSettings(), GuiConsoleGetMinMaxInfo(), GuiConsoleHandleClose(), GuiConsoleHandleKey(), GuiConsoleHandleMouse(), GuiConsoleHandlePaint(), GuiConsoleHandleScroll(), GuiConsoleHandleSysMenuCommand(), GuiConsoleHandleTimer(), GuiConsoleResize(), GuiConsoleShowConsoleProperties(), GuiConsoleSwitchFullScreen(), GuiConsoleWndProc(), GuiPaintGraphicsBuffer(), GuiPaintTextModeBuffer(), OnClose(), OnFocus(), OnGetMinMaxInfo(), OnKey(), OnMouse(), OnScroll(), OnSize(), OnTimer(), and SendMenuEvent().

◆ RemoveConsole()

static NTSTATUS RemoveConsole ( IN PCONSOLE  Console)
static

Definition at line 61 of file console.c.

62 {
63  // ASSERT(Console);
64  if (!Console) return STATUS_INVALID_PARAMETER;
65 
66  /* Remove the console from the list */
68 
69  RemoveEntryList(&Console->ListEntry);
70 
71  /* Unlock the console list and return success */
73  return STATUS_SUCCESS;
74 }
#define ConDrvUnlockConsoleList()
Definition: console.c:35
#define ConDrvLockConsoleListExclusive()
Definition: console.c:29
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by ConDrvDeleteConsole().

◆ ResetTerminal()

VOID ResetTerminal ( IN PCONSOLE  Console)

Definition at line 156 of file dummyterm.c.

157 {
158  if (!Console) return;
159 
160  /* Reinitialize the terminal interface */
161  RtlZeroMemory(&Console->TermIFace, sizeof(Console->TermIFace));
162  Console->TermIFace.Vtbl = &DummyVtbl;
163 }
static TERMINAL_VTBL DummyVtbl
Definition: dummyterm.c:136
CConsole Console
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

Referenced by ConDrvAttachTerminal(), ConDrvDetachTerminal(), and ConDrvInitConsole().

Variable Documentation

◆ ConDrvConsoleList

LIST_ENTRY ConDrvConsoleList
static

Definition at line 26 of file console.c.

Referenced by ConDrvInitConsoleSupport(), and ConDrvInsertConsole().

◆ CurrentConsoleID

ULONG CurrentConsoleID = 0
static

Definition at line 23 of file console.c.

Referenced by ConDrvInsertConsole().

◆ ListLock

RTL_RESOURCE ListLock
static

Definition at line 27 of file console.c.

Referenced by ConDrvInitConsoleSupport().