ReactOS  0.4.14-dev-114-gc8cbd56
console.c File Reference
#include "consrv.h"
#include <shlobj.h>
#include <alias.h>
#include <history.h>
#include "procinit.h"
#include <debug.h>
Include dependency graph for console.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#define NDEBUG
 
#define ConSrvLockConsoleListExclusive()   RtlAcquireResourceExclusive(&ListLock, TRUE)
 
#define ConSrvLockConsoleListShared()   RtlAcquireResourceShared(&ListLock, TRUE)
 
#define ConSrvUnlockConsoleList()   RtlReleaseResource(&ListLock)
 
#define CONSOLE_HANDLES_INCREMENT   2 * 3
 
#define PATH_SEPARATOR   L'\\'
 
#define CONSOLE_VALID_CONTROL_MODES
 

Functions

static NTSTATUS InsertConsole (OUT PHANDLE Handle, IN PCONSRV_CONSOLE Console)
 
static NTSTATUS RemoveConsoleByPointer (IN PCONSRV_CONSOLE Console)
 
BOOLEAN NTAPI ConSrvValidateConsole (OUT PCONSRV_CONSOLE *Console, IN HANDLE ConsoleHandle, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
 
static BOOLEAN ConsoleCreateUnicodeString (IN OUT PUNICODE_STRING UniDest, IN PCWSTR Source)
 
static VOID ConsoleFreeUnicodeString (IN PUNICODE_STRING UnicodeString)
 
VOID ConioPause (PCONSRV_CONSOLE Console, UINT Flags)
 
VOID ConioUnpause (PCONSRV_CONSOLE Console, UINT Flags)
 
NTSTATUS ConSrvGetConsole (IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
 
VOID ConSrvReleaseConsole (IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
 
VOID NTAPI ConSrvInitConsoleSupport (VOID)
 
NTSTATUS NTAPI ConSrvInitTerminal (IN OUT PTERMINAL Terminal, IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN HANDLE ConsoleLeaderProcessHandle)
 
NTSTATUS NTAPI ConSrvDeinitTerminal (IN OUT PTERMINAL Terminal)
 
static BOOL LoadShellLinkConsoleInfo (IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo)
 
NTSTATUS NTAPI ConSrvInitConsole (OUT PHANDLE NewConsoleHandle, OUT PCONSRV_CONSOLE *NewConsole, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo, IN PCSR_PROCESS ConsoleLeaderProcess)
 
VOID NTAPI ConSrvDeleteConsole (PCONSRV_CONSOLE Console)
 
NTSTATUS ConSrvConsoleCtrlEventTimeout (IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Timeout)
 
NTSTATUS ConSrvConsoleCtrlEvent (IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData)
 
PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess (IN PCONSRV_CONSOLE Console)
 
NTSTATUS NTAPI ConSrvGetConsoleProcessList (IN PCONSRV_CONSOLE Console, IN OUT PULONG ProcessIdsList, IN ULONG MaxIdListItems, OUT PULONG ProcessIdsTotal)
 
NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent (IN PCONSRV_CONSOLE Console, IN ULONG ProcessGroupId, IN ULONG CtrlEvent)
 
VOID ConSrvSetProcessFocus (IN PCSR_PROCESS CsrProcess, IN BOOLEAN SetForeground)
 
NTSTATUS NTAPI ConSrvSetConsoleProcessFocus (IN PCONSRV_CONSOLE Console, IN BOOLEAN SetForeground)
 
 CSR_API (SrvAllocConsole)
 
 CSR_API (SrvAttachConsole)
 
 CSR_API (SrvFreeConsole)
 
NTSTATUS NTAPI ConDrvGetConsoleMode (IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, OUT PULONG ConsoleMode)
 
 CSR_API (SrvGetConsoleMode)
 
NTSTATUS NTAPI ConDrvSetConsoleMode (IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, IN ULONG ConsoleMode)
 
 CSR_API (SrvSetConsoleMode)
 
 CSR_API (SrvGetConsoleTitle)
 
 CSR_API (SrvSetConsoleTitle)
 
NTSTATUS NTAPI ConDrvGetConsoleCP (IN PCONSOLE Console, OUT PUINT CodePage, IN BOOLEAN OutputCP)
 
 CSR_API (SrvGetConsoleCP)
 
NTSTATUS NTAPI ConDrvSetConsoleCP (IN PCONSOLE Console, IN UINT CodePage, IN BOOLEAN OutputCP)
 
 CSR_API (SrvSetConsoleCP)
 
 CSR_API (SrvGetConsoleProcessList)
 
 CSR_API (SrvGenerateConsoleCtrlEvent)
 
 CSR_API (SrvConsoleNotifyLastClose)
 
 CSR_API (SrvGetConsoleMouseInfo)
 
 CSR_API (SrvSetConsoleKeyShortcuts)
 
 CSR_API (SrvGetConsoleKeyboardLayoutName)
 
 CSR_API (SrvGetConsoleCharType)
 
 CSR_API (SrvSetConsoleLocalEUDC)
 
 CSR_API (SrvSetConsoleCursorMode)
 
 CSR_API (SrvGetConsoleCursorMode)
 
 CSR_API (SrvGetConsoleNlsMode)
 
 CSR_API (SrvSetConsoleNlsMode)
 
 CSR_API (SrvGetConsoleLangId)
 

Variables

static ULONG ConsoleListSize
 
static PCONSRV_CONSOLEConsoleList
 
static RTL_RESOURCE ListLock
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 16 of file console.c.

◆ CONSOLE_HANDLES_INCREMENT

#define CONSOLE_HANDLES_INCREMENT   2 * 3

◆ CONSOLE_VALID_CONTROL_MODES

#define CONSOLE_VALID_CONTROL_MODES
Value:
ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE )
#define ENABLE_EXTENDED_FLAGS
Definition: wincon.h:82
#define ENABLE_QUICK_EDIT_MODE
Definition: wincon.h:81

◆ ConSrvLockConsoleListExclusive

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

Definition at line 35 of file console.c.

◆ ConSrvLockConsoleListShared

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

Definition at line 38 of file console.c.

◆ ConSrvUnlockConsoleList

#define ConSrvUnlockConsoleList ( )    RtlReleaseResource(&ListLock)

Definition at line 41 of file console.c.

◆ NDEBUG

#define NDEBUG

Definition at line 24 of file console.c.

◆ PATH_SEPARATOR

#define PATH_SEPARATOR   L'\\'

Function Documentation

◆ ConDrvGetConsoleCP()

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

Definition at line 513 of file console.c.

516 {
517  if (Console == NULL || CodePage == NULL)
519 
520  *CodePage = (OutputCP ? Console->OutputCodePage : Console->InputCodePage);
521 
522  return STATUS_SUCCESS;
523 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ ConDrvGetConsoleMode()

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

Definition at line 426 of file console.c.

429 {
431 
432  if (Console == NULL || Object == NULL || ConsoleMode == NULL)
434 
435  /* Validity check */
436  ASSERT(Console == Object->Console);
437 
438  /*** FIXME: */ *ConsoleMode = 0; /***/
439 
440  if (INPUT_BUFFER == Object->Type)
441  {
443  *ConsoleMode = InputBuffer->Mode;
444  }
445  else if (TEXTMODE_BUFFER == Object->Type || GRAPHICS_BUFFER == Object->Type)
446  {
448  *ConsoleMode = Buffer->Mode;
449  }
450  else
451  {
453  }
454 
455  return Status;
456 }
#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:2966

◆ ConDrvSetConsoleCP()

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

Definition at line 526 of file console.c.

529 {
530  if (Console == NULL || !IsValidCodePage(CodePage))
532 
533  if (OutputCP)
534  Console->OutputCodePage = CodePage;
535  else
536  Console->InputCodePage = CodePage;
537 
538  return STATUS_SUCCESS;
539 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI IsValidCodePage(UINT CodePage)
Definition: nls.c:1468
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ ConDrvSetConsoleMode()

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

Definition at line 459 of file console.c.

462 {
463 #define CONSOLE_VALID_INPUT_MODES ( ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | \
464  ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT | \
465  ENABLE_MOUSE_INPUT )
466 #define CONSOLE_VALID_OUTPUT_MODES ( ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT )
467 
469 
470  if (Console == NULL || Object == NULL)
472 
473  /* Validity check */
474  ASSERT(Console == Object->Console);
475 
476  if (INPUT_BUFFER == Object->Type)
477  {
479 
480  /* Only the presence of valid mode flags is allowed */
481  if (ConsoleMode & ~CONSOLE_VALID_INPUT_MODES)
482  {
484  }
485  else
486  {
487  InputBuffer->Mode = (ConsoleMode & CONSOLE_VALID_INPUT_MODES);
488  }
489  }
490  else if (TEXTMODE_BUFFER == Object->Type || GRAPHICS_BUFFER == Object->Type)
491  {
493 
494  /* Only the presence of valid mode flags is allowed */
495  if (ConsoleMode & ~CONSOLE_VALID_OUTPUT_MODES)
496  {
498  }
499  else
500  {
501  Buffer->Mode = (ConsoleMode & CONSOLE_VALID_OUTPUT_MODES);
502  }
503  }
504  else
505  {
507  }
508 
509  return Status;
510 }
#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:2966

◆ ConioPause()

VOID ConioPause ( PCONSRV_CONSOLE  Console,
UINT  Flags 
)

Definition at line 243 of file console.c.

244 {
245  Console->PauseFlags |= Flags;
247 }
VOID NTAPI ConDrvPause(PCONSOLE Console)
Definition: console.c:80
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
CConsole Console

Referenced by ConioProcessInputEvent(), GuiConsoleHandleScroll(), GuiConsoleUpdateSelection(), OnScroll(), PreprocessInput(), and UpdateSelection().

◆ ConioUnpause()

VOID ConioUnpause ( PCONSRV_CONSOLE  Console,
UINT  Flags 
)

Definition at line 250 of file console.c.

251 {
252  Console->PauseFlags &= ~Flags;
253 
254  // if ((Console->PauseFlags & (PAUSED_FROM_KEYBOARD | PAUSED_FROM_SCROLLBAR | PAUSED_FROM_SELECTION)) == 0)
255  if (Console->PauseFlags == 0)
256  {
258 
259  CsrNotifyWait(&Console->WriteWaitQueue,
260  TRUE,
261  NULL,
262  NULL);
263  if (!IsListEmpty(&Console->WriteWaitQueue))
264  {
265  CsrDereferenceWait(&Console->WriteWaitQueue);
266  }
267  }
268 }
#define TRUE
Definition: types.h:120
_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
VOID NTAPI ConDrvUnpause(PCONSOLE Console)
Definition: console.c:91
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI CsrDereferenceWait(IN PLIST_ENTRY WaitList)
Definition: wait.c:266
CConsole Console

Referenced by ConioProcessInputEvent(), GuiConsoleHandleScroll(), GuiConsoleUpdateSelection(), OnScroll(), PreprocessInput(), and UpdateSelection().

◆ ConsoleCreateUnicodeString()

static BOOLEAN ConsoleCreateUnicodeString ( IN OUT PUNICODE_STRING  UniDest,
IN PCWSTR  Source 
)
static

Definition at line 215 of file console.c.

217 {
218  SIZE_T Size = (wcslen(Source) + 1) * sizeof(WCHAR);
219  if (Size > MAXUSHORT) return FALSE;
220 
221  UniDest->Buffer = ConsoleAllocHeap(HEAP_ZERO_MEMORY, Size);
222  if (UniDest->Buffer == NULL) return FALSE;
223 
224  RtlCopyMemory(UniDest->Buffer, Source, Size);
225  UniDest->MaximumLength = (USHORT)Size;
226  UniDest->Length = (USHORT)Size - sizeof(WCHAR);
227 
228  return TRUE;
229 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned short USHORT
Definition: pedump.c:61
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MAXUSHORT
Definition: typedefs.h:81
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3167
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by ConSrvInitConsole().

◆ ConsoleFreeUnicodeString()

static VOID ConsoleFreeUnicodeString ( IN PUNICODE_STRING  UnicodeString)
static

Definition at line 233 of file console.c.

234 {
235  if (UnicodeString->Buffer)
236  {
239  }
240 }
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261

Referenced by ConSrvDeleteConsole(), and CSR_API().

◆ ConSrvConsoleCtrlEvent()

NTSTATUS ConSrvConsoleCtrlEvent ( IN ULONG  CtrlEvent,
IN PCONSOLE_PROCESS_DATA  ProcessData 
)

Definition at line 860 of file console.c.

862 {
863  return ConSrvConsoleCtrlEventTimeout(CtrlEvent, ProcessData, 0);
864 }
NTSTATUS ConSrvConsoleCtrlEventTimeout(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData, IN ULONG Timeout)
Definition: console.c:809

Referenced by ConSrvConsoleProcessCtrlEvent(), and ConSrvRemoveConsole().

◆ ConSrvConsoleCtrlEventTimeout()

NTSTATUS ConSrvConsoleCtrlEventTimeout ( IN ULONG  CtrlEvent,
IN PCONSOLE_PROCESS_DATA  ProcessData,
IN ULONG  Timeout 
)

Definition at line 809 of file console.c.

812 {
814 
815  DPRINT("ConSrvConsoleCtrlEventTimeout Parent ProcessId = %x\n", ProcessData->Process->ClientId.UniqueProcess);
816 
817  /*
818  * Be sure we effectively have a control routine. It resides in kernel32.dll (client).
819  */
820  if (ProcessData->CtrlRoutine == NULL) return Status;
821 
822  _SEH2_TRY
823  {
824  HANDLE Thread = NULL;
825 
826  _SEH2_TRY
827  {
828  Thread = CreateRemoteThread(ProcessData->Process->ProcessHandle, NULL, 0,
829  ProcessData->CtrlRoutine,
830  UlongToPtr(CtrlEvent), 0, NULL);
831  if (NULL == Thread)
832  {
834  DPRINT1("Failed thread creation, Status = 0x%08lx\n", Status);
835  }
836  else
837  {
838  DPRINT("ProcessData->CtrlRoutine remote thread creation succeeded, ProcessId = %x, Process = 0x%p\n",
839  ProcessData->Process->ClientId.UniqueProcess, ProcessData->Process);
841  }
842  }
844  {
846  }
847  _SEH2_END;
848  }
850  {
852  DPRINT1("ConSrvConsoleCtrlEventTimeout - Caught an exception, Status = 0x%08lx\n", Status);
853  }
854  _SEH2_END;
855 
856  return Status;
857 }
#define CloseHandle
Definition: compat.h:398
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4250
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define UlongToPtr(u)
Definition: config.h:106
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
static ULONG Timeout
Definition: ping.c:61
NTSTATUS NTAPI RtlGetLastNtStatus(VOID)
Definition: error.c:114
_SEH2_FINALLY
Definition: create.c:4395
#define DPRINT1
Definition: precomp.h:8
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2966
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:158

Referenced by ConSrvConsoleCtrlEvent(), and NotifyConsoleProcessForShutdown().

◆ ConSrvConsoleProcessCtrlEvent()

NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent ( IN PCONSRV_CONSOLE  Console,
IN ULONG  ProcessGroupId,
IN ULONG  CtrlEvent 
)

Definition at line 906 of file console.c.

909 {
911  PLIST_ENTRY current_entry;
913 
914  /* If the console is already being destroyed, just return */
916  return STATUS_UNSUCCESSFUL;
917 
918  /*
919  * Loop through the process list, from the most recent process
920  * (the active one) to the oldest one (the first created, i.e.
921  * the console leader process), and for each, send an event
922  * (new processes are inserted at the head of the console process list).
923  */
924  current_entry = Console->ProcessList.Flink;
925  while (current_entry != &Console->ProcessList)
926  {
927  current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink);
928  current_entry = current_entry->Flink;
929 
930  /*
931  * Only processes belonging to the same process group are signaled.
932  * If the process group ID is zero, then all the processes are signaled.
933  */
934  if (ProcessGroupId == 0 || current->Process->ProcessGroupId == ProcessGroupId)
935  {
936  Status = ConSrvConsoleCtrlEvent(CtrlEvent, current);
937  }
938  }
939 
940  return Status;
941 }
BOOLEAN NTAPI ConDrvValidateConsoleState(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState)
Definition: console.c:108
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS ConSrvConsoleCtrlEvent(IN ULONG CtrlEvent, IN PCONSOLE_PROCESS_DATA ProcessData)
Definition: console.c:860
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct task_struct * current
Definition: linux.c:32

Referenced by ConioProcessKey(), CSR_API(), and OnClose().

◆ ConSrvDeinitTerminal()

NTSTATUS NTAPI ConSrvDeinitTerminal ( IN OUT PTERMINAL  Terminal)

Definition at line 232 of file terminal.c.

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

Referenced by ConSrvInitConsole().

◆ ConSrvDeleteConsole()

VOID NTAPI ConSrvDeleteConsole ( PCONSRV_CONSOLE  Console)

Definition at line 771 of file console.c.

772 {
773  DPRINT("ConSrvDeleteConsole\n");
774 
775  // FIXME: Send a terminate message to all the processes owning this console
776 
777  /* Remove the console from the list */
779 
780  /* Destroy the Initialization Events */
781  NtClose(Console->InitEvents[INIT_FAILURE]);
782  NtClose(Console->InitEvents[INIT_SUCCESS]);
783 
784  /* Clean the Input Line Discipline */
785  if (Console->LineBuffer) ConsoleFreeHeap(Console->LineBuffer);
786 
787  /* Clean aliases and history */
790 
791  /* Free the console title */
792  ConsoleFreeUnicodeString(&Console->OriginalTitle);
794 
795  /* Now, call the driver. ConDrvDetachTerminal is called on-demand. */
797 
798  /* Deinit the ConSrv terminal */
799  // FIXME!!
800  // ConSrvDeinitTerminal(&Terminal);
801 }
VOID IntDeleteAllAliases(PCONSRV_CONSOLE Console)
Definition: alias.c:428
VOID HistoryDeleteBuffers(PCONSRV_CONSOLE Console)
Definition: history.c:313
static VOID ConsoleFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
Definition: console.c:233
static NTSTATUS RemoveConsoleByPointer(IN PCONSRV_CONSOLE Console)
Definition: console.c:141
VOID NTAPI ConDrvDeleteConsole(IN PCONSOLE Console)
Definition: console.c:327
void DPRINT(...)
Definition: polytest.cpp:61
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15

Referenced by ConSrvAllocateConsole(), and ConSrvReleaseConsole().

◆ ConSrvGetConsole()

NTSTATUS ConSrvGetConsole ( IN PCONSOLE_PROCESS_DATA  ProcessData,
OUT PCONSRV_CONSOLE Console,
IN BOOLEAN  LockConsole 
)

Definition at line 271 of file console.c.

274 {
276  PCONSRV_CONSOLE GrabConsole;
277 
278  // if (Console == NULL) return STATUS_INVALID_PARAMETER;
279  ASSERT(Console);
280  *Console = NULL;
281 
282  if (ConSrvValidateConsole(&GrabConsole,
283  ProcessData->ConsoleHandle,
285  LockConsole))
286  {
287  InterlockedIncrement(&GrabConsole->ReferenceCount);
288  *Console = GrabConsole;
290  }
291 
292  return Status;
293 }
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN NTAPI ConSrvValidateConsole(OUT PCONSRV_CONSOLE *Console, IN HANDLE ConsoleHandle, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:167
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
#define InterlockedIncrement
Definition: armddk.h:53
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by CSR_API(), and GetThreadConsoleDesktop().

◆ ConSrvGetConsoleLeaderProcess()

PCONSOLE_PROCESS_DATA NTAPI ConSrvGetConsoleLeaderProcess ( IN PCONSRV_CONSOLE  Console)

Definition at line 867 of file console.c.

868 {
869  if (Console == NULL) return NULL;
870 
871  return CONTAINING_RECORD(Console->ProcessList.Blink,
873  ConsoleLink);
874 }
smooth NULL
Definition: ftsmooth.c:416
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
CConsole Console

Referenced by ConSrvRemoveConsole(), GuiApplyUserSettings(), GuiConsoleShowConsoleProperties(), and SetConWndConsoleLeaderCID().

◆ ConSrvGetConsoleProcessList()

NTSTATUS NTAPI ConSrvGetConsoleProcessList ( IN PCONSRV_CONSOLE  Console,
IN OUT PULONG  ProcessIdsList,
IN ULONG  MaxIdListItems,
OUT PULONG  ProcessIdsTotal 
)

Definition at line 877 of file console.c.

881 {
883  PLIST_ENTRY current_entry;
884 
885  if (Console == NULL || ProcessIdsList == NULL || ProcessIdsTotal == NULL)
887 
888  *ProcessIdsTotal = 0;
889 
890  for (current_entry = Console->ProcessList.Flink;
891  current_entry != &Console->ProcessList;
892  current_entry = current_entry->Flink)
893  {
894  current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink);
895  if (++(*ProcessIdsTotal) <= MaxIdListItems)
896  {
897  *ProcessIdsList++ = HandleToUlong(current->Process->ClientId.UniqueProcess);
898  }
899  }
900 
901  return STATUS_SUCCESS;
902 }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define HandleToUlong(h)
Definition: basetsd.h:79
smooth NULL
Definition: ftsmooth.c:416
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
Definition: typedefs.h:117
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct task_struct * current
Definition: linux.c:32

Referenced by CSR_API().

◆ ConSrvInitConsole()

NTSTATUS NTAPI ConSrvInitConsole ( OUT PHANDLE  NewConsoleHandle,
OUT PCONSRV_CONSOLE NewConsole,
IN OUT PCONSOLE_INIT_INFO  ConsoleInitInfo,
IN PCSR_PROCESS  ConsoleLeaderProcess 
)

Definition at line 511 of file console.c.

515 {
517  HANDLE ConsoleHandle;
519 
520  BYTE ConsoleInfoBuffer[sizeof(CONSOLE_STATE_INFO) + MAX_PATH * sizeof(WCHAR)]; // CONSRV console information
522  CONSOLE_INFO DrvConsoleInfo; // Console information for CONDRV
523 
524  SIZE_T Length = 0;
525 
526  TERMINAL Terminal; /* The ConSrv terminal for this console */
527 
528  if (NewConsole == NULL || ConsoleInitInfo == NULL)
530 
531  *NewConsole = NULL;
532 
533  /*
534  * Load the console settings
535  */
536  RtlZeroMemory(ConsoleInfo, sizeof(ConsoleInfoBuffer));
537  ConsoleInfo->cbSize = sizeof(ConsoleInfoBuffer);
538 
539  /* 1. Get the title of the console (initialize ConsoleInfo->ConsoleTitle) */
540  Length = min(ConsoleInitInfo->TitleLength,
541  (ConsoleInfo->cbSize - FIELD_OFFSET(CONSOLE_STATE_INFO, ConsoleTitle) - sizeof(UNICODE_NULL)) / sizeof(WCHAR));
542  wcsncpy(ConsoleInfo->ConsoleTitle, ConsoleInitInfo->ConsoleTitle, Length);
543  ConsoleInfo->ConsoleTitle[Length] = UNICODE_NULL; // NULL-terminate it.
544 
545  /* 2. Impersonate the caller in order to retrieve settings in its context */
548 
549  /* 3. Load the default settings */
551 
552  /*
553  * 4. Load per-application terminal settings.
554  *
555  * Check whether the process creating the console was launched via
556  * a shell-link. ConsoleInfo->ConsoleTitle may be updated with the
557  * name of the shortcut, and ConsoleStartInfo->Icon[Path|Index] too.
558  */
559  // if (ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) // FIXME!! (for icon loading)
560  {
561  if (!LoadShellLinkConsoleInfo(ConsoleInfo, ConsoleInitInfo))
562  {
563  ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags &= ~STARTF_TITLEISLINKNAME;
564  }
565  }
566 
567  /*
568  * 5. Load the remaining console settings via the registry.
569  */
570  if ((ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
571  {
572  /*
573  * Either we weren't created by an app launched via a shell-link,
574  * or we failed to load shell-link console properties.
575  * Therefore, load the console infos for the application from the registry.
576  */
578 
579  /*
580  * Now, update them with the properties the user might gave to us
581  * via the STARTUPINFO structure before calling CreateProcess
582  * (and which was transmitted via the ConsoleStartInfo structure).
583  * We therefore overwrite the values read in the registry.
584  */
585  if (ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags & STARTF_USEFILLATTRIBUTE)
586  {
587  ConsoleInfo->ScreenAttributes = (USHORT)ConsoleInitInfo->ConsoleStartInfo->wFillAttribute;
588  }
589  if (ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags & STARTF_USECOUNTCHARS)
590  {
591  ConsoleInfo->ScreenBufferSize = ConsoleInitInfo->ConsoleStartInfo->dwScreenBufferSize;
592  }
593  if (ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags & STARTF_USESIZE)
594  {
595  ConsoleInfo->WindowSize = ConsoleInitInfo->ConsoleStartInfo->dwWindowSize;
596  }
597 
598 #if 0
599  /*
600  * Now, update them with the properties the user might gave to us
601  * via the STARTUPINFO structure before calling CreateProcess
602  * (and which was transmitted via the ConsoleStartInfo structure).
603  * We therefore overwrite the values read in the registry.
604  */
605  if (ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags & STARTF_USEPOSITION)
606  {
607  ConsoleInfo->AutoPosition = FALSE;
608  ConsoleInfo->WindowPosition.x = ConsoleInitInfo->ConsoleStartInfo->dwWindowOrigin.X;
609  ConsoleInfo->WindowPosition.y = ConsoleInitInfo->ConsoleStartInfo->dwWindowOrigin.Y;
610  }
611  if (ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags & STARTF_RUNFULLSCREEN)
612  {
613  ConsoleInfo->FullScreen = TRUE;
614  }
615 #endif
616  }
617 
618  /* 6. Revert impersonation */
619  CsrRevertToSelf();
620 
621  /* Set-up the code page */
622  ConsoleInfo->CodePage = GetOEMCP();
623 
624  /*
625  * Initialize the ConSrv terminal and give it a chance to load
626  * its own settings and override the console settings.
627  */
628  Status = ConSrvInitTerminal(&Terminal,
629  ConsoleInfo,
630  ConsoleInitInfo,
631  ConsoleLeaderProcess->ProcessHandle);
632  if (!NT_SUCCESS(Status))
633  {
634  DPRINT1("CONSRV: Failed to initialize a terminal, Status = 0x%08lx\n", Status);
635  return Status;
636  }
637  DPRINT("CONSRV: Terminal initialized\n");
638 
639  /* Initialize a new console via the driver */
640  // DrvConsoleInfo.InputBufferSize = 0;
641  DrvConsoleInfo.ScreenBufferSize = ConsoleInfo->ScreenBufferSize;
642  DrvConsoleInfo.ConsoleSize = ConsoleInfo->WindowSize;
643  DrvConsoleInfo.CursorSize = ConsoleInfo->CursorSize;
644  // DrvConsoleInfo.CursorBlinkOn = ConsoleInfo->CursorBlinkOn;
645  DrvConsoleInfo.ScreenAttrib = ConsoleInfo->ScreenAttributes;
646  DrvConsoleInfo.PopupAttrib = ConsoleInfo->PopupAttributes;
647  DrvConsoleInfo.CodePage = ConsoleInfo->CodePage;
648  Status = ConDrvInitConsole(&Console, &DrvConsoleInfo);
649  if (!NT_SUCCESS(Status))
650  {
651  DPRINT1("Creating a new console failed, Status = 0x%08lx\n", Status);
652  ConSrvDeinitTerminal(&Terminal);
653  return Status;
654  }
655 
656  ASSERT(Console);
657  DPRINT("Console initialized\n");
658 
659  /*** Register ConSrv features ***/
660 
661  /* Initialize the console title */
662 #if 0
663  WCHAR DefaultTitle[128];
664 #endif
665  ConsoleCreateUnicodeString(&Console->OriginalTitle, ConsoleInfo->ConsoleTitle);
666 #if 0
667  if (ConsoleInfo->ConsoleTitle[0] == UNICODE_NULL)
668  {
669  if (LoadStringW(ConSrvDllInstance, IDS_CONSOLE_TITLE, DefaultTitle, sizeof(DefaultTitle) / sizeof(DefaultTitle[0])))
670  {
671  ConsoleCreateUnicodeString(&Console->Title, DefaultTitle);
672  }
673  else
674  {
675  ConsoleCreateUnicodeString(&Console->Title, L"ReactOS Console");
676  }
677  }
678  else
679  {
680 #endif
681  ConsoleCreateUnicodeString(&Console->Title, ConsoleInfo->ConsoleTitle);
682 #if 0
683  }
684 #endif
685 
686  /* Initialize process support */
687  InitializeListHead(&Console->ProcessList);
688  Console->NotifiedLastCloseProcess = NULL;
689  Console->NotifyLastClose = FALSE;
690  Console->HasFocus = FALSE;
691 
692  /* Initialize pausing support */
693  Console->PauseFlags = 0;
694  InitializeListHead(&Console->ReadWaitQueue);
695  InitializeListHead(&Console->WriteWaitQueue);
696 
697  /* Initialize the alias and history buffers */
698  Console->Aliases = NULL;
699  InitializeListHead(&Console->HistoryBuffers);
700  Console->HistoryBufferSize = ConsoleInfo->HistoryBufferSize;
701  Console->NumberOfHistoryBuffers = ConsoleInfo->NumberOfHistoryBuffers;
702  Console->HistoryNoDup = ConsoleInfo->HistoryNoDup;
703 
704  /* Initialize the Input Line Discipline */
705  Console->LineBuffer = NULL;
706  Console->LinePos = Console->LineMaxSize = Console->LineSize = 0;
707  Console->LineComplete = Console->LineUpPressed = FALSE;
708  // LineWakeupMask
709  Console->LineInsertToggle =
710  Console->InsertMode = ConsoleInfo->InsertMode;
711  Console->QuickEdit = ConsoleInfo->QuickEdit;
712 
713  /* Popup windows */
714  InitializeListHead(&Console->PopupWindows);
715 
716  /* Colour table */
717  RtlCopyMemory(Console->Colors, ConsoleInfo->ColorTable,
718  sizeof(ConsoleInfo->ColorTable));
719 
720  /* Create the Initialization Events */
723  if (!NT_SUCCESS(Status))
724  {
725  DPRINT1("NtCreateEvent(InitEvents[INIT_SUCCESS]) failed: %lu\n", Status);
727  ConSrvDeinitTerminal(&Terminal);
728  return Status;
729  }
732  if (!NT_SUCCESS(Status))
733  {
734  DPRINT1("NtCreateEvent(InitEvents[INIT_FAILURE]) failed: %lu\n", Status);
735  NtClose(Console->InitEvents[INIT_SUCCESS]);
737  ConSrvDeinitTerminal(&Terminal);
738  return Status;
739  }
740 
741  /*
742  * Attach the ConSrv terminal to the console.
743  * This call makes a copy of our local Terminal variable.
744  */
745  Status = ConDrvAttachTerminal(Console, &Terminal);
746  if (!NT_SUCCESS(Status))
747  {
748  DPRINT1("Failed to register terminal to the given console, Status = 0x%08lx\n", Status);
749  NtClose(Console->InitEvents[INIT_FAILURE]);
750  NtClose(Console->InitEvents[INIT_SUCCESS]);
752  ConSrvDeinitTerminal(&Terminal);
753  return Status;
754  }
755  DPRINT("Terminal attached\n");
756 
757  /* All went right, so add the console to the list */
758  Status = InsertConsole(&ConsoleHandle, Console);
759 
760  // FIXME! We do not support at all asynchronous console creation!
761  NtSetEvent(Console->InitEvents[INIT_SUCCESS], NULL);
762  // NtSetEvent(Console->InitEvents[INIT_FAILURE], NULL);
763 
764  /* Return the newly created console to the caller and a success code too */
765  *NewConsoleHandle = ConsoleHandle;
766  *NewConsole = Console;
767  return STATUS_SUCCESS;
768 }
VOID ConCfgGetDefaultSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo)
Definition: settings.c:491
#define STARTF_RUNFULLSCREEN
Definition: winbase.h:477
COORD ConsoleSize
Definition: conio.h:209
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define IDS_CONSOLE_TITLE
Definition: resource.h:10
#define STATUS_BAD_IMPERSONATION_LEVEL
Definition: ntstatus.h:387
COORD ScreenBufferSize
Definition: conio.h:208
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_STATE_INFO CONSOLE_STATE_INFO
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1048
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 STARTF_USEFILLATTRIBUTE
Definition: winbase.h:476
#define STARTF_USEPOSITION
Definition: winbase.h:474
#define PCONSRV_CONSOLE
Definition: conio.h:27
USHORT PopupAttrib
Definition: conio.h:216
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static BOOLEAN ConsoleCreateUnicodeString(IN OUT PUNICODE_STRING UniDest, IN PCWSTR Source)
Definition: console.c:215
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
VOID NTAPI ConDrvDeleteConsole(IN PCONSOLE Console)
Definition: console.c:327
static NTSTATUS InsertConsole(OUT PHANDLE Handle, IN PCONSRV_CONSOLE Console)
Definition: console.c:46
#define UNICODE_NULL
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
ULONG CodePage
Definition: conio.h:218
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
struct _CONSOLE_STATE_INFO * PCONSOLE_STATE_INFO
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:458
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define MAX_PATH
Definition: compat.h:26
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
NTSTATUS NTAPI ConDrvAttachTerminal(IN PCONSOLE Console, IN PTERMINAL Terminal)
Definition: console.c:269
unsigned char BYTE
Definition: mem.h:68
BOOLEAN ConCfgReadUserSettings(IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN BOOLEAN DefaultSettings)
Definition: settings.c:167
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
USHORT ScreenAttrib
Definition: conio.h:215
#define STARTF_USECOUNTCHARS
Definition: winbase.h:475
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
unsigned short USHORT
Definition: pedump.c:61
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define min(a, b)
Definition: monoChain.cc:55
#define STARTF_USESIZE
Definition: winbase.h:473
ULONG CursorSize
Definition: conio.h:211
CConsole Console
#define DPRINT1
Definition: precomp.h:8
HINSTANCE ConSrvDllInstance
Definition: init.c:21
NTSTATUS NTAPI ConDrvInitConsole(OUT PCONSOLE *NewConsole, IN PCONSOLE_INFO ConsoleInfo)
Definition: console.c:163
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:925
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966
static BOOL LoadShellLinkConsoleInfo(IN OUT PCONSOLE_STATE_INFO ConsoleInfo, IN OUT PCONSOLE_INIT_INFO ConsoleInitInfo)
Definition: console.c:349
NTSTATUS NTAPI ConSrvDeinitTerminal(IN OUT PTERMINAL Terminal)
Definition: terminal.c:232
UINT WINAPI GetOEMCP(VOID)
Definition: nls.c:2184

Referenced by ConSrvAllocateConsole().

◆ ConSrvInitConsoleSupport()

VOID NTAPI ConSrvInitConsoleSupport ( VOID  )

Definition at line 327 of file console.c.

328 {
329  DPRINT("CONSRV: ConSrvInitConsoleSupport()\n");
330 
331  /* Initialize the console list and its lock */
332  ConsoleListSize = 0;
333  ConsoleList = NULL;
335 
336  /* Should call LoadKeyboardLayout */
337 }
static PCONSRV_CONSOLE * ConsoleList
Definition: console.c:32
static ULONG ConsoleListSize
Definition: console.c:31
static RTL_RESOURCE ListLock
Definition: console.c:33
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
NTSYSAPI VOID NTAPI RtlInitializeResource(_In_ PRTL_RESOURCE Resource)

Referenced by CSR_SERVER_DLL_INIT().

◆ ConSrvInitTerminal()

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

Definition at line 199 of file terminal.c.

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

Referenced by ConSrvInitConsole().

◆ ConSrvReleaseConsole()

VOID ConSrvReleaseConsole ( IN PCONSRV_CONSOLE  Console,
IN BOOLEAN  IsConsoleLocked 
)

Definition at line 296 of file console.c.

298 {
299  LONG RefCount = 0;
300 
301  if (!Console) return;
302  // if (Console->ReferenceCount == 0) return; // This shouldn't happen
303  ASSERT(Console->ReferenceCount > 0);
304 
305  /* The console must be locked */
306  // ASSERT(Console_locked);
307 
308  /*
309  * Decrement the reference count. Save the new value too,
310  * because Console->ReferenceCount might be modified after
311  * the console gets unlocked but before we check whether we
312  * can destroy it.
313  */
314  RefCount = _InterlockedDecrement(&Console->ReferenceCount);
315 
316  /* Unlock the console if needed */
317  if (IsConsoleLocked) LeaveCriticalSection(&Console->Lock);
318 
319  /* Delete the console if needed */
320  if (RefCount <= 0) ConSrvDeleteConsole(Console);
321 }
long LONG
Definition: pedump.c:60
long __cdecl _InterlockedDecrement(_Interlocked_operand_ long volatile *_Addend)
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI ConSrvDeleteConsole(PCONSRV_CONSOLE Console)
Definition: console.c:771
CConsole Console
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by ConSrvReleaseObject(), ConSrvRemoveConsole(), CSR_API(), and GetThreadConsoleDesktop().

◆ ConSrvSetConsoleProcessFocus()

NTSTATUS NTAPI ConSrvSetConsoleProcessFocus ( IN PCONSRV_CONSOLE  Console,
IN BOOLEAN  SetForeground 
)

Definition at line 957 of file console.c.

959 {
960  PLIST_ENTRY current_entry;
962 
963  /* If the console is already being destroyed, just return */
965  return STATUS_UNSUCCESSFUL;
966 
967  /*
968  * Loop through the process list, from the most recent process
969  * to the oldest one, and for each, set its foreground priority.
970  */
971  current_entry = Console->ProcessList.Flink;
972  while (current_entry != &Console->ProcessList)
973  {
974  current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink);
975  current_entry = current_entry->Flink;
976 
977  ConSrvSetProcessFocus(current->Process, SetForeground);
978  }
979 
980  return STATUS_SUCCESS;
981 }
BOOLEAN NTAPI ConDrvValidateConsoleState(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState)
Definition: console.c:108
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Definition: typedefs.h:117
CConsole Console
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct task_struct * current
Definition: linux.c:32
VOID ConSrvSetProcessFocus(IN PCSR_PROCESS CsrProcess, IN BOOLEAN SetForeground)
Definition: console.c:944

Referenced by OnFocus().

◆ ConSrvSetProcessFocus()

VOID ConSrvSetProcessFocus ( IN PCSR_PROCESS  CsrProcess,
IN BOOLEAN  SetForeground 
)

Definition at line 944 of file console.c.

946 {
947  // FIXME: Call NtUserSetInformationProcess (currently unimplemented!)
948  // for setting Win32 foreground/background flags.
949 
950  if (SetForeground)
951  CsrSetForegroundPriority(CsrProcess);
952  else
953  CsrSetBackgroundPriority(CsrProcess);
954 }
VOID NTAPI CsrSetForegroundPriority(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1129
VOID NTAPI CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1098

Referenced by ConSrvAllocateConsole(), ConSrvInheritConsole(), and ConSrvSetConsoleProcessFocus().

◆ ConSrvValidateConsole()

BOOLEAN NTAPI ConSrvValidateConsole ( OUT PCONSRV_CONSOLE Console,
IN HANDLE  ConsoleHandle,
IN CONSOLE_STATE  ExpectedState,
IN BOOLEAN  LockConsole 
)

Definition at line 167 of file console.c.

171 {
172  BOOLEAN RetVal = FALSE;
173  PCONSRV_CONSOLE ValidatedConsole;
174 
175  BOOLEAN ValidHandle = ((HandleToULong(ConsoleHandle) & 0x3) == 0x3);
176  ULONG Index = HandleToULong(ConsoleHandle) >> 2;
177 
178  if (!ValidHandle) return FALSE;
179 
180  if (!Console) return FALSE;
181  *Console = NULL;
182 
183  /*
184  * Forbid creation or deletion of consoles when
185  * checking for the existence of a console.
186  */
188 
189  if (Index >= ConsoleListSize ||
190  (ValidatedConsole = ConsoleList[Index]) == NULL)
191  {
192  /* Unlock the console list and return */
194  return FALSE;
195  }
196 
197  ValidatedConsole = ConsoleList[Index];
198 
199  /* Unlock the console list and return */
201 
202  RetVal = ConDrvValidateConsoleUnsafe((PCONSOLE)ValidatedConsole,
203  ExpectedState,
204  LockConsole);
205  if (RetVal) *Console = ValidatedConsole;
206 
207  return RetVal;
208 }
static PCONSRV_CONSOLE * ConsoleList
Definition: console.c:32
static ULONG ConsoleListSize
Definition: console.c:31
#define HandleToULong(h)
Definition: basetsd.h:95
#define PCONSRV_CONSOLE
Definition: conio.h:27
#define ConSrvLockConsoleListShared()
Definition: console.c:38
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
static const UCHAR Index[8]
Definition: usbohci.c:18
BOOLEAN NTAPI ConDrvValidateConsoleUnsafe(IN PCONSOLE Console, IN CONSOLE_STATE ExpectedState, IN BOOLEAN LockConsole)
Definition: console.c:120
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
#define ConSrvUnlockConsoleList()
Definition: console.c:41

Referenced by ConSrvGetConsole(), ConSrvInheritConsole(), ConSrvNewProcess(), and ConSrvRemoveConsole().

◆ CSR_API() [1/22]

CSR_API ( SrvAllocConsole  )

Definition at line 986 of file console.c.

987 {
989  PCONSOLE_ALLOCCONSOLE AllocConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.AllocConsoleRequest;
990  PCSR_PROCESS CsrProcess = CsrGetClientThread()->Process;
991  PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrProcess);
992  CONSOLE_INIT_INFO ConsoleInitInfo;
993 
994  if (ProcessData->ConsoleHandle != NULL)
995  {
996  DPRINT1("Process already has a console\n");
997  return STATUS_ACCESS_DENIED;
998  }
999 
1000  if ( !CsrValidateMessageBuffer(ApiMessage,
1001  (PVOID*)&AllocConsoleRequest->ConsoleStartInfo,
1002  1,
1003  sizeof(CONSOLE_START_INFO)) ||
1004  !CsrValidateMessageBuffer(ApiMessage,
1005  (PVOID*)&AllocConsoleRequest->ConsoleTitle,
1006  AllocConsoleRequest->TitleLength,
1007  sizeof(BYTE)) ||
1008  !CsrValidateMessageBuffer(ApiMessage,
1009  (PVOID*)&AllocConsoleRequest->Desktop,
1010  AllocConsoleRequest->DesktopLength,
1011  sizeof(BYTE)) ||
1012  !CsrValidateMessageBuffer(ApiMessage,
1013  (PVOID*)&AllocConsoleRequest->CurDir,
1014  AllocConsoleRequest->CurDirLength,
1015  sizeof(BYTE)) ||
1016  !CsrValidateMessageBuffer(ApiMessage,
1017  (PVOID*)&AllocConsoleRequest->AppName,
1018  AllocConsoleRequest->AppNameLength,
1019  sizeof(BYTE)) )
1020  {
1021  return STATUS_INVALID_PARAMETER;
1022  }
1023 
1024  /* Initialize the console initialization info structure */
1025  ConsoleInitInfo.ConsoleStartInfo = AllocConsoleRequest->ConsoleStartInfo;
1026  ConsoleInitInfo.IsWindowVisible = TRUE; // The console window is always visible.
1027  ConsoleInitInfo.TitleLength = AllocConsoleRequest->TitleLength;
1028  ConsoleInitInfo.ConsoleTitle = AllocConsoleRequest->ConsoleTitle;
1029  ConsoleInitInfo.DesktopLength = AllocConsoleRequest->DesktopLength;
1030  ConsoleInitInfo.Desktop = AllocConsoleRequest->Desktop;
1031  ConsoleInitInfo.AppNameLength = AllocConsoleRequest->AppNameLength;
1032  ConsoleInitInfo.AppName = AllocConsoleRequest->AppName;
1033  ConsoleInitInfo.CurDirLength = AllocConsoleRequest->CurDirLength;
1034  ConsoleInitInfo.CurDir = AllocConsoleRequest->CurDir;
1035 
1036  /* Initialize a new Console owned by the Console Leader Process */
1037  Status = ConSrvAllocateConsole(ProcessData,
1038  &AllocConsoleRequest->ConsoleStartInfo->InputHandle,
1039  &AllocConsoleRequest->ConsoleStartInfo->OutputHandle,
1040  &AllocConsoleRequest->ConsoleStartInfo->ErrorHandle,
1041  &ConsoleInitInfo);
1042  if (!NT_SUCCESS(Status))
1043  {
1044  DPRINT1("Console allocation failed\n");
1045  return Status;
1046  }
1047 
1048  /* Set the Property-Dialog and Control-Dispatcher handlers */
1049  ProcessData->PropRoutine = AllocConsoleRequest->PropRoutine;
1050  ProcessData->CtrlRoutine = AllocConsoleRequest->CtrlRoutine;
1051 
1052  return STATUS_SUCCESS;
1053 }
HANDLE OutputHandle
Definition: conmsg.h:173
HANDLE ErrorHandle
Definition: conmsg.h:174
HANDLE ConsoleHandle
Definition: consrv.h:45
PWCHAR Desktop
Definition: console.h:19
PCONSOLE_START_INFO ConsoleStartInfo
Definition: console.h:13
#define CsrGetClientThread()
Definition: csrsrv.h:77
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:286
#define TRUE
Definition: types.h:120
ULONG CurDirLength
Definition: console.h:22
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: consrv.h:52
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:285
ULONG AppNameLength
Definition: console.h:20
PWCHAR AppName
Definition: console.h:21
ULONG TitleLength
Definition: console.h:16
smooth NULL
Definition: ftsmooth.c:416
PWCHAR ConsoleTitle
Definition: console.h:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
LPTHREAD_START_ROUTINE PropRoutine
Definition: consrv.h:53
unsigned char BYTE
Definition: mem.h:68
ULONG DesktopLength
Definition: console.h:18
Status
Definition: gdiplustypes.h:24
BOOLEAN IsWindowVisible
Definition: console.h:14
HANDLE InputHandle
Definition: conmsg.h:172
#define DPRINT1
Definition: precomp.h:8
NTSTATUS ConSrvAllocateConsole(PCONSOLE_PROCESS_DATA ProcessData, PHANDLE pInputHandle, PHANDLE pOutputHandle, PHANDLE pErrorHandle, PCONSOLE_INIT_INFO ConsoleInitInfo)
Definition: handle.c:474
return STATUS_SUCCESS
Definition: btrfs.c:2966
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:274

◆ CSR_API() [2/22]

CSR_API ( SrvAttachConsole  )

Definition at line 1055 of file console.c.

1056 {
1058  PCONSOLE_ATTACHCONSOLE AttachConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.AttachConsoleRequest;
1059  PCSR_PROCESS SourceProcess = NULL; // The parent process.
1060  PCSR_PROCESS TargetProcess = CsrGetClientThread()->Process; // Ourselves.
1061  HANDLE ProcessId = ULongToHandle(AttachConsoleRequest->ProcessId);
1062  PCONSOLE_PROCESS_DATA SourceProcessData, TargetProcessData;
1063 
1064  TargetProcessData = ConsoleGetPerProcessData(TargetProcess);
1065 
1066  if (TargetProcessData->ConsoleHandle != NULL)
1067  {
1068  DPRINT1("Process already has a console\n");
1069  return STATUS_ACCESS_DENIED;
1070  }
1071 
1072  if (!CsrValidateMessageBuffer(ApiMessage,
1073  (PVOID*)&AttachConsoleRequest->ConsoleStartInfo,
1074  1,
1075  sizeof(CONSOLE_START_INFO)))
1076  {
1077  return STATUS_INVALID_PARAMETER;
1078  }
1079 
1080  /* Check whether we try to attach to the parent's console */
1081  if (ProcessId == ULongToHandle(ATTACH_PARENT_PROCESS))
1082  {
1083  PROCESS_BASIC_INFORMATION ProcessInfo;
1084  ULONG Length = sizeof(ProcessInfo);
1085 
1086  /* Get the real parent's PID */
1087 
1090  &ProcessInfo,
1091  Length, &Length);
1092  if (!NT_SUCCESS(Status))
1093  {
1094  DPRINT1("SrvAttachConsole - Cannot retrieve basic process info, Status = 0x%08lx\n", Status);
1095  return Status;
1096  }
1097 
1099  }
1100 
1101  /* Lock the source process via its PID */
1102  Status = CsrLockProcessByClientId(ProcessId, &SourceProcess);
1103  if (!NT_SUCCESS(Status)) return Status;
1104 
1105  SourceProcessData = ConsoleGetPerProcessData(SourceProcess);
1106 
1107  if (SourceProcessData->ConsoleHandle == NULL)
1108  {
1110  goto Quit;
1111  }
1112 
1113  /*
1114  * Inherit the console from the parent,
1115  * if any, otherwise return an error.
1116  */
1117  Status = ConSrvInheritConsole(TargetProcessData,
1118  SourceProcessData->ConsoleHandle,
1119  TRUE,
1120  &AttachConsoleRequest->ConsoleStartInfo->InputHandle,
1121  &AttachConsoleRequest->ConsoleStartInfo->OutputHandle,
1122  &AttachConsoleRequest->ConsoleStartInfo->ErrorHandle,
1123  AttachConsoleRequest->ConsoleStartInfo);
1124  if (!NT_SUCCESS(Status))
1125  {
1126  DPRINT1("Console inheritance failed\n");
1127  goto Quit;
1128  }
1129 
1130  /* Set the Property-Dialog and Control-Dispatcher handlers */
1131  TargetProcessData->PropRoutine = AttachConsoleRequest->PropRoutine;
1132  TargetProcessData->CtrlRoutine = AttachConsoleRequest->CtrlRoutine;
1133 
1135 
1136 Quit:
1137  /* Unlock the "source" process and exit */
1138  CsrUnlockProcess(SourceProcess);
1139  return Status;
1140 }
HANDLE OutputHandle
Definition: conmsg.h:173
HANDLE ErrorHandle
Definition: conmsg.h:174
HANDLE ConsoleHandle
Definition: consrv.h:45
#define ULongToHandle(h)
Definition: basetsd.h:81
#define CsrGetClientThread()
Definition: csrsrv.h:77
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define TRUE
Definition: types.h:120
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:299
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: consrv.h:52
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI NtQueryInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, OUT PVOID ProcessInformation, IN ULONG ProcessInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:59
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
NTSTATUS ConSrvInheritConsole(PCONSOLE_PROCESS_DATA ProcessData, HANDLE ConsoleHandle, BOOLEAN CreateNewHandlesTable, PHANDLE pInputHandle, PHANDLE pOutputHandle, PHANDLE pErrorHandle, PCONSOLE_START_INFO ConsoleStartInfo)
Definition: handle.c:605
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
HANDLE ProcessHandle
Definition: csrsrv.h:46
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI CsrLockProcessByClientId(IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess OPTIONAL)
ULONG_PTR InheritedFromUniqueProcessId
Definition: pstypes.h:340
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LPTHREAD_START_ROUTINE PropRoutine
Definition: consrv.h:53
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:300
Status
Definition: gdiplustypes.h:24
HANDLE InputHandle
Definition: conmsg.h:172
#define DPRINT1
Definition: precomp.h:8
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:297
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1398

◆ CSR_API() [3/22]

CSR_API ( SrvFreeConsole  )

Definition at line 1142 of file console.c.

1143 {
1145 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
NTSTATUS ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData)
Definition: handle.c:735
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ CSR_API() [4/22]

CSR_API ( SrvGetConsoleMode  )

Definition at line 1151 of file console.c.

1152 {
1153  NTSTATUS Status;
1154  PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
1156 
1157  PULONG ConsoleMode = &ConsoleModeRequest->Mode;
1158 
1160  ConsoleModeRequest->Handle,
1161  &Object, NULL, GENERIC_READ, TRUE, 0);
1162  if (!NT_SUCCESS(Status)) return Status;
1163 
1164  /* Get the standard console modes */
1166  ConsoleMode);
1167  if (NT_SUCCESS(Status))
1168  {
1169  /*
1170  * If getting the console modes succeeds, then retrieve
1171  * the extended CONSRV-specific input modes.
1172  */
1173  if (INPUT_BUFFER == Object->Type)
1174  {
1175  if (Object->Console->InsertMode || Object->Console->QuickEdit)
1176  {
1177  /* Windows also adds ENABLE_EXTENDED_FLAGS, even if it's not documented on MSDN */
1178  *ConsoleMode |= ENABLE_EXTENDED_FLAGS;
1179 
1180  if (Object->Console->InsertMode) *ConsoleMode |= ENABLE_INSERT_MODE;
1181  if (Object->Console->QuickEdit ) *ConsoleMode |= ENABLE_QUICK_EDIT_MODE;
1182  }
1183  }
1184  }
1185 
1187  return Status;
1188 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ConDrvGetConsoleMode(IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, OUT PULONG ConsoleMode)
Definition: console.c:426
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
static IUnknown Object
Definition: main.c:512
#define GENERIC_READ
Definition: compat.h:124
Status
Definition: gdiplustypes.h:24
NTSTATUS ConSrvGetObject(IN PCONSOLE_PROCESS_DATA ProcessData, IN HANDLE Handle, OUT PCONSOLE_IO_OBJECT *Object, OUT PVOID *Entry OPTIONAL, IN ULONG Access, IN BOOLEAN LockConsole, IN CONSOLE_IO_OBJECT_TYPE Type)
Definition: handle.c:401
#define ENABLE_INSERT_MODE
Definition: wincon.h:80
#define ENABLE_EXTENDED_FLAGS
Definition: wincon.h:82
unsigned int * PULONG
Definition: retypes.h:1
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID ConSrvReleaseObject(IN PCONSOLE_IO_OBJECT Object, IN BOOLEAN IsConsoleLocked)
Definition: handle.c:465
#define ENABLE_QUICK_EDIT_MODE
Definition: wincon.h:81

◆ CSR_API() [5/22]

CSR_API ( SrvSetConsoleMode  )

Definition at line 1194 of file console.c.

1195 {
1196 #define CONSOLE_VALID_CONTROL_MODES ( ENABLE_EXTENDED_FLAGS | \
1197  ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE )
1198 
1199  NTSTATUS Status;
1200  PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
1202 
1203  ULONG ConsoleMode = ConsoleModeRequest->Mode;
1204 
1206  ConsoleModeRequest->Handle,
1207  &Object, NULL, GENERIC_WRITE, TRUE, 0);
1208  if (!NT_SUCCESS(Status)) return Status;
1209 
1210  /* Set the standard console modes (without the CONSRV-specific input modes) */
1211  ConsoleMode &= ~CONSOLE_VALID_CONTROL_MODES; // Remove CONSRV-specific input modes.
1213  ConsoleMode);
1214  if (NT_SUCCESS(Status))
1215  {
1216  /*
1217  * If setting the console modes succeeds, then set
1218  * the extended CONSRV-specific input modes.
1219  */
1220  if (INPUT_BUFFER == Object->Type)
1221  {
1222  ConsoleMode = ConsoleModeRequest->Mode;
1223 
1224  if (ConsoleMode & CONSOLE_VALID_CONTROL_MODES)
1225  {
1226  /*
1227  * If we use control mode flags without ENABLE_EXTENDED_FLAGS,
1228  * then consider the flags invalid.
1229  */
1230  if ((ConsoleMode & ENABLE_EXTENDED_FLAGS) == 0)
1231  {
1233  }
1234  else
1235  {
1236  Object->Console->InsertMode = !!(ConsoleMode & ENABLE_INSERT_MODE);
1237  Object->Console->QuickEdit = !!(ConsoleMode & ENABLE_QUICK_EDIT_MODE);
1238  }
1239  }
1240  }
1241  }
1242 
1244  return Status;
1245 }
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI ConDrvSetConsoleMode(IN PCONSOLE Console, IN PCONSOLE_IO_OBJECT Object, IN ULONG ConsoleMode)
Definition: console.c:459
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define CONSOLE_VALID_CONTROL_MODES
static IUnknown Object
Definition: main.c:512
Status
Definition: gdiplustypes.h:24
NTSTATUS ConSrvGetObject(IN PCONSOLE_PROCESS_DATA ProcessData, IN HANDLE Handle, OUT PCONSOLE_IO_OBJECT *Object, OUT PVOID *Entry OPTIONAL, IN ULONG Access, IN BOOLEAN LockConsole, IN CONSOLE_IO_OBJECT_TYPE Type)
Definition: handle.c:401
#define ENABLE_INSERT_MODE
Definition: wincon.h:80
#define ENABLE_EXTENDED_FLAGS
Definition: wincon.h:82
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
VOID ConSrvReleaseObject(IN PCONSOLE_IO_OBJECT Object, IN BOOLEAN IsConsoleLocked)
Definition: handle.c:465
unsigned int ULONG
Definition: retypes.h:1
#define ENABLE_QUICK_EDIT_MODE
Definition: wincon.h:81

◆ CSR_API() [6/22]

CSR_API ( SrvGetConsoleTitle  )

Definition at line 1247 of file console.c.

1248 {
1249  NTSTATUS Status;
1250  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
1252  ULONG Length;
1253 
1254  if (!CsrValidateMessageBuffer(ApiMessage,
1255  (PVOID)&TitleRequest->Title,
1256  TitleRequest->Length,
1257  sizeof(BYTE)))
1258  {
1259  return STATUS_INVALID_PARAMETER;
1260  }
1261 
1263  if (!NT_SUCCESS(Status))
1264  {
1265  DPRINT1("Can't get console, status %lx\n", Status);
1266  return Status;
1267  }
1268 
1269  /* Copy title of the console to the user title buffer */
1270  if (TitleRequest->Unicode)
1271  {
1272  if (TitleRequest->Length >= sizeof(WCHAR))
1273  {
1274  Length = min(TitleRequest->Length - sizeof(WCHAR), Console->Title.Length);
1275  RtlCopyMemory(TitleRequest->Title, Console->Title.Buffer, Length);
1276  ((PWCHAR)TitleRequest->Title)[Length / sizeof(WCHAR)] = UNICODE_NULL;
1277  TitleRequest->Length = Length;
1278  }
1279  else
1280  {
1281  TitleRequest->Length = Console->Title.Length;
1282  }
1283  }
1284  else
1285  {
1286  if (TitleRequest->Length >= sizeof(CHAR))
1287  {
1288  Length = min(TitleRequest->Length - sizeof(CHAR), Console->Title.Length / sizeof(WCHAR));
1289  Length = WideCharToMultiByte(Console->InputCodePage, 0,
1290  Console->Title.Buffer, Length,
1291  TitleRequest->Title, Length,
1292  NULL, NULL);
1293  ((PCHAR)TitleRequest->Title)[Length] = ANSI_NULL;
1294  TitleRequest->Length = Length;
1295  }
1296  else
1297  {
1298  TitleRequest->Length = Console->Title.Length / sizeof(WCHAR);
1299  }
1300  }
1301 
1303  return Status;
1304 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define WideCharToMultiByte
Definition: compat.h:101
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
char CHAR
Definition: xmlstorage.h:175
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
uint16_t * PWCHAR
Definition: typedefs.h:54
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define UNICODE_NULL
#define ANSI_NULL
smooth NULL
Definition: ftsmooth.c:416
#define PCHAR
Definition: match.c:90
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
#define min(a, b)
Definition: monoChain.cc:55
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1

◆ CSR_API() [7/22]

CSR_API ( SrvSetConsoleTitle  )

Definition at line 1306 of file console.c.

1307 {
1308  NTSTATUS Status;
1309  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
1311 
1312  PWCHAR Buffer;
1313  ULONG Length;
1314 
1315  if (!CsrValidateMessageBuffer(ApiMessage,
1316  (PVOID)&TitleRequest->Title,
1317  TitleRequest->Length,
1318  sizeof(BYTE)))
1319  {
1320  return STATUS_INVALID_PARAMETER;
1321  }
1322 
1324  if (!NT_SUCCESS(Status))
1325  {
1326  DPRINT1("Can't get console, status %lx\n", Status);
1327  return Status;
1328  }
1329 
1330  if (TitleRequest->Unicode)
1331  {
1332  /* Length is in bytes */
1333  Length = TitleRequest->Length;
1334  }
1335  else
1336  {
1337  /* Use the console input CP for the conversion */
1338  Length = MultiByteToWideChar(Console->InputCodePage, 0,
1339  TitleRequest->Title, TitleRequest->Length,
1340  NULL, 0);
1341  /* The returned Length was in number of wchars, convert it in bytes */
1342  Length *= sizeof(WCHAR);
1343  }
1344 
1345  /* Allocate a new buffer to hold the new title (NULL-terminated) */
1347  if (!Buffer)
1348  {
1350  goto Quit;
1351  }
1352 
1353  /* Free the old title */
1355 
1356  /* Copy title to console */
1357  Console->Title.Buffer = Buffer;
1358  Console->Title.Length = Length;
1359  Console->Title.MaximumLength = Console->Title.Length + sizeof(WCHAR);
1360 
1361  if (TitleRequest->Unicode)
1362  {
1363  RtlCopyMemory(Console->Title.Buffer, TitleRequest->Title, Console->Title.Length);
1364  }
1365  else
1366  {
1367  MultiByteToWideChar(Console->InputCodePage, 0,
1368  TitleRequest->Title, TitleRequest->Length,
1369  Console->Title.Buffer,
1370  Console->Title.Length / sizeof(WCHAR));
1371  }
1372 
1373  /* NULL-terminate */
1374  Console->Title.Buffer[Console->Title.Length / sizeof(WCHAR)] = UNICODE_NULL;
1375 
1378 
1379 Quit:
1381  return Status;
1382 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
static VOID ConsoleFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
Definition: console.c:233
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
uint16_t * PWCHAR
Definition: typedefs.h:54
#define TermChangeTitle(Console)
Definition: term.h:46
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned char BYTE
Definition: mem.h:68
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
CConsole Console
#define DPRINT1
Definition: precomp.h:8
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ CSR_API() [8/22]

CSR_API ( SrvGetConsoleCP  )

Definition at line 1388 of file console.c.

1389 {
1390  NTSTATUS Status;
1391  PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleCPRequest;
1393 
1394  DPRINT("SrvGetConsoleCP, getting %s Code Page\n",
1395  GetConsoleCPRequest->OutputCP ? "Output" : "Input");
1396 
1398  if (!NT_SUCCESS(Status)) return Status;
1399 
1401  &GetConsoleCPRequest->CodePage,
1402  GetConsoleCPRequest->OutputCP);
1403 
1405  return Status;
1406 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvGetConsoleCP(IN PCONSOLE Console, OUT PUINT CodePage, IN BOOLEAN OutputCP)
Definition: console.c:513
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ CSR_API() [9/22]

CSR_API ( SrvSetConsoleCP  )

Definition at line 1412 of file console.c.

1413 {
1415  PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetConsoleCPRequest;
1417 
1418  DPRINT("SrvSetConsoleCP, setting %s Code Page\n",
1419  SetConsoleCPRequest->OutputCP ? "Output" : "Input");
1420 
1422  if (!NT_SUCCESS(Status)) return Status;
1423 
1425  SetConsoleCPRequest->CodePage,
1426  SetConsoleCPRequest->OutputCP);
1427 
1429  return Status;
1430 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI ConDrvSetConsoleCP(IN PCONSOLE Console, IN UINT CodePage, IN BOOLEAN OutputCP)
Definition: console.c:526
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ CSR_API() [10/22]

CSR_API ( SrvGetConsoleProcessList  )

Definition at line 1432 of file console.c.

1433 {
1434  NTSTATUS Status;
1435  PCONSOLE_GETPROCESSLIST GetProcessListRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetProcessListRequest;
1437 
1438  if (!CsrValidateMessageBuffer(ApiMessage,
1439  (PVOID)&GetProcessListRequest->ProcessIdsList,
1440  GetProcessListRequest->ProcessCount,
1441  sizeof(DWORD)))
1442  {
1443  return STATUS_INVALID_PARAMETER;
1444  }
1445 
1447  if (!NT_SUCCESS(Status)) return Status;
1448 
1450  GetProcessListRequest->ProcessIdsList,
1451  GetProcessListRequest->ProcessCount,
1452  &GetProcessListRequest->ProcessCount);
1453 
1455  return Status;
1456 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1315
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
NTSTATUS NTAPI ConSrvGetConsoleProcessList(IN PCONSRV_CONSOLE Console, IN OUT PULONG ProcessIdsList, IN ULONG MaxIdListItems, OUT PULONG ProcessIdsTotal)
Definition: console.c:877
static DWORD
Definition: console.c:27
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ CSR_API() [11/22]

CSR_API ( SrvGenerateConsoleCtrlEvent  )

Definition at line 1458 of file console.c.

1459 {
1460  NTSTATUS Status;
1461  PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GenerateCtrlEventRequest;
1463 
1465  if (!NT_SUCCESS(Status)) return Status;
1466 
1468  GenerateCtrlEventRequest->ProcessGroupId,
1469  GenerateCtrlEventRequest->CtrlEvent);
1470 
1472  return Status;
1473 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
NTSTATUS NTAPI ConSrvConsoleProcessCtrlEvent(IN PCONSRV_CONSOLE Console, IN ULONG ProcessGroupId, IN ULONG CtrlEvent)
Definition: console.c:906
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219

◆ CSR_API() [12/22]

CSR_API ( SrvConsoleNotifyLastClose  )

Definition at line 1475 of file console.c.

1476 {
1477  NTSTATUS Status;
1480 
1481  Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
1482  if (!NT_SUCCESS(Status)) return Status;
1483 
1484  /* Only one process is allowed to be registered for last close notification */
1485  if (!Console->NotifyLastClose)
1486  {
1487  Console->NotifyLastClose = TRUE;
1488  Console->NotifiedLastCloseProcess = ProcessData;
1490  }
1491  else
1492  {
1494  }
1495 
1497  return Status;
1498 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ CSR_API() [13/22]

CSR_API ( SrvGetConsoleMouseInfo  )

Definition at line 1502 of file console.c.

1503 {
1504  NTSTATUS Status;
1505  PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetMouseInfoRequest;
1507 
1509  if (!NT_SUCCESS(Status)) return Status;
1510 
1511  /* Just retrieve the number of buttons of the mouse attached to this console */
1512  GetMouseInfoRequest->NumButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
1513 
1515  return STATUS_SUCCESS;
1516 }
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
#define SM_CMOUSEBUTTONS
Definition: winuser.h:996
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
int WINAPI GetSystemMetrics(_In_ int)
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2966

◆ CSR_API() [14/22]

CSR_API ( SrvSetConsoleKeyShortcuts  )

Definition at line 1518 of file console.c.

1519 {
1520  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1521  return STATUS_NOT_IMPLEMENTED;
1522 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [15/22]

CSR_API ( SrvGetConsoleKeyboardLayoutName  )

Definition at line 1524 of file console.c.

1525 {
1526  NTSTATUS Status;
1527  PCONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetKbdLayoutNameRequest;
1529 
1531  if (!NT_SUCCESS(Status)) return Status;
1532 
1533  /* Retrieve the keyboard layout name of the system */
1534  if (GetKbdLayoutNameRequest->Ansi)
1535  GetKeyboardLayoutNameA((PCHAR)GetKbdLayoutNameRequest->LayoutBuffer);
1536  else
1537  GetKeyboardLayoutNameW((PWCHAR)GetKbdLayoutNameRequest->LayoutBuffer);
1538 
1540  return STATUS_SUCCESS;
1541 }
signed char * PCHAR
Definition: retypes.h:7
NTSTATUS ConSrvGetConsole(IN PCONSOLE_PROCESS_DATA ProcessData, OUT PCONSRV_CONSOLE *Console, IN BOOLEAN LockConsole)
Definition: console.c:271
#define CsrGetClientThread()
Definition: csrsrv.h:77
#define TRUE
Definition: types.h:120
BOOL WINAPI GetKeyboardLayoutNameW(_Out_writes_(KL_NAMELENGTH) LPWSTR)
struct _CONSOLE_API_MESSAGE * PCONSOLE_API_MESSAGE
LONG NTSTATUS
Definition: precomp.h:26
BOOL WINAPI GetKeyboardLayoutNameA(_Out_writes_(KL_NAMELENGTH) LPSTR)
uint16_t * PWCHAR
Definition: typedefs.h:54
#define PCONSRV_CONSOLE
Definition: conio.h:27
VOID ConSrvReleaseConsole(IN PCONSRV_CONSOLE Console, IN BOOLEAN IsConsoleLocked)
Definition: console.c:296
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
Status
Definition: gdiplustypes.h:24
CConsole Console
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
return STATUS_SUCCESS
Definition: btrfs.c:2966
CHAR LayoutBuffer[KL_NAMELENGTH *sizeof(WCHAR)]
Definition: conmsg.h:865

◆ CSR_API() [16/22]

CSR_API ( SrvGetConsoleCharType  )

Definition at line 1543 of file console.c.

1544 {
1545  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1546  return STATUS_NOT_IMPLEMENTED;
1547 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [17/22]

CSR_API ( SrvSetConsoleLocalEUDC  )

Definition at line 1549 of file console.c.

1550 {
1551  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1552  return STATUS_NOT_IMPLEMENTED;
1553 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [18/22]

CSR_API ( SrvSetConsoleCursorMode  )

Definition at line 1555 of file console.c.

1556 {
1557  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1558  return STATUS_NOT_IMPLEMENTED;
1559 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [19/22]

CSR_API ( SrvGetConsoleCursorMode  )

Definition at line 1561 of file console.c.

1562 {
1563  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1564  return STATUS_NOT_IMPLEMENTED;
1565 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [20/22]

CSR_API ( SrvGetConsoleNlsMode  )

Definition at line 1567 of file console.c.

1568 {
1569  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1570  return STATUS_NOT_IMPLEMENTED;
1571 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [21/22]

CSR_API ( SrvSetConsoleNlsMode  )

Definition at line 1573 of file console.c.

1574 {
1575  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1576  return STATUS_NOT_IMPLEMENTED;
1577 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ CSR_API() [22/22]

CSR_API ( SrvGetConsoleLangId  )

Definition at line 1579 of file console.c.

1580 {
1581  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1582  return STATUS_NOT_IMPLEMENTED;
1583 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:112

◆ InsertConsole()

static NTSTATUS InsertConsole ( OUT PHANDLE  Handle,
IN PCONSRV_CONSOLE  Console 
)
static

Definition at line 46 of file console.c.

48 {
49 #define CONSOLE_HANDLES_INCREMENT 2 * 3
50 
52  ULONG i = 0;
53  PCONSRV_CONSOLE* Block;
54 
55  ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
56  (ConsoleList != NULL && ConsoleListSize != 0) );
57 
58  /* All went right, so add the console to the list */
60  DPRINT("Insert in the list\n");
61 
62  if (ConsoleList)
63  {
64  for (i = 0; i < ConsoleListSize; i++)
65  {
66  if (ConsoleList[i] == NULL) break;
67  }
68  }
69 
70  if (i >= ConsoleListSize)
71  {
72  DPRINT("Creation of a new handles table\n");
73  /* Allocate a new handles table */
77  if (Block == NULL)
78  {
80  goto Quit;
81  }
82 
83  /* If we previously had a handles table, free it and use the new one */
84  if (ConsoleList)
85  {
86  /* Copy the handles from the old table to the new one */
87  RtlCopyMemory(Block,
91  }
92  ConsoleList = Block;
94  }
95 
97  *Handle = ULongToHandle((i << 2) | 0x3);
98 
99 Quit:
100  /* Unlock the console list and return status */
102  return Status;
103 }
static PCONSRV_CONSOLE * ConsoleList
Definition: console.c:32
static ULONG ConsoleListSize
Definition: console.c:31
#define ConSrvLockConsoleListExclusive()
Definition: console.c:35
#define ULongToHandle(h)
Definition: basetsd.h:81
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
#define PCONSRV_CONSOLE
Definition: conio.h:27
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
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_In_ HANDLE Handle
Definition: extypes.h:390
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
#define CONSOLE_HANDLES_INCREMENT
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
CConsole Console
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
unsigned int ULONG
Definition: retypes.h:1
#define ConSrvUnlockConsoleList()
Definition: console.c:41
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by ConSrvInitConsole().

◆ LoadShellLinkConsoleInfo()

static BOOL LoadShellLinkConsoleInfo ( IN OUT PCONSOLE_STATE_INFO  ConsoleInfo,
IN OUT PCONSOLE_INIT_INFO  ConsoleInitInfo 
)
static

Definition at line 349 of file console.c.

351 {
352 #define PATH_SEPARATOR L'\\'
353 
354  BOOL RetVal = FALSE;
355  HRESULT hRes = S_OK;
356  SIZE_T Length = 0;
357  LPWSTR LinkName = NULL;
358  LPWSTR IconPath = NULL;
359  WCHAR Buffer[MAX_PATH + 1];
360 
361  ConsoleInitInfo->ConsoleStartInfo->IconIndex = 0;
362 
363  if ((ConsoleInitInfo->ConsoleStartInfo->dwStartupFlags & STARTF_TITLEISLINKNAME) == 0)
364  {
365  // return FALSE; // FIXME!! (for icon loading)
366  RetVal = TRUE;
367  goto Finish;
368  }
369 
370  /* 1- Find the last path separator if any */
371  LinkName = wcsrchr(ConsoleInfo->ConsoleTitle, PATH_SEPARATOR);
372  if (LinkName == NULL)
373  LinkName = ConsoleInfo->ConsoleTitle;
374  else
375  ++LinkName; // Skip the path separator
376 
377  /* 2- Check for the link extension. The name ".lnk" is considered invalid. */
378  Length = wcslen(LinkName);
379  if ( (Length <= 4) || (wcsicmp(LinkName + (Length - 4), L".lnk") != 0) )
380  return FALSE;
381 
382  /* 3- It may be a link. Try to retrieve some properties */
383  hRes = CoInitialize(NULL);
384  if (SUCCEEDED(hRes))
385  {
386  /* Get a pointer to the IShellLink interface */
387  IShellLinkW* pshl = NULL;
388  hRes = CoCreateInstance(&CLSID_ShellLink,
389  NULL,
390  CLSCTX_INPROC_SERVER,
391  &IID_IShellLinkW,
392  (LPVOID*)&pshl);
393  if (SUCCEEDED(hRes))
394  {
395  /* Get a pointer to the IPersistFile interface */
396  IPersistFile* ppf = NULL;
397  hRes = IPersistFile_QueryInterface(pshl, &IID_IPersistFile, (LPVOID*)&ppf);
398  if (SUCCEEDED(hRes))
399  {
400  /* Load the shortcut */
401  hRes = IPersistFile_Load(ppf, ConsoleInfo->ConsoleTitle, STGM_READ);
402  if (SUCCEEDED(hRes))
403  {
404  /*
405  * Finally we can get the properties !
406  * Update the old ones if needed.
407  */
408  INT ShowCmd = 0;
409  // WORD HotKey = 0;
410 
411  /* Reset the name of the console with the name of the shortcut */
412  Length = min(/*Length*/ Length - 4, // 4 == len(".lnk")
413  (ConsoleInfo->cbSize - FIELD_OFFSET(CONSOLE_STATE_INFO, ConsoleTitle) - sizeof(UNICODE_NULL)) / sizeof(WCHAR));
414  wcsncpy(ConsoleInfo->ConsoleTitle, LinkName, Length);
415  ConsoleInfo->ConsoleTitle[Length] = UNICODE_NULL;
416 
417  /* Get the window showing command */
418  hRes = IShellLinkW_GetShowCmd(pshl, &ShowCmd);
419  if (SUCCEEDED(hRes)) ConsoleInitInfo->ConsoleStartInfo->wShowWindow = (WORD)ShowCmd;
420 
421  /* Get the hotkey */
422  // hRes = pshl->GetHotkey(&ShowCmd);
423  // if (SUCCEEDED(hRes)) ConsoleInitInfo->ConsoleStartInfo->HotKey = HotKey;
424 
425  /* Get the icon location, if any */
426  hRes = IShellLinkW_GetIconLocation(pshl,
427  Buffer,
428  sizeof(Buffer)/sizeof(Buffer[0]) - 1, // == MAX_PATH
429  &ConsoleInitInfo->ConsoleStartInfo->IconIndex);
430  if (!SUCCEEDED(hRes))
431  {
432  ConsoleInitInfo->ConsoleStartInfo->IconIndex = 0;
433  }
434  else
435  {
436  IconPath = Buffer;
437  }
438 
439  // FIXME: Since we still don't load console properties from the shortcut,
440  // return false. When this will be done, we will return true instead.
441  RetVal = TRUE; // FALSE;
442  }
443  IPersistFile_Release(ppf);
444  }
445  IShellLinkW_Release(pshl);
446  }
447  }
448  CoUninitialize();
449 
450 Finish:
451 
452  if (RetVal)
453  {
454  /* Get the associated icon, if any */
455  if (IconPath == NULL)
456  {
457  // Question: How to retrieve the full path name
458  // of the app we are going to run??
459  Length = RtlDosSearchPath_U(ConsoleInitInfo->CurDir,
460  ConsoleInitInfo->AppName,
461  NULL,
462  sizeof(Buffer),
463  Buffer,
464  NULL);
465  if (Length > 0 && Length < sizeof(Buffer))
466  IconPath = Buffer;
467  else
468  IconPath = ConsoleInitInfo->AppName;
469 
470  // ConsoleInitInfo->ConsoleStartInfo->IconIndex = 0;
471  }
472  DPRINT("IconPath = '%S' ; IconIndex = %lu\n",
473  IconPath, ConsoleInitInfo->ConsoleStartInfo->IconIndex);
474  if (IconPath && *IconPath)
475  {
476  HICON hIcon = NULL, hIconSm = NULL;
477  /*
478  * FIXME!! Because of a strange bug we have in PrivateExtractIconExW
479  * (see r65683 for more details), we cannot use this API to extract
480  * at the same time the large and small icons from the app.
481  * Instead we just use PrivateExtractIconsW.
482  *
483  PrivateExtractIconExW(IconPath,
484  ConsoleInitInfo->ConsoleStartInfo->IconIndex,
485  &hIcon,
486  &hIconSm,
487  1);
488  */
490  ConsoleInitInfo->ConsoleStartInfo->IconIndex,
491  32, 32,
494  ConsoleInitInfo->ConsoleStartInfo->IconIndex,
495  16, 16,
497 
498  DPRINT("hIcon = 0x%p ; hIconSm = 0x%p\n", hIcon, hIconSm);
499  if (hIcon != NULL) ConsoleInitInfo->ConsoleStartInfo->hIcon = hIcon;
500  if (hIconSm != NULL) ConsoleInitInfo->ConsoleStartInfo->hIconSm = hIconSm;
501  }
502  }
503 
504  // FIXME: See the previous FIXME above.
505  RetVal = FALSE;
506 
507  return RetVal;
508 }
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:56
NTSYSAPI ULONG NTAPI RtlDosSearchPath_U(_In_ PCWSTR Path, _In_ PCWSTR FileName, _In_ PCWSTR Extension, _In_ ULONG BufferSize, _Out_ PWSTR Buffer, _Out_ PWSTR *PartName)
#define UNICODE_NULL
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
Definition: bufpool.h:45
#define STGM_READ
Definition: objbase.h:916
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
UINT WINAPI PrivateExtractIconsW(_In_reads_(MAX_PATH) LPCWSTR szFileName, _In_ int nIconIndex, _In_ int cxIcon, _In_ int cyIcon, _Out_writes_opt_(nIcons) HICON *phicon, _Out_writes_opt_(nIcons) UINT *piconid, _In_ UINT nIcons, _In_ UINT flags)
unsigned short WORD
Definition: ntddk_ex.h:93
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
static const WCHAR L[]
Definition: oid.c:1250
#define wcsicmp
Definition: string.h:1152
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3234
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define S_OK
Definition: intsafe.h:59
#define PATH_SEPARATOR
#define LR_COPYFROMRESOURCE
Definition: winuser.h:1089
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
HICON hIcon
Definition: msconfig.c:44
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:1991
static CONSOLE_SCREEN_BUFFER_INFO ConsoleInfo
Definition: video.c:47
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define min(a, b)
Definition: monoChain.cc:55
static const WCHAR IconPath[]
Definition: install.c:50
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1897
const GUID IID_IPersistFile
HICON hIconSm
Definition: msconfig.c:44
WCHAR * LPWSTR
Definition: xmlstorage.h:184
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by ConSrvInitConsole().

◆ RemoveConsoleByPointer()

static NTSTATUS RemoveConsoleByPointer ( IN PCONSRV_CONSOLE  Console)
static

Definition at line 141 of file console.c.

142 {
143  ULONG i = 0;
144 
145  if (!Console) return STATUS_INVALID_PARAMETER;
146 
147  ASSERT( (ConsoleList == NULL && ConsoleListSize == 0) ||
148  (ConsoleList != NULL && ConsoleListSize != 0) );
149 
150  /* Remove the console from the list */
152 
153  if (ConsoleList)
154  {
155  for (i = 0; i < ConsoleListSize; i++)
156  {
157  if (ConsoleList[i] == Console) ConsoleList[i] = NULL;
158  }
159  }
160 
161  /* Unlock the console list and return */
163  return STATUS_SUCCESS;
164 }
static PCONSRV_CONSOLE * ConsoleList
Definition: console.c:32
static ULONG ConsoleListSize
Definition: console.c:31
#define ConSrvLockConsoleListExclusive()
Definition: console.c:35
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
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
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
CConsole Console
unsigned int ULONG
Definition: retypes.h:1
#define ConSrvUnlockConsoleList()
Definition: console.c:41
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by ConSrvDeleteConsole().

Variable Documentation

◆ ConsoleList

PCONSRV_CONSOLE* ConsoleList
static

◆ ConsoleListSize

ULONG ConsoleListSize
static

◆ ListLock

RTL_RESOURCE ListLock
static

Definition at line 33 of file console.c.

Referenced by ConSrvInitConsoleSupport().