ReactOS  0.4.13-dev-464-g6b95727
console.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Console Driver DLL
4  * FILE: win32ss/user/winsrv/consrv_new/condrv/console.c
5  * PURPOSE: Console Management Functions
6  * PROGRAMMERS: Gé van Geldorp
7  * Jeffrey Morlan
8  * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
9  */
10 
11 /* INCLUDES *******************************************************************/
12 
13 #include "consrv.h"
14 #include "include/conio.h"
15 #include "include/conio2.h"
16 #include "handle.h"
17 #include "procinit.h"
18 #include "alias.h"
19 #include "coninput.h"
20 #include "conoutput.h"
21 #include "lineinput.h"
22 #include "include/settings.h"
23 
24 #include "include/console.h"
25 #include "console.h"
26 #include "resource.h"
27 
28 #define NDEBUG
29 #include <debug.h>
30 
31 // FIXME: Add this prototype to winternl.h / rtlfuncs.h / ...
33 
34 
35 /* GLOBALS ********************************************************************/
36 
38 static PCONSOLE* ConsoleList; /* The list of all the allocated consoles */
40 
41 #define ConDrvLockConsoleListExclusive() \
42  RtlAcquireResourceExclusive(&ListLock, TRUE)
43 
44 #define ConDrvLockConsoleListShared() \
45  RtlAcquireResourceShared(&ListLock, TRUE)
46 
47 #define ConDrvUnlockConsoleList() \
48  RtlReleaseResource(&ListLock)
49 
50 // Adapted from reactos/lib/rtl/unicode.c, RtlCreateUnicodeString line 2180
51 static BOOLEAN
54 {
55  SIZE_T Size = (wcslen(Source) + 1) * sizeof(WCHAR);
56  if (Size > MAXUSHORT) return FALSE;
57 
58  UniDest->Buffer = ConsoleAllocHeap(HEAP_ZERO_MEMORY, Size);
59  if (UniDest->Buffer == NULL) return FALSE;
60 
61  RtlCopyMemory(UniDest->Buffer, Source, Size);
62  UniDest->MaximumLength = (USHORT)Size;
63  UniDest->Length = (USHORT)Size - sizeof(WCHAR);
64 
65  return TRUE;
66 }
67 
68 // Adapted from reactos/lib/rtl/unicode.c, RtlFreeUnicodeString line 431
69 static VOID
71 {
72  if (UnicodeString->Buffer)
73  {
76  }
77 }
78 
79 
80 static NTSTATUS
83 {
84 #define CONSOLE_HANDLES_INCREMENT 2 * 3
85 
87  ULONG i = 0;
88  PCONSOLE* Block;
89 
90  ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
91  (ConsoleList != NULL && ConsoleListSize != 0) );
92 
93  /* All went right, so add the console to the list */
95  DPRINT1("Insert in the list\n");
96 
97  if (ConsoleList)
98  {
99  for (i = 0; i < ConsoleListSize; i++)
100  {
101  if (ConsoleList[i] == NULL) break;
102  }
103  }
104 
105  if (i >= ConsoleListSize)
106  {
107  DPRINT1("Creation of a new handles table\n");
108  /* Allocate a new handles table */
110  (ConsoleListSize +
112  if (Block == NULL)
113  {
115  goto Quit;
116  }
117 
118  /* If we previously had a handles table, free it and use the new one */
119  if (ConsoleList)
120  {
121  /* Copy the handles from the old table to the new one */
122  RtlCopyMemory(Block,
123  ConsoleList,
124  ConsoleListSize * sizeof(PCONSOLE));
126  }
127  ConsoleList = Block;
129  }
130 
131  ConsoleList[i] = Console;
132  *Handle = ULongToHandle((i << 2) | 0x3);
133 
134 Quit:
135  /* Unlock the console list and return status */
137  return Status;
138 }
139 
140 /* Unused */
141 #if 0
142 static NTSTATUS
143 RemoveConsoleByHandle(IN HANDLE Handle)
144 {
148 
149  ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
150  (ConsoleList != NULL && ConsoleListSize != 0) );
151 
152  /* Remove the console from the list */
154 
155  if (Index >= ConsoleListSize ||
156  (Console = ConsoleList[Index]) == NULL)
157  {
159  goto Quit;
160  }
161 
163 
164 Quit:
165  /* Unlock the console list and return status */
167  return Status;
168 }
169 #endif
170 
171 static NTSTATUS
173 {
174  ULONG i = 0;
175 
176  if (!Console) return STATUS_INVALID_PARAMETER;
177 
178  ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
179  (ConsoleList != NULL && ConsoleListSize != 0) );
180 
181  /* Remove the console from the list */
183 
184  if (ConsoleList)
185  {
186  for (i = 0; i < ConsoleListSize; i++)
187  {
188  if (ConsoleList[i] == Console) ConsoleList[i] = NULL;
189  }
190  }
191 
192  /* Unlock the console list */
194 
195  return STATUS_SUCCESS;
196 }
197 
198 
199 /* For resetting the frontend - defined in dummyfrontend.c */
201 
202 
203 /* PRIVATE FUNCTIONS **********************************************************/
204 
205 static NTSTATUS
207  IN PCONSOLE_PROCESS_DATA ProcessData,
208  IN ULONG Timeout)
209 {
211 
212  DPRINT("ConDrvConsoleCtrlEventTimeout Parent ProcessId = %x\n", ProcessData->Process->ClientId.UniqueProcess);
213 
214  if (ProcessData->CtrlDispatcher)
215  {
216  _SEH2_TRY
217  {
218  HANDLE Thread = NULL;
219 
220  _SEH2_TRY
221  {
222  Thread = CreateRemoteThread(ProcessData->Process->ProcessHandle, NULL, 0,
223  ProcessData->CtrlDispatcher,
224  UlongToPtr(Event), 0, NULL);
225  if (NULL == Thread)
226  {
228  DPRINT1("Failed thread creation, Status = 0x%08lx\n", Status);
229  }
230  else
231  {
232  DPRINT("ProcessData->CtrlDispatcher remote thread creation succeeded, ProcessId = %x, Process = 0x%p\n", ProcessData->Process->ClientId.UniqueProcess, ProcessData->Process);
234  }
235  }
237  {
239  }
240  _SEH2_END;
241  }
243  {
245  DPRINT1("ConDrvConsoleCtrlEventTimeout - Caught an exception, Status = 0x%08lx\n", Status);
246  }
247  _SEH2_END;
248  }
249 
250  return Status;
251 }
252 
253 static NTSTATUS
255  IN PCONSOLE_PROCESS_DATA ProcessData)
256 {
257  return ConDrvConsoleCtrlEventTimeout(Event, ProcessData, 0);
258 }
259 
262 {
263  Console->PauseFlags |= Flags;
264  if (!Console->UnpauseEvent)
265  Console->UnpauseEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
266 }
267 
270 {
271  Console->PauseFlags &= ~Flags;
272 
273  // if ((Console->PauseFlags & (PAUSED_FROM_KEYBOARD | PAUSED_FROM_SCROLLBAR | PAUSED_FROM_SELECTION)) == 0)
274  if (Console->PauseFlags == 0 && Console->UnpauseEvent)
275  {
276  SetEvent(Console->UnpauseEvent);
277  CloseHandle(Console->UnpauseEvent);
278  Console->UnpauseEvent = NULL;
279 
280  CsrNotifyWait(&Console->WriteWaitQueue,
281  WaitAll,
282  NULL,
283  NULL);
284  if (!IsListEmpty(&Console->WriteWaitQueue))
285  {
286  CsrDereferenceWait(&Console->WriteWaitQueue);
287  }
288  }
289 }
290 
291 
292 /*
293  * Console accessibility check helpers
294  */
295 
298  IN CONSOLE_STATE ExpectedState)
299 {
300  // if (!Console) return FALSE;
301 
302  /* The console must be locked */
303  // ASSERT(Console_locked);
304 
305  return (Console->State == ExpectedState);
306 }
307 
310  IN CONSOLE_STATE ExpectedState,
311  IN BOOLEAN LockConsole)
312 {
313  if (!Console) return FALSE;
314 
315  /*
316  * Lock the console to forbid possible console's state changes
317  * (which must be done when the console is already locked).
318  * If we don't want to lock it, it's because the lock is already
319  * held. So there must be no problems.
320  */
321  if (LockConsole) EnterCriticalSection(&Console->Lock);
322 
323  // ASSERT(Console_locked);
324 
325  /* Check whether the console's state is what we expect */
326  if (!ConDrvValidateConsoleState(Console, ExpectedState))
327  {
328  if (LockConsole) LeaveCriticalSection(&Console->Lock);
329  return FALSE;
330  }
331 
332  return TRUE;
333 }
334 
337  IN HANDLE ConsoleHandle,
338  IN CONSOLE_STATE ExpectedState,
339  IN BOOLEAN LockConsole)
340 {
341  BOOLEAN RetVal = FALSE;
342 
343  ULONG Index = HandleToULong(ConsoleHandle) >> 2;
344  PCONSOLE ValidatedConsole;
345 
346  if (!Console) return FALSE;
347  *Console = NULL;
348 
349  /*
350  * Forbid creation or deletion of consoles when
351  * checking for the existence of a console.
352  */
354 
355  if (Index >= ConsoleListSize ||
356  (ValidatedConsole = ConsoleList[Index]) == NULL)
357  {
358  /* Unlock the console list */
360 
361  return FALSE;
362  }
363 
364  ValidatedConsole = ConsoleList[Index];
365 
366  /* Unlock the console list and return */
368 
369  RetVal = ConDrvValidateConsoleUnsafe(ValidatedConsole,
370  ExpectedState,
371  LockConsole);
372  if (RetVal) *Console = ValidatedConsole;
373 
374  return RetVal;
375 }
376 
379  IN HANDLE ConsoleHandle,
380  IN BOOLEAN LockConsole)
381 {
383  PCONSOLE GrabConsole;
384 
385  if (Console == NULL) return STATUS_INVALID_PARAMETER;
386  *Console = NULL;
387 
388  if (ConDrvValidateConsole(&GrabConsole,
389  ConsoleHandle,
391  LockConsole))
392  {
393  InterlockedIncrement(&GrabConsole->ReferenceCount);
394  *Console = GrabConsole;
396  }
397 
398  return Status;
399 }
400 
401 VOID NTAPI
403  IN BOOLEAN WasConsoleLocked)
404 {
405  LONG RefCount = 0;
406 
407  if (!Console) return;
408  // if (Console->ReferenceCount == 0) return; // This shouldn't happen
409  ASSERT(Console->ReferenceCount > 0);
410 
411  /* The console must be locked */
412  // ASSERT(Console_locked);
413 
414  /*
415  * Decrement the reference count. Save the new value too,
416  * because Console->ReferenceCount might be modified after
417  * the console gets unlocked but before we check whether we
418  * can destroy it.
419  */
420  RefCount = _InterlockedDecrement(&Console->ReferenceCount);
421 
422  /* Unlock the console if needed */
423  if (WasConsoleLocked) LeaveCriticalSection(&Console->Lock);
424 
425  /* Delete the console if needed */
426  if (RefCount <= 0) ConDrvDeleteConsole(Console);
427 }
428 
429 
430 /* CONSOLE INITIALIZATION FUNCTIONS *******************************************/
431 
432 VOID NTAPI
434 {
435  DPRINT("CONSRV: ConDrvInitConsoleSupport()\n");
436 
437  /* Initialize the console list and its lock */
438  ConsoleListSize = 0;
439  ConsoleList = NULL;
441 
442  /* Should call LoadKeyboardLayout */
443 }
444 
446 ConDrvInitConsole(OUT PHANDLE NewConsoleHandle,
447  OUT PCONSOLE* NewConsole,
449  IN ULONG ConsoleLeaderProcessId)
450 {
452  SECURITY_ATTRIBUTES SecurityAttributes;
453  // CONSOLE_INFO CapturedConsoleInfo;
455  HANDLE ConsoleHandle;
457  PCONSOLE_SCREEN_BUFFER NewBuffer;
458  // WCHAR DefaultTitle[128];
459 
460  if (NewConsoleHandle == NULL || NewConsole == NULL || ConsoleInfo == NULL)
462 
463  *NewConsoleHandle = NULL;
464  *NewConsole = NULL;
465 
466  /*
467  * Allocate a console structure
468  */
470  if (NULL == Console)
471  {
472  DPRINT1("Not enough memory for console creation.\n");
473  return STATUS_NO_MEMORY;
474  }
475 
476  /*
477  * Load the console settings
478  */
479 
480  /* 1. Load the default settings */
481  // ConSrvGetDefaultSettings(ConsoleInfo, ProcessId);
482 
483  // /* 2. Get the title of the console (initialize ConsoleInfo.ConsoleTitle) */
484  // Length = min(wcslen(ConsoleStartInfo->ConsoleTitle),
485  // sizeof(ConsoleInfo.ConsoleTitle) / sizeof(ConsoleInfo.ConsoleTitle[0]) - 1);
486  // wcsncpy(ConsoleInfo.ConsoleTitle, ConsoleStartInfo->ConsoleTitle, Length);
487  // ConsoleInfo.ConsoleTitle[Length] = L'\0';
488 
489  /*
490  * 4. Load the remaining console settings via the registry.
491  */
492 #if 0
493  if ((ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
494  {
495  /*
496  * Either we weren't created by an app launched via a shell-link,
497  * or we failed to load shell-link console properties.
498  * Therefore, load the console infos for the application from the registry.
499  */
501 
502  /*
503  * Now, update them with the properties the user might gave to us
504  * via the STARTUPINFO structure before calling CreateProcess
505  * (and which was transmitted via the ConsoleStartInfo structure).
506  * We therefore overwrite the values read in the registry.
507  */
508  if (ConsoleStartInfo->dwStartupFlags & STARTF_USEFILLATTRIBUTE)
509  {
510  ConsoleInfo->ScreenAttrib = (USHORT)ConsoleStartInfo->FillAttribute;
511  }
512  if (ConsoleStartInfo->dwStartupFlags & STARTF_USECOUNTCHARS)
513  {
514  ConsoleInfo->ScreenBufferSize = ConsoleStartInfo->ScreenBufferSize;
515  }
516  if (ConsoleStartInfo->dwStartupFlags & STARTF_USESIZE)
517  {
518  // ConsoleInfo->ConsoleSize = ConsoleStartInfo->ConsoleWindowSize;
519  ConsoleInfo->ConsoleSize.X = (SHORT)ConsoleStartInfo->ConsoleWindowSize.cx;
520  ConsoleInfo->ConsoleSize.Y = (SHORT)ConsoleStartInfo->ConsoleWindowSize.cy;
521  }
522  }
523 #endif
524 
525  /*
526  * Fix the screen buffer size if needed. The rule is:
527  * ScreenBufferSize >= ConsoleSize
528  */
529  if (ConsoleInfo->ScreenBufferSize.X < ConsoleInfo->ConsoleSize.X)
530  ConsoleInfo->ScreenBufferSize.X = ConsoleInfo->ConsoleSize.X;
531  if (ConsoleInfo->ScreenBufferSize.Y < ConsoleInfo->ConsoleSize.Y)
532  ConsoleInfo->ScreenBufferSize.Y = ConsoleInfo->ConsoleSize.Y;
533 
534  /*
535  * Initialize the console
536  */
537  Console->State = CONSOLE_INITIALIZING;
538  Console->ReferenceCount = 0;
540  InitializeListHead(&Console->ProcessList);
541 
542  /* Initialize the frontend interface */
544 
545  memcpy(Console->Colors, ConsoleInfo->Colors, sizeof(ConsoleInfo->Colors));
546  Console->ConsoleSize = ConsoleInfo->ConsoleSize;
547  Console->FixedSize = FALSE; // Value by default; is reseted by the front-ends if needed.
548 
549  /*
550  * Initialize the input buffer
551  */
552  ConSrvInitObject(&Console->InputBuffer.Header, INPUT_BUFFER, Console);
553 
554  SecurityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
555  SecurityAttributes.lpSecurityDescriptor = NULL;
556  SecurityAttributes.bInheritHandle = TRUE;
557  Console->InputBuffer.ActiveEvent = CreateEventW(&SecurityAttributes, TRUE, FALSE, NULL);
558  if (NULL == Console->InputBuffer.ActiveEvent)
559  {
562  return STATUS_UNSUCCESSFUL;
563  }
564 
565  Console->InputBuffer.InputBufferSize = 0; // FIXME!
566  InitializeListHead(&Console->InputBuffer.InputEvents);
567  InitializeListHead(&Console->InputBuffer.ReadWaitQueue);
568  Console->InputBuffer.Mode = ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
570 
571  Console->QuickEdit = ConsoleInfo->QuickEdit;
572  Console->InsertMode = ConsoleInfo->InsertMode;
573  Console->LineBuffer = NULL;
574  Console->LineMaxSize = Console->LineSize = Console->LinePos = 0;
575  Console->LineComplete = Console->LineUpPressed = Console->LineInsertToggle = FALSE;
576  // LineWakeupMask
577 
578  // FIXME: This is terminal-specific !! VV
579  RtlZeroMemory(&Console->Selection, sizeof(CONSOLE_SELECTION_INFO));
580  Console->Selection.dwFlags = CONSOLE_NO_SELECTION;
581  // dwSelectionCursor
582 
583  /* Set-up the code page */
584  Console->CodePage = Console->OutputCodePage = ConsoleInfo->CodePage;
585 
586  /* Initialize a new text-mode screen buffer with default settings */
587  ScreenBufferInfo.ScreenBufferSize = ConsoleInfo->ScreenBufferSize;
588  ScreenBufferInfo.ScreenAttrib = ConsoleInfo->ScreenAttrib;
589  ScreenBufferInfo.PopupAttrib = ConsoleInfo->PopupAttrib;
590  ScreenBufferInfo.IsCursorVisible = TRUE;
591  ScreenBufferInfo.CursorSize = ConsoleInfo->CursorSize;
592 
593  InitializeListHead(&Console->BufferList);
594  Status = ConDrvCreateScreenBuffer(&NewBuffer,
595  Console,
598  if (!NT_SUCCESS(Status))
599  {
600  DPRINT1("ConDrvCreateScreenBuffer: failed, Status = 0x%08lx\n", Status);
601  CloseHandle(Console->InputBuffer.ActiveEvent);
604  return Status;
605  }
606  /* Make the new screen buffer active */
607  Console->ActiveBuffer = NewBuffer;
608  InitializeListHead(&Console->WriteWaitQueue);
609  Console->PauseFlags = 0;
610  Console->UnpauseEvent = NULL;
611 
612  /*
613  * Initialize the alias and history buffers
614  */
615  Console->Aliases = NULL;
616  InitializeListHead(&Console->HistoryBuffers);
617  Console->HistoryBufferSize = ConsoleInfo->HistoryBufferSize;
618  Console->NumberOfHistoryBuffers = ConsoleInfo->NumberOfHistoryBuffers;
619  Console->HistoryNoDup = ConsoleInfo->HistoryNoDup;
620 
621  /* Initialize the console title */
622  ConsoleCreateUnicodeString(&Console->OriginalTitle, ConsoleInfo->ConsoleTitle);
623  // if (ConsoleInfo.ConsoleTitle[0] == L'\0')
624  // {
625  // if (LoadStringW(ConSrvDllInstance, IDS_CONSOLE_TITLE, DefaultTitle, sizeof(DefaultTitle) / sizeof(DefaultTitle[0])))
626  // {
627  // ConsoleCreateUnicodeString(&Console->Title, DefaultTitle);
628  // }
629  // else
630  // {
631  // ConsoleCreateUnicodeString(&Console->Title, L"ReactOS Console");
632  // }
633  // }
634  // else
635  // {
636  ConsoleCreateUnicodeString(&Console->Title, ConsoleInfo->ConsoleTitle);
637  // }
638 
639  /* Lock the console until its initialization is finished */
640  // EnterCriticalSection(&Console->Lock);
641 
642  DPRINT("Console initialized\n");
643 
644  /* All went right, so add the console to the list */
645  Status = InsertConsole(&ConsoleHandle, Console);
646  if (!NT_SUCCESS(Status))
647  {
648  /* Fail */
650  return Status;
651  }
652 
653  /* The initialization is finished */
654  DPRINT("Change state\n");
655  Console->State = CONSOLE_RUNNING;
656 
657  /* Unlock the console */
658  // LeaveCriticalSection(&Console->Lock);
659 
660  /* Return the newly created console to the caller and a success code too */
661  *NewConsoleHandle = ConsoleHandle;
662  *NewConsole = Console;
663  return STATUS_SUCCESS;
664 }
665 
668  IN PFRONTEND FrontEnd)
669 {
671 
672  if (Console == NULL || FrontEnd == NULL)
674 
675  /* FIXME: Lock the console before ?? */
676 
677  /*
678  * Attach the frontend to the console. Use now the TermIFace of the console,
679  * and not the user-defined temporary FrontEnd pointer.
680  */
681  Console->TermIFace = *FrontEnd;
682  Console->TermIFace.Console = Console;
683 
684  /* Initialize the frontend AFTER having attached it to the console */
685  DPRINT("Finish initialization of frontend\n");
686  Status = Console->TermIFace.Vtbl->InitFrontEnd(&Console->TermIFace, Console);
687  if (!NT_SUCCESS(Status))
688  {
689  DPRINT1("FrontEnd initialization failed, Status = 0x%08lx\n", Status);
690 
691  /* We failed, detach the frontend from the console */
692  FrontEnd->Console = NULL; // For the caller
694 
695  return Status;
696  }
697 
698  /* Copy buffer contents to screen */
699  // FrontEnd.Draw();
700  // ConioDrawConsole(Console);
701  DPRINT("Console drawn\n");
702 
703  DPRINT("Terminal FrontEnd initialization done\n");
704  return STATUS_SUCCESS;
705 }
706 
709 {
710  if (Console == NULL) return STATUS_INVALID_PARAMETER;
711 
712  /* FIXME: Lock the console before ?? */
713 
714  /* Deinitialize the frontend BEFORE detaching it from the console */
715  Console->TermIFace.Vtbl->DeinitFrontEnd(&Console->TermIFace/*, Console*/);
716 
717  /*
718  * Detach the frontend from the console:
719  * reinitialize the frontend interface.
720  */
722 
723  DPRINT("Terminal FrontEnd unregistered\n");
724  return STATUS_SUCCESS;
725 }
726 
727 VOID NTAPI
729 {
730  DPRINT("ConDrvDeleteConsole(0x%p)\n", Console);
731 
732  /*
733  * Forbid validation of any console by other threads
734  * during the deletion of this console.
735  */
737 
738  /*
739  * If the console is already being destroyed, i.e. not running
740  * or finishing to be initialized, just return.
741  */
744  {
745  /* Unlock the console list and return */
747  return;
748  }
749 
750  /*
751  * We are about to be destroyed. Signal it to other people
752  * so that they can terminate what they are doing, and that
753  * they cannot longer validate the console.
754  */
755  Console->State = CONSOLE_TERMINATING;
756 
757  /*
758  * Allow other threads to finish their job: basically, unlock
759  * all other calls to EnterCriticalSection(&Console->Lock); by
760  * ConDrvValidateConsole(Unsafe) functions so that they just see
761  * that we are not in CONSOLE_RUNNING state anymore, or unlock
762  * other concurrent calls to ConDrvDeleteConsole so that they
763  * can see that we are in fact already deleting the console.
764  */
767 
768  /* FIXME: Send a terminate message to all the processes owning this console */
769 
770  /* Cleanup the UI-oriented part */
771  DPRINT("Deregister console\n");
773  DPRINT("Console deregistered\n");
774 
775  /***
776  * Check that the console is in terminating state before continuing
777  * (the cleanup code must not change the state of the console...
778  * ...unless to cancel console deletion ?).
779  ***/
780 
782 
784  {
786  return;
787  }
788 
789  /* We are now in destruction */
791 
792  /* We really delete the console. Reset the count to be sure. */
793  Console->ReferenceCount = 0;
794 
795  /* Remove the console from the list */
797 
798  /* Discard all entries in the input event queue */
800 
801  if (Console->LineBuffer) ConsoleFreeHeap(Console->LineBuffer);
802 
805 
806  ConioDeleteScreenBuffer(Console->ActiveBuffer);
807  Console->ActiveBuffer = NULL;
808  if (!IsListEmpty(&Console->BufferList))
809  {
810  DPRINT1("BUG: screen buffer list not empty\n");
811  ASSERT(FALSE);
812  }
813 
814  CloseHandle(Console->InputBuffer.ActiveEvent);
815  if (Console->UnpauseEvent) CloseHandle(Console->UnpauseEvent);
816 
817  ConsoleFreeUnicodeString(&Console->OriginalTitle);
819 
820  DPRINT("ConDrvDeleteConsole - Unlocking\n");
822  DPRINT("ConDrvDeleteConsole - Destroying lock\n");
824  DPRINT("ConDrvDeleteConsole - Lock destroyed ; freeing console\n");
825 
827  DPRINT("ConDrvDeleteConsole - Console destroyed\n");
828 
829  /* Unlock the console list and return */
831 }
832 
833 
834 /* PUBLIC DRIVER APIS *********************************************************/
835 
839  OUT PULONG ConsoleMode)
840 {
842 
843  if (Console == NULL || Object == NULL || ConsoleMode == NULL)
845 
846  /* Validity check */
847  ASSERT(Console == Object->Console);
848 
849  /*** FIXME: */ *ConsoleMode = 0; /***/
850 
851  if (INPUT_BUFFER == Object->Type)
852  {
854 
855  *ConsoleMode = InputBuffer->Mode;
856 
857  if (Console->QuickEdit || Console->InsertMode)
858  {
859  // Windows does this, even if it's not documented on MSDN
860  *ConsoleMode |= ENABLE_EXTENDED_FLAGS;
861 
862  if (Console->QuickEdit ) *ConsoleMode |= ENABLE_QUICK_EDIT_MODE;
863  if (Console->InsertMode) *ConsoleMode |= ENABLE_INSERT_MODE;
864  }
865  }
866  else if (TEXTMODE_BUFFER == Object->Type || GRAPHICS_BUFFER == Object->Type)
867  {
869  *ConsoleMode = Buffer->Mode;
870  }
871  else
872  {
874  }
875 
876  return Status;
877 }
878 
882  IN ULONG ConsoleMode)
883 {
884 #define CONSOLE_VALID_CONTROL_MODES ( ENABLE_EXTENDED_FLAGS | ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE )
885 #define CONSOLE_VALID_INPUT_MODES ( ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | \
886  ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT | \
887  ENABLE_MOUSE_INPUT )
888 #define CONSOLE_VALID_OUTPUT_MODES ( ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT )
889 
891 
892  if (Console == NULL || Object == NULL)
894 
895  /* Validity check */
896  ASSERT(Console == Object->Console);
897 
898  if (INPUT_BUFFER == Object->Type)
899  {
901 
902  DPRINT("SetConsoleMode(Input, %d)\n", ConsoleMode);
903 
904  /*
905  * 1. Only the presence of valid mode flags is allowed.
906  */
908  {
910  goto Quit;
911  }
912 
913  /*
914  * 2. If we use control mode flags without ENABLE_EXTENDED_FLAGS,
915  * then consider the flags invalid.
916  *
917  if ( (ConsoleMode & CONSOLE_VALID_CONTROL_MODES) &&
918  (ConsoleMode & ENABLE_EXTENDED_FLAGS) == 0 )
919  {
920  Status = STATUS_INVALID_PARAMETER;
921  goto Quit;
922  }
923  */
924 
925  /*
926  * 3. Now we can continue.
927  */
928  if (ConsoleMode & CONSOLE_VALID_CONTROL_MODES)
929  {
930  Console->QuickEdit = !!(ConsoleMode & ENABLE_QUICK_EDIT_MODE);
931  Console->InsertMode = !!(ConsoleMode & ENABLE_INSERT_MODE);
932  }
933  InputBuffer->Mode = (ConsoleMode & CONSOLE_VALID_INPUT_MODES);
934  }
935  else if (TEXTMODE_BUFFER == Object->Type || GRAPHICS_BUFFER == Object->Type)
936  {
938 
939  DPRINT("SetConsoleMode(Output, %d)\n", ConsoleMode);
940 
941  if (ConsoleMode & ~CONSOLE_VALID_OUTPUT_MODES)
942  {
944  }
945  else
946  {
947  Buffer->Mode = (ConsoleMode & CONSOLE_VALID_OUTPUT_MODES);
948  }
949  }
950  else
951  {
953  }
954 
955 Quit:
956  return Status;
957 }
958 
961  IN OUT PWCHAR Title,
962  IN OUT PULONG BufLength)
963 {
964  ULONG Length;
965 
966  if (Console == NULL || Title == NULL || BufLength == NULL)
968 
969  /* Copy title of the console to the user title buffer */
970  if (*BufLength >= sizeof(WCHAR))
971  {
972  Length = min(*BufLength - sizeof(WCHAR), Console->Title.Length);
973  RtlCopyMemory(Title, Console->Title.Buffer, Length);
974  Title[Length / sizeof(WCHAR)] = L'\0';
975  }
976 
977  *BufLength = Console->Title.Length;
978 
979  return STATUS_SUCCESS;
980 }
981 
984  IN PWCHAR Title,
985  IN ULONG BufLength)
986 {
987  PWCHAR Buffer;
988 
989  if (Console == NULL || Title == NULL)
991 
992  /* Allocate a new buffer to hold the new title (NULL-terminated) */
993  Buffer = ConsoleAllocHeap(0, BufLength + sizeof(WCHAR));
994  if (!Buffer) return STATUS_NO_MEMORY;
995 
996  /* Free the old title */
998 
999  /* Copy title to console */
1000  Console->Title.Buffer = Buffer;
1001  Console->Title.Length = BufLength;
1002  Console->Title.MaximumLength = Console->Title.Length + sizeof(WCHAR);
1003  RtlCopyMemory(Console->Title.Buffer, Title, Console->Title.Length);
1004  Console->Title.Buffer[Console->Title.Length / sizeof(WCHAR)] = L'\0';
1005 
1006  // ConioChangeTitle(Console);
1007  return STATUS_SUCCESS;
1008 }
1009 
1012  OUT PUINT CodePage,
1013  IN BOOLEAN InputCP)
1014 {
1015  if (Console == NULL || CodePage == NULL)
1016  return STATUS_INVALID_PARAMETER;
1017 
1018  *CodePage = (InputCP ? Console->CodePage : Console->OutputCodePage);
1019 
1020  return STATUS_SUCCESS;
1021 }
1022 
1025  IN UINT CodePage,
1026  IN BOOLEAN InputCP)
1027 {
1028  if (Console == NULL || !IsValidCodePage(CodePage))
1029  return STATUS_INVALID_PARAMETER;
1030 
1031  if (InputCP)
1032  Console->CodePage = CodePage;
1033  else
1034  Console->OutputCodePage = CodePage;
1035 
1036  return STATUS_SUCCESS;
1037 }
1038 
1041  IN OUT PULONG ProcessIdsList,
1042  IN ULONG MaxIdListItems,
1043  OUT PULONG ProcessIdsTotal)
1044 {
1046  PLIST_ENTRY current_entry;
1047 
1048  if (Console == NULL || ProcessIdsList == NULL || ProcessIdsTotal == NULL)
1049  return STATUS_INVALID_PARAMETER;
1050 
1051  *ProcessIdsTotal = 0;
1052 
1053  for (current_entry = Console->ProcessList.Flink;
1054  current_entry != &Console->ProcessList;
1055  current_entry = current_entry->Flink)
1056  {
1057  current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink);
1058  if (++(*ProcessIdsTotal) <= MaxIdListItems)
1059  {
1060  *ProcessIdsList++ = HandleToUlong(current->Process->ClientId.UniqueProcess);
1061  }
1062  }
1063 
1064  return STATUS_SUCCESS;
1065 }
1066 
1067 // ConDrvGenerateConsoleCtrlEvent
1070  IN ULONG ProcessGroupId,
1071  IN ULONG Event)
1072 {
1074  PLIST_ENTRY current_entry;
1076 
1077  /* If the console is already being destroyed, just return */
1079  return STATUS_UNSUCCESSFUL;
1080 
1081  /*
1082  * Loop through the process list, from the most recent process
1083  * (the active one) to the oldest one (the first created, i.e.
1084  * the console leader process), and for each, send an event
1085  * (new processes are inserted at the head of the console process list).
1086  */
1087  current_entry = Console->ProcessList.Flink;
1088  while (current_entry != &Console->ProcessList)
1089  {
1090  current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink);
1091  current_entry = current_entry->Flink;
1092 
1093  /*
1094  * Only processes belonging to the same process group are signaled.
1095  * If the process group ID is zero, then all the processes are signaled.
1096  */
1097  if (ProcessGroupId == 0 || current->Process->ProcessGroupId == ProcessGroupId)
1098  {
1100  }
1101  }
1102 
1103  return Status;
1104 }
1105 
1106 /* EOF */
#define CreateEvent
Definition: winbase.h:3562
BOOLEAN NTAPI ConDrvValidateConsoleState(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState)
Definition: console.c:108
const uint16_t * PCWSTR
Definition: typedefs.h:55
#define IN
Definition: typedefs.h:38
#define ULongToHandle(h)
Definition: basetsd.h:81
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
NTSTATUS NTAPI ConDrvConsoleProcessCtrlEvent(IN PCONSOLE Console, IN ULONG ProcessGroupId, IN ULONG Event)
Definition: console.c:1069
VOID IntDeleteAllAliases(PCONSRV_CONSOLE Console)
Definition: alias.c:428
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
NTSTATUS NTAPI ConDrvGetConsoleTitle(IN PCONSOLE Console, IN OUT PWCHAR Title, IN OUT PULONG BufLength)
Definition: console.c:960
#define CloseHandle
Definition: compat.h:398
VOID ConioUnpause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:250
#define CONSOLE_VALID_CONTROL_MODES
NTSTATUS NTAPI ConDrvDeregisterFrontEnd(IN PCONSOLE Console)
Definition: console.c:708
CONSOLE_SCREEN_BUFFER_INFO ScreenBufferInfo
Definition: notevil.c:38
VOID HistoryDeleteBuffers(PCONSRV_CONSOLE Console)
Definition: history.c:313
VOID NTAPI ConDrvInitConsoleSupport(VOID)
Definition: console.c:150
LONG ReferenceCount
Definition: conio.h:325
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define CONSOLE_VALID_OUTPUT_MODES
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
#define ConDrvUnlockConsoleList()
Definition: console.c:47
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
NTSTATUS NTAPI ConDrvGetConsoleProcessList(IN PCONSOLE Console, IN OUT PULONG ProcessIdsList, IN ULONG MaxIdListItems, OUT PULONG ProcessIdsTotal)
Definition: console.c:1040
#define STARTF_USEFILLATTRIBUTE
Definition: winbase.h:476
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:679
#define HandleToULong(h)
Definition: basetsd.h:95
#define CONSOLE_NO_SELECTION
Definition: wincon.h:96
NTSTATUS ConDrvCreateScreenBuffer(OUT PCONSOLE_SCREEN_BUFFER *Buffer, IN PCONSOLE Console, IN HANDLE ProcessHandle OPTIONAL, IN ULONG BufferType, IN PVOID ScreenBufferInfo)
Definition: conoutput.c:79
uint16_t * PWCHAR
Definition: typedefs.h:54
#define TEXTMODE_BUFFER
Definition: pccons.c:21
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
NTSTATUS NTAPI ConDrvGetConsoleMode(IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, OUT PULONG ConsoleMode)
Definition: console.c:426
#define FASTCALL
Definition: nt_native.h:50
#define CONSOLE_HANDLES_INCREMENT
VOID NTAPI ConDrvReleaseConsole(IN PCONSOLE Console, IN BOOLEAN WasConsoleLocked)
Definition: console.c:402
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
BOOLEAN NTAPI CsrNotifyWait(IN PLIST_ENTRY WaitList, IN BOOLEAN NotifyAll, IN PVOID WaitArgument1, IN PVOID WaitArgument2)
Definition: wait.c:388
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
CHAR InputBuffer[80]
Definition: conmgr.c:33
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:597
_SEH2_TRY
Definition: create.c:4250
NTSTATUS NTAPI ConDrvSetConsoleMode(IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, IN ULONG ConsoleMode)
Definition: console.c:459
#define ENABLE_ECHO_INPUT
Definition: wincon.h:77
NTSTATUS NTAPI ConDrvRegisterFrontEnd(IN PCONSOLE Console, IN PFRONTEND FrontEnd)
Definition: console.c:667
VOID NTAPI ConDrvDeleteConsole(IN PCONSOLE Console)
Definition: console.c:327
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
struct _CONSOLE_INPUT_BUFFER * PCONSOLE_INPUT_BUFFER
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
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
BOOL ConSrvReadUserSettings(IN OUT PCONSOLE_INFO ConsoleInfo, IN DWORD ProcessId)
Definition: settings.c:194
long LONG
Definition: pedump.c:60
short SHORT
Definition: pedump.c:59
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
struct _CONSOLE_SCREEN_BUFFER * PCONSOLE_SCREEN_BUFFER
Definition: conio.h:70
unsigned char BOOLEAN
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:697
smooth NULL
Definition: ftsmooth.c:416
static BOOLEAN ConsoleCreateUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PCWSTR Source)
Definition: console.c:52
void DPRINT(...)
Definition: polytest.cpp:61
static NTSTATUS ConDrvConsoleCtrlEvent(IN ULONG Event, IN PCONSOLE_PROCESS_DATA ProcessData)
Definition: console.c:254
static NTSTATUS ConDrvConsoleCtrlEventTimeout(IN ULONG Event, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Timeout)
Definition: console.c:206
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
#define UlongToPtr(u)
Definition: config.h:106
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
_In_ HANDLE Handle
Definition: extypes.h:390
NTSYSAPI VOID NTAPI RtlInitializeResource(_In_ PRTL_RESOURCE Resource)
static const WCHAR Title[]
Definition: oid.c:1259
NTSTATUS NTAPI ConDrvSetConsoleTitle(IN PCONSOLE Console, IN PWCHAR Title, IN ULONG BufLength)
Definition: console.c:983
__wchar_t WCHAR
Definition: xmlstorage.h:180
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static NTSTATUS RemoveConsoleByPointer(IN PCONSOLE Console)
Definition: console.c:172
static const UCHAR Index[8]
Definition: usbohci.c:18
BOOLEAN NTAPI ConDrvValidateConsole(OUT PCONSOLE *Console, IN HANDLE ConsoleHandle, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:336
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define ENABLE_LINE_INPUT
Definition: wincon.h:76
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static PCONSOLE * ConsoleList
Definition: console.c:38
static IUnknown Object
Definition: main.c:512
VOID NTAPI CsrDereferenceWait(IN PLIST_ENTRY WaitList)
Definition: wait.c:266
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define ENABLE_MOUSE_INPUT
Definition: wincon.h:79
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: typedefs.h:117
VOID ConSrvInitObject(IN OUT PCONSOLE_IO_OBJECT Object, IN CONSOLE_IO_OBJECT_TYPE Type, IN PCONSOLE Console)
Definition: handle.c:294
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
Status
Definition: gdiplustypes.h:24
#define ENABLE_PROCESSED_INPUT
Definition: wincon.h:75
ULONG_PTR SIZE_T
Definition: typedefs.h:78
NTSTATUS NTAPI ConDrvSetConsoleCP(IN PCONSOLE Console, IN UINT CodePage, IN BOOLEAN OutputCP)
Definition: console.c:526
_SEH2_END
Definition: create.c:4424
BOOL WINAPI IsValidCodePage(UINT CodePage)
Definition: nls.c:1468
VOID WINAPI ConioDeleteScreenBuffer(PCONSOLE_SCREEN_BUFFER Buffer)
Definition: conoutput.c:113
static ULONG Timeout
Definition: ping.c:61
static ULONG ConsoleListSize
Definition: console.c:37
#define InterlockedIncrement
Definition: armddk.h:53
#define STARTF_USECOUNTCHARS
Definition: winbase.h:475
LPVOID lpSecurityDescriptor
Definition: compat.h:181
#define CONSOLE_TEXTMODE_BUFFER
Definition: wincon.h:59
static VOID PurgeInputBuffer(PCONSOLE Console)
Definition: coninput.c:173
unsigned short USHORT
Definition: pedump.c:61
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
NTSTATUS NTAPI RtlGetLastNtStatus(VOID)
Definition: error.c:114
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define ENABLE_INSERT_MODE
Definition: wincon.h:80
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
VOID ResetFrontEnd(IN PCONSOLE Console)
_SEH2_FINALLY
Definition: create.c:4395
#define ENABLE_EXTENDED_FLAGS
Definition: wincon.h:82
unsigned int * PULONG
Definition: retypes.h:1
#define min(a, b)
Definition: monoChain.cc:55
NTSTATUS NTAPI ConDrvGetConsoleCP(IN PCONSOLE Console, OUT PUINT CodePage, IN BOOLEAN OutputCP)
Definition: console.c:513
#define STARTF_USESIZE
Definition: winbase.h:473
unsigned int UINT
Definition: ndis.h:50
static NTSTATUS InsertConsole(OUT PHANDLE Handle, IN PCONSOLE Console)
Definition: console.c:81
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MAXUSHORT
Definition: typedefs.h:81
CConsole Console
#define DPRINT1
Definition: precomp.h:8
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
VOID ConioPause(PCONSRV_CONSOLE Console, UINT Flags)
Definition: console.c:243
NTSTATUS NTAPI ConDrvInitConsole(OUT PCONSOLE *NewConsole, IN PCONSOLE_INFO ConsoleInfo)
Definition: console.c:163
#define OUT
Definition: typedefs.h:39
static RTL_RESOURCE ListLock
Definition: console.c:39
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ENABLE_QUICK_EDIT_MODE
Definition: wincon.h:81
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
#define CONSOLE_VALID_INPUT_MODES
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2777
#define ConDrvLockConsoleListExclusive()
Definition: console.c:41
NTSTATUS NTAPI ConDrvGetConsole(OUT PCONSOLE *Console, IN HANDLE ConsoleHandle, IN BOOLEAN LockConsole)
Definition: console.c:378
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned int * PUINT
Definition: ndis.h:50
struct task_struct * current
Definition: linux.c:32
static VOID ConsoleFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
Definition: console.c:70
struct _SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES
#define ConDrvLockConsoleListShared()
Definition: console.c:44
HANDLE WINAPI CreateRemoteThread(IN HANDLE hProcess, IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:133