ReactOS  0.4.14-dev-854-gb9426a3
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 515 of file console.c.

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

◆ ConDrvGetConsoleMode()

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

Definition at line 428 of file console.c.

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

◆ ConDrvSetConsoleCP()

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

Definition at line 528 of file console.c.

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

◆ ConDrvSetConsoleMode()

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

Definition at line 461 of file console.c.

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

◆ 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:406
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:2938
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:2938
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 233 of file terminal.c.

234 {
236  PFRONTEND FrontEnd = Terminal->Context;
237 
238  /* Reset the ConSrv terminal */
239  Terminal->Context = NULL;
240  Terminal->Vtbl = NULL;
241 
242  /* Unload the frontend */
243  if (FrontEnd != NULL)
244  {
245  Status = ConSrvUnloadFrontEnd(FrontEnd);
246  ConsoleFreeHeap(FrontEnd);
247  }
248 
249  return Status;
250 }
LONG NTSTATUS
Definition: precomp.h:26
static NTSTATUS ConSrvUnloadFrontEnd(IN PFRONTEND FrontEnd)
Definition: terminal.c:189
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:2938

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:329
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:2938

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:2938
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:200
VOID NTAPI ConDrvDeleteConsole(IN PCONSOLE Console)
Definition: console.c:329
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:271
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:2938
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:233
UINT WINAPI GetOEMCP(VOID)
Definition: nls.c:2195

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

204 {
206  PFRONTEND FrontEnd;
207 
208  /* Load a suitable frontend for the ConSrv terminal */
209  FrontEnd = ConsoleAllocHeap(HEAP_ZERO_MEMORY, sizeof(*FrontEnd));
210  if (!FrontEnd) return STATUS_NO_MEMORY;
211 
212  Status = ConSrvLoadFrontEnd(FrontEnd,
213  ConsoleInfo,
214  ConsoleInitInfo,
215  ConsoleLeaderProcessHandle);
216  if (!NT_SUCCESS(Status))
217  {
218  DPRINT1("CONSRV: Failed to initialize a frontend, Status = 0x%08lx\n", Status);
219  ConsoleFreeHeap(FrontEnd);
220  return Status;
221  }
222  DPRINT("CONSRV: Frontend initialized\n");
223 
224  /* Initialize the ConSrv terminal */
225  Terminal->Vtbl = &ConSrvTermVtbl;
226  // Terminal->Console will be initialized by ConDrvAttachTerminal
227  Terminal->Context = FrontEnd; /* We store the frontend pointer in the terminal private context */
228 
229  return STATUS_SUCCESS;
230 }
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:197
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:150
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:2938

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:2938
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)
952  else
954 }
PKPROCESS CsrProcess
Definition: videoprt.c:37
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 987 of file console.c.

988 {
990  PCONSOLE_ALLOCCONSOLE AllocConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.AllocConsoleRequest;
993  CONSOLE_INIT_INFO ConsoleInitInfo;
994 
995  if (ProcessData->ConsoleHandle != NULL)
996  {
997  DPRINT1("Process already has a console\n");
998  return STATUS_ACCESS_DENIED;
999  }
1000 
1001  if ( !CsrValidateMessageBuffer(ApiMessage,
1002  (PVOID*)&AllocConsoleRequest->ConsoleStartInfo,
1003  1,
1004  sizeof(CONSOLE_START_INFO)) ||
1005  !CsrValidateMessageBuffer(ApiMessage,
1006  (PVOID*)&AllocConsoleRequest->ConsoleTitle,
1007  AllocConsoleRequest->TitleLength,
1008  sizeof(BYTE)) ||
1009  !CsrValidateMessageBuffer(ApiMessage,
1010  (PVOID*)&AllocConsoleRequest->Desktop,
1011  AllocConsoleRequest->DesktopLength,
1012  sizeof(BYTE)) ||
1013  !CsrValidateMessageBuffer(ApiMessage,
1014  (PVOID*)&AllocConsoleRequest->CurDir,
1015  AllocConsoleRequest->CurDirLength,
1016  sizeof(BYTE)) ||
1017  !CsrValidateMessageBuffer(ApiMessage,
1018  (PVOID*)&AllocConsoleRequest->AppName,
1019  AllocConsoleRequest->AppNameLength,
1020  sizeof(BYTE)) )
1021  {
1022  return STATUS_INVALID_PARAMETER;
1023  }
1024 
1025  /* Initialize the console initialization info structure */
1026  ConsoleInitInfo.ConsoleStartInfo = AllocConsoleRequest->ConsoleStartInfo;
1027  ConsoleInitInfo.IsWindowVisible = TRUE; // The console window is always visible.
1028  ConsoleInitInfo.TitleLength = AllocConsoleRequest->TitleLength;
1029  ConsoleInitInfo.ConsoleTitle = AllocConsoleRequest->ConsoleTitle;
1030  ConsoleInitInfo.DesktopLength = AllocConsoleRequest->DesktopLength;
1031  ConsoleInitInfo.Desktop = AllocConsoleRequest->Desktop;
1032  ConsoleInitInfo.AppNameLength = AllocConsoleRequest->AppNameLength;
1033  ConsoleInitInfo.AppName = AllocConsoleRequest->AppName;
1034  ConsoleInitInfo.CurDirLength = AllocConsoleRequest->CurDirLength;
1035  ConsoleInitInfo.CurDir = AllocConsoleRequest->CurDir;
1036 
1037  /* Initialize a new Console owned by the Console Leader Process */
1038  Status = ConSrvAllocateConsole(ProcessData,
1039  &AllocConsoleRequest->ConsoleStartInfo->InputHandle,
1040  &AllocConsoleRequest->ConsoleStartInfo->OutputHandle,
1041  &AllocConsoleRequest->ConsoleStartInfo->ErrorHandle,
1042  &ConsoleInitInfo);
1043  if (!NT_SUCCESS(Status))
1044  {
1045  DPRINT1("Console allocation failed\n");
1046  return Status;
1047  }
1048 
1049  /* Set the Property-Dialog and Control-Dispatcher handlers */
1050  ProcessData->PropRoutine = AllocConsoleRequest->PropRoutine;
1051  ProcessData->CtrlRoutine = AllocConsoleRequest->CtrlRoutine;
1052 
1053  return STATUS_SUCCESS;
1054 }
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
PKPROCESS CsrProcess
Definition: videoprt.c:37
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:2938
PCONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:274

◆ CSR_API() [2/22]

CSR_API ( SrvAttachConsole  )

Definition at line 1057 of file console.c.

1058 {
1060  PCONSOLE_ATTACHCONSOLE AttachConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.AttachConsoleRequest;
1061  PCSR_PROCESS SourceProcess = NULL; // The parent process.
1062  PCSR_PROCESS TargetProcess = CsrGetClientThread()->Process; // Ourselves.
1063  HANDLE ProcessId = ULongToHandle(AttachConsoleRequest->ProcessId);
1064  PCONSOLE_PROCESS_DATA SourceProcessData, TargetProcessData;
1065 
1066  TargetProcessData = ConsoleGetPerProcessData(TargetProcess);
1067 
1068  if (TargetProcessData->ConsoleHandle != NULL)
1069  {
1070  DPRINT1("Process already has a console\n");
1071  return STATUS_ACCESS_DENIED;
1072  }
1073 
1074  if (!CsrValidateMessageBuffer(ApiMessage,
1075  (PVOID*)&AttachConsoleRequest->ConsoleStartInfo,
1076  1,
1077  sizeof(CONSOLE_START_INFO)))
1078  {
1079  return STATUS_INVALID_PARAMETER;
1080  }
1081 
1082  /* Check whether we try to attach to the parent's console */
1083  if (ProcessId == ULongToHandle(ATTACH_PARENT_PROCESS))
1084  {
1085  PROCESS_BASIC_INFORMATION ProcessInfo;
1086  ULONG Length = sizeof(ProcessInfo);
1087 
1088  /* Get the real parent's PID */
1089 
1092  &ProcessInfo,
1093  Length, &Length);
1094  if (!NT_SUCCESS(Status))
1095  {
1096  DPRINT1("SrvAttachConsole - Cannot retrieve basic process info, Status = 0x%08lx\n", Status);
1097  return Status;
1098  }
1099 
1101  }
1102 
1103  /* Lock the source process via its PID */
1104  Status = CsrLockProcessByClientId(ProcessId, &SourceProcess);
1105  if (!NT_SUCCESS(Status)) return Status;
1106 
1107  SourceProcessData = ConsoleGetPerProcessData(SourceProcess);
1108 
1109  if (SourceProcessData->ConsoleHandle == NULL)
1110  {
1112  goto Quit;
1113  }
1114 
1115  /*
1116  * Inherit the console from the parent,
1117  * if any, otherwise return an error.
1118  */
1119  Status = ConSrvInheritConsole(TargetProcessData,
1120  SourceProcessData->ConsoleHandle,
1121  TRUE,
1122  &AttachConsoleRequest->ConsoleStartInfo->InputHandle,
1123  &AttachConsoleRequest->ConsoleStartInfo->OutputHandle,
1124  &AttachConsoleRequest->ConsoleStartInfo->ErrorHandle,
1125  AttachConsoleRequest->ConsoleStartInfo);
1126  if (!NT_SUCCESS(Status))
1127  {
1128  DPRINT1("Console inheritance failed\n");
1129  goto Quit;
1130  }
1131 
1132  /* Set the Property-Dialog and Control-Dispatcher handlers */
1133  TargetProcessData->PropRoutine = AttachConsoleRequest->PropRoutine;
1134  TargetProcessData->CtrlRoutine = AttachConsoleRequest->CtrlRoutine;
1135 
1137 
1138 Quit:
1139  /* Unlock the "source" process and exit */
1140  CsrUnlockProcess(SourceProcess);
1141  return Status;
1142 }
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:2938
NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1398

◆ CSR_API() [3/22]

CSR_API ( SrvFreeConsole  )

Definition at line 1145 of file console.c.

1146 {
1148 }
#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 1155 of file console.c.

1156 {
1157  NTSTATUS Status;
1158  PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
1160 
1161  PULONG ConsoleMode = &ConsoleModeRequest->Mode;
1162 
1164  ConsoleModeRequest->Handle,
1165  &Object, NULL, GENERIC_READ, TRUE, 0);
1166  if (!NT_SUCCESS(Status)) return Status;
1167 
1168  /* Get the standard console modes */
1170  ConsoleMode);
1171  if (NT_SUCCESS(Status))
1172  {
1173  /*
1174  * If getting the console modes succeeds, then retrieve
1175  * the extended CONSRV-specific input modes.
1176  */
1177  if (INPUT_BUFFER == Object->Type)
1178  {
1179  if (Object->Console->InsertMode || Object->Console->QuickEdit)
1180  {
1181  /* Windows also adds ENABLE_EXTENDED_FLAGS, even if it's not documented on MSDN */
1182  *ConsoleMode |= ENABLE_EXTENDED_FLAGS;
1183 
1184  if (Object->Console->InsertMode) *ConsoleMode |= ENABLE_INSERT_MODE;
1185  if (Object->Console->QuickEdit ) *ConsoleMode |= ENABLE_QUICK_EDIT_MODE;
1186  }
1187  }
1188  }
1189 
1191  return Status;
1192 }
#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:428
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 1199 of file console.c.

1200 {
1201 #define CONSOLE_VALID_CONTROL_MODES ( ENABLE_EXTENDED_FLAGS | \
1202  ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE )
1203 
1204  NTSTATUS Status;
1205  PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
1207 
1208  ULONG ConsoleMode = ConsoleModeRequest->Mode;
1209 
1211  ConsoleModeRequest->Handle,
1212  &Object, NULL, GENERIC_WRITE, TRUE, 0);
1213  if (!NT_SUCCESS(Status)) return Status;
1214 
1215  /* Set the standard console modes (without the CONSRV-specific input modes) */
1216  ConsoleMode &= ~CONSOLE_VALID_CONTROL_MODES; // Remove CONSRV-specific input modes.
1218  ConsoleMode);
1219  if (NT_SUCCESS(Status))
1220  {
1221  /*
1222  * If setting the console modes succeeds, then set
1223  * the extended CONSRV-specific input modes.
1224  */
1225  if (INPUT_BUFFER == Object->Type)
1226  {
1227  ConsoleMode = ConsoleModeRequest->Mode;
1228 
1229  if (ConsoleMode & CONSOLE_VALID_CONTROL_MODES)
1230  {
1231  /*
1232  * If we use control mode flags without ENABLE_EXTENDED_FLAGS,
1233  * then consider the flags invalid.
1234  */
1235  if ((ConsoleMode & ENABLE_EXTENDED_FLAGS) == 0)
1236  {
1238  }
1239  else
1240  {
1241  Object->Console->InsertMode = !!(ConsoleMode & ENABLE_INSERT_MODE);
1242  Object->Console->QuickEdit = !!(ConsoleMode & ENABLE_QUICK_EDIT_MODE);
1243  }
1244  }
1245  }
1246  }
1247 
1249  return Status;
1250 }
#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:461
#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 1253 of file console.c.

1254 {
1255  NTSTATUS Status;
1256  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
1258  ULONG Length;
1259 
1260  if (!CsrValidateMessageBuffer(ApiMessage,
1261  (PVOID)&TitleRequest->Title,
1262  TitleRequest->Length,
1263  sizeof(BYTE)))
1264  {
1265  return STATUS_INVALID_PARAMETER;
1266  }
1267 
1269  if (!NT_SUCCESS(Status))
1270  {
1271  DPRINT1("Can't get console, status %lx\n", Status);
1272  return Status;
1273  }
1274 
1275  /* Copy title of the console to the user title buffer */
1276  if (TitleRequest->Unicode)
1277  {
1278  if (TitleRequest->Length >= sizeof(WCHAR))
1279  {
1280  Length = min(TitleRequest->Length - sizeof(WCHAR), Console->Title.Length);
1281  RtlCopyMemory(TitleRequest->Title, Console->Title.Buffer, Length);
1282  ((PWCHAR)TitleRequest->Title)[Length / sizeof(WCHAR)] = UNICODE_NULL;
1283  TitleRequest->Length = Length;
1284  }
1285  else
1286  {
1287  TitleRequest->Length = Console->Title.Length;
1288  }
1289  }
1290  else
1291  {
1292  if (TitleRequest->Length >= sizeof(CHAR))
1293  {
1294  Length = min(TitleRequest->Length - sizeof(CHAR), Console->Title.Length / sizeof(WCHAR));
1295  Length = WideCharToMultiByte(Console->InputCodePage, 0,
1296  Console->Title.Buffer, Length,
1297  TitleRequest->Title, Length,
1298  NULL, NULL);
1299  ((PCHAR)TitleRequest->Title)[Length] = ANSI_NULL;
1300  TitleRequest->Length = Length;
1301  }
1302  else
1303  {
1304  TitleRequest->Length = Console->Title.Length / sizeof(WCHAR);
1305  }
1306  }
1307 
1309  return Status;
1310 }
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 1313 of file console.c.

1314 {
1315  NTSTATUS Status;
1316  PCONSOLE_GETSETCONSOLETITLE TitleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.TitleRequest;
1318 
1319  PWCHAR Buffer;
1320  ULONG Length;
1321 
1322  if (!CsrValidateMessageBuffer(ApiMessage,
1323  (PVOID)&TitleRequest->Title,
1324  TitleRequest->Length,
1325  sizeof(BYTE)))
1326  {
1327  return STATUS_INVALID_PARAMETER;
1328  }
1329 
1331  if (!NT_SUCCESS(Status))
1332  {
1333  DPRINT1("Can't get console, status %lx\n", Status);
1334  return Status;
1335  }
1336 
1337  if (TitleRequest->Unicode)
1338  {
1339  /* Length is in bytes */
1340  Length = TitleRequest->Length;
1341  }
1342  else
1343  {
1344  /* Use the console input CP for the conversion */
1345  Length = MultiByteToWideChar(Console->InputCodePage, 0,
1346  TitleRequest->Title, TitleRequest->Length,
1347  NULL, 0);
1348  /* The returned Length was in number of wchars, convert it in bytes */
1349  Length *= sizeof(WCHAR);
1350  }
1351 
1352  /* Allocate a new buffer to hold the new title (NULL-terminated) */
1354  if (!Buffer)
1355  {
1357  goto Quit;
1358  }
1359 
1360  /* Free the old title */
1362 
1363  /* Copy title to console */
1364  Console->Title.Buffer = Buffer;
1365  Console->Title.Length = Length;
1366  Console->Title.MaximumLength = Console->Title.Length + sizeof(WCHAR);
1367 
1368  if (TitleRequest->Unicode)
1369  {
1370  RtlCopyMemory(Console->Title.Buffer, TitleRequest->Title, Console->Title.Length);
1371  }
1372  else
1373  {
1374  MultiByteToWideChar(Console->InputCodePage, 0,
1375  TitleRequest->Title, TitleRequest->Length,
1376  Console->Title.Buffer,
1377  Console->Title.Length / sizeof(WCHAR));
1378  }
1379 
1380  /* NULL-terminate */
1381  Console->Title.Buffer[Console->Title.Length / sizeof(WCHAR)] = UNICODE_NULL;
1382 
1385 
1386 Quit:
1388  return Status;
1389 }
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:2938

◆ CSR_API() [8/22]

CSR_API ( SrvGetConsoleCP  )

Definition at line 1396 of file console.c.

1397 {
1398  NTSTATUS Status;
1399  PCONSOLE_GETINPUTOUTPUTCP GetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleCPRequest;
1401 
1402  DPRINT("SrvGetConsoleCP, getting %s Code Page\n",
1403  GetConsoleCPRequest->OutputCP ? "Output" : "Input");
1404 
1406  if (!NT_SUCCESS(Status)) return Status;
1407 
1409  &GetConsoleCPRequest->CodePage,
1410  GetConsoleCPRequest->OutputCP);
1411 
1413  return Status;
1414 }
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:515
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 1421 of file console.c.

1422 {
1424  PCONSOLE_SETINPUTOUTPUTCP SetConsoleCPRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetConsoleCPRequest;
1426 
1427  DPRINT("SrvSetConsoleCP, setting %s Code Page\n",
1428  SetConsoleCPRequest->OutputCP ? "Output" : "Input");
1429 
1431  if (!NT_SUCCESS(Status)) return Status;
1432 
1434  SetConsoleCPRequest->CodePage,
1435  SetConsoleCPRequest->OutputCP);
1436 
1438  return Status;
1439 }
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:528
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 1442 of file console.c.

1443 {
1444  NTSTATUS Status;
1445  PCONSOLE_GETPROCESSLIST GetProcessListRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetProcessListRequest;
1447 
1448  if (!CsrValidateMessageBuffer(ApiMessage,
1449  (PVOID)&GetProcessListRequest->ProcessIdsList,
1450  GetProcessListRequest->ProcessCount,
1451  sizeof(DWORD)))
1452  {
1453  return STATUS_INVALID_PARAMETER;
1454  }
1455 
1457  if (!NT_SUCCESS(Status)) return Status;
1458 
1460  GetProcessListRequest->ProcessIdsList,
1461  GetProcessListRequest->ProcessCount,
1462  &GetProcessListRequest->ProcessCount);
1463 
1465  return Status;
1466 }
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 1469 of file console.c.

1470 {
1471  NTSTATUS Status;
1472  PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GenerateCtrlEventRequest;
1474 
1476  if (!NT_SUCCESS(Status)) return Status;
1477 
1479  GenerateCtrlEventRequest->ProcessGroupId,
1480  GenerateCtrlEventRequest->CtrlEvent);
1481 
1483  return Status;
1484 }
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 1487 of file console.c.

1488 {
1489  NTSTATUS Status;
1492 
1493  Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
1494  if (!NT_SUCCESS(Status)) return Status;
1495 
1496  /* Only one process is allowed to be registered for last close notification */
1497  if (!Console->NotifyLastClose)
1498  {
1499  Console->NotifyLastClose = TRUE;
1500  Console->NotifiedLastCloseProcess = ProcessData;
1502  }
1503  else
1504  {
1506  }
1507 
1509  return Status;
1510 }
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:2938

◆ CSR_API() [13/22]

CSR_API ( SrvGetConsoleMouseInfo  )

Definition at line 1513 of file console.c.

1514 {
1515  NTSTATUS Status;
1516  PCONSOLE_GETMOUSEINFO GetMouseInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetMouseInfoRequest;
1518 
1520  if (!NT_SUCCESS(Status)) return Status;
1521 
1522  /* Just retrieve the number of buttons of the mouse attached to this console */
1523  GetMouseInfoRequest->NumButtons = GetSystemMetrics(SM_CMOUSEBUTTONS);
1524 
1526  return STATUS_SUCCESS;
1527 }
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:2938

◆ CSR_API() [14/22]

CSR_API ( SrvSetConsoleKeyShortcuts  )

Definition at line 1530 of file console.c.

1531 {
1532  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1533  return STATUS_NOT_IMPLEMENTED;
1534 }
#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 1537 of file console.c.

1538 {
1539  NTSTATUS Status;
1540  PCONSOLE_GETKBDLAYOUTNAME GetKbdLayoutNameRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetKbdLayoutNameRequest;
1542 
1544  if (!NT_SUCCESS(Status)) return Status;
1545 
1546  /* Retrieve the keyboard layout name of the system */
1547  if (GetKbdLayoutNameRequest->Ansi)
1548  GetKeyboardLayoutNameA((PCHAR)GetKbdLayoutNameRequest->LayoutBuffer);
1549  else
1550  GetKeyboardLayoutNameW((PWCHAR)GetKbdLayoutNameRequest->LayoutBuffer);
1551 
1553  return STATUS_SUCCESS;
1554 }
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:2938
CHAR LayoutBuffer[KL_NAMELENGTH *sizeof(WCHAR)]
Definition: conmsg.h:865

◆ CSR_API() [16/22]

CSR_API ( SrvGetConsoleCharType  )

Definition at line 1557 of file console.c.

1558 {
1559  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1560  return STATUS_NOT_IMPLEMENTED;
1561 }
#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 1564 of file console.c.

1565 {
1566  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1567  return STATUS_NOT_IMPLEMENTED;
1568 }
#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 1571 of file console.c.

1572 {
1573  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1574  return STATUS_NOT_IMPLEMENTED;
1575 }
#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 1578 of file console.c.

1579 {
1580  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1581  return STATUS_NOT_IMPLEMENTED;
1582 }
#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 1585 of file console.c.

1586 {
1587  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1588  return STATUS_NOT_IMPLEMENTED;
1589 }
#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 1592 of file console.c.

1593 {
1594  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1595  return STATUS_NOT_IMPLEMENTED;
1596 }
#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 1599 of file console.c.

1600 {
1601  DPRINT1("%s not yet implemented\n", __FUNCTION__);
1602  return STATUS_NOT_IMPLEMENTED;
1603 }
#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:2938

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:3325
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:2067
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:51
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
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:2938

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