ReactOS  0.4.14-dev-52-g6116262
init.c File Reference
#include "consrv.h"
#include "api.h"
#include "procinit.h"
#include <debug.h>
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS ConSrvInheritHandlesTable (IN PCONSOLE_PROCESS_DATA SourceProcessData, IN PCONSOLE_PROCESS_DATA TargetProcessData)
 
NTSTATUS NTAPI ConSrvNewProcess (PCSR_PROCESS SourceProcess, PCSR_PROCESS TargetProcess)
 
NTSTATUS NTAPI ConSrvConnect (IN PCSR_PROCESS CsrProcess, IN OUT PVOID ConnectionInfo, IN OUT PULONG ConnectionInfoLength)
 
VOID NTAPI ConSrvDisconnect (IN PCSR_PROCESS CsrProcess)
 
 CSR_SERVER_DLL_INIT (ConServerDllInitialization)
 

Variables

HINSTANCE ConSrvDllInstance = NULL
 
HANDLE ConSrvHeap = NULL
 
PCSR_API_ROUTINE ConsoleServerApiDispatchTable [ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER]
 
BOOLEAN ConsoleServerApiServerValidTable [ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file init.c.

Function Documentation

◆ ConSrvConnect()

NTSTATUS NTAPI ConSrvConnect ( IN PCSR_PROCESS  CsrProcess,
IN OUT PVOID  ConnectionInfo,
IN OUT PULONG  ConnectionInfoLength 
)

Definition at line 406 of file init.c.

409 {
410  /**************************************************************************
411  * This function is called whenever a CUI new process is created.
412  **************************************************************************/
413 
415  PCONSRV_API_CONNECTINFO ConnectInfo = (PCONSRV_API_CONNECTINFO)ConnectionInfo;
416  PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrProcess);
417 
418  if ( ConnectionInfo == NULL ||
419  ConnectionInfoLength == NULL ||
420  *ConnectionInfoLength != sizeof(*ConnectInfo) )
421  {
422  DPRINT1("CONSRV: Connection failed - ConnectionInfo = 0x%p ; ConnectionInfoLength = 0x%p (%lu), expected %lu\n",
423  ConnectionInfo,
424  ConnectionInfoLength,
425  ConnectionInfoLength ? *ConnectionInfoLength : (ULONG)-1,
426  sizeof(*ConnectInfo));
427 
428  return STATUS_UNSUCCESSFUL;
429  }
430 
431  /* Set Control-Dispatcher handler */
432  ProcessData->CtrlRoutine = ConnectInfo->CtrlRoutine;
433 
434  /* If we don't need a console, then get out of here */
435  DPRINT("ConnectInfo->IsConsoleApp = %s\n", ConnectInfo->IsConsoleApp ? "True" : "False");
436  if (!ConnectInfo->IsConsoleApp) return STATUS_SUCCESS;
437 
438  /* If we don't inherit from an existing console, then create a new one... */
439  if (ConnectInfo->ConsoleStartInfo.ConsoleHandle == NULL)
440  {
441  CONSOLE_INIT_INFO ConsoleInitInfo;
442 
443  DPRINT("ConSrvConnect - Allocate a new console\n");
444 
445  /* Initialize the console initialization info structure */
446  ConsoleInitInfo.ConsoleStartInfo = &ConnectInfo->ConsoleStartInfo;
447  ConsoleInitInfo.IsWindowVisible = ConnectInfo->IsWindowVisible;
448  ConsoleInitInfo.TitleLength = ConnectInfo->TitleLength;
449  ConsoleInitInfo.ConsoleTitle = ConnectInfo->ConsoleTitle;
450  ConsoleInitInfo.DesktopLength = 0;
451  ConsoleInitInfo.Desktop = NULL;
452  ConsoleInitInfo.AppNameLength = ConnectInfo->AppNameLength;
453  ConsoleInitInfo.AppName = ConnectInfo->AppName;
454  ConsoleInitInfo.CurDirLength = ConnectInfo->CurDirLength;
455  ConsoleInitInfo.CurDir = ConnectInfo->CurDir;
456 
457  /*
458  * Contrary to the case of SrvAllocConsole, the desktop string is
459  * allocated in the process' heap, so we need to retrieve it by
460  * using NtReadVirtualMemory.
461  */
462  if (ConnectInfo->DesktopLength)
463  {
464  ConsoleInitInfo.DesktopLength = ConnectInfo->DesktopLength;
465 
466  ConsoleInitInfo.Desktop = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
467  ConsoleInitInfo.DesktopLength);
468  if (ConsoleInitInfo.Desktop == NULL)
469  return STATUS_NO_MEMORY;
470 
472  ConnectInfo->Desktop,
473  ConsoleInitInfo.Desktop,
474  ConsoleInitInfo.DesktopLength,
475  NULL);
476  if (!NT_SUCCESS(Status))
477  {
478  ConsoleFreeHeap(ConsoleInitInfo.Desktop);
479  return Status;
480  }
481  }
482 
483  /*
484  * We are about to create a new console. However when ConSrvNewProcess
485  * was called, we didn't know that we wanted to create a new console and
486  * therefore, we by default inherited the handles table from our parent
487  * process. It's only now that we notice that in fact we do not need
488  * them, because we've created a new console and thus we must use it.
489  *
490  * ConSrvAllocateConsole will free our old handles table
491  * and recreate a new valid one.
492  */
493 
494  /* Initialize a new Console owned by the Console Leader Process */
495  Status = ConSrvAllocateConsole(ProcessData,
496  &ConnectInfo->ConsoleStartInfo.InputHandle,
497  &ConnectInfo->ConsoleStartInfo.OutputHandle,
498  &ConnectInfo->ConsoleStartInfo.ErrorHandle,
499  &ConsoleInitInfo);
500 
501  /* Free our local desktop string if any */
502  if (ConsoleInitInfo.DesktopLength)
503  ConsoleFreeHeap(ConsoleInitInfo.Desktop);
504 
505  /* Check for success */
506  if (!NT_SUCCESS(Status))
507  {
508  DPRINT1("Console allocation failed\n");
509  return Status;
510  }
511  }
512  else /* We inherit it from the parent */
513  {
514  DPRINT("ConSrvConnect - Reuse current (parent's) console\n");
515 
516  /* Reuse our current console */
517  Status = ConSrvInheritConsole(ProcessData,
518  ConnectInfo->ConsoleStartInfo.ConsoleHandle,
519  FALSE,
520  NULL, // &ConnectInfo->ConsoleStartInfo.InputHandle,
521  NULL, // &ConnectInfo->ConsoleStartInfo.OutputHandle,
522  NULL, // &ConnectInfo->ConsoleStartInfo.ErrorHandle,
523  &ConnectInfo->ConsoleStartInfo);
524  if (!NT_SUCCESS(Status))
525  {
526  DPRINT1("Console inheritance failed\n");
527  return Status;
528  }
529  }
530 
531  /* Set the Property-Dialog handler */
532  ProcessData->PropRoutine = ConnectInfo->PropRoutine;
533 
534  return STATUS_SUCCESS;
535 }
HANDLE OutputHandle
Definition: conmsg.h:173
HANDLE ErrorHandle
Definition: conmsg.h:174
PWCHAR Desktop
Definition: console.h:19
PCONSOLE_START_INFO ConsoleStartInfo
Definition: console.h:13
BOOLEAN IsWindowVisible
Definition: conmsg.h:189
ULONG CurDirLength
Definition: console.h:22
CONSOLE_START_INFO ConsoleStartInfo
Definition: conmsg.h:186
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: consrv.h:52
LONG NTSTATUS
Definition: precomp.h:26
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
WCHAR AppName[128]
Definition: conmsg.h:204
NTSTATUS ConSrvInheritConsole(PCONSOLE_PROCESS_DATA ProcessData, HANDLE ConsoleHandle, BOOLEAN CreateNewHandlesTable, PHANDLE pInputHandle, PHANDLE pOutputHandle, PHANDLE pErrorHandle, PCONSOLE_START_INFO ConsoleStartInfo)
Definition: handle.c:605
ULONG AppNameLength
Definition: console.h:20
PWCHAR AppName
Definition: console.h:21
LPTHREAD_START_ROUTINE CtrlRoutine
Definition: conmsg.h:193
ULONG TitleLength
Definition: console.h:16
HANDLE ProcessHandle
Definition: csrsrv.h:46
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
PWCHAR ConsoleTitle
Definition: console.h:17
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
HANDLE ConsoleHandle
Definition: conmsg.h:170
PCSR_PROCESS Process
Definition: consrv.h:43
NTSTATUS NTAPI NtReadVirtualMemory(IN HANDLE ProcessHandle, IN PVOID BaseAddress, OUT PVOID Buffer, IN SIZE_T NumberOfBytesToRead, OUT PSIZE_T NumberOfBytesRead OPTIONAL)
Definition: virtual.c:2691
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
LPTHREAD_START_ROUTINE PropRoutine
Definition: consrv.h:53
LPTHREAD_START_ROUTINE PropRoutine
Definition: conmsg.h:194
ULONG DesktopLength
Definition: console.h:18
Status
Definition: gdiplustypes.h:24
BOOLEAN IsWindowVisible
Definition: console.h:14
WCHAR ConsoleTitle[MAX_PATH+1]
Definition: conmsg.h:198
HANDLE InputHandle
Definition: conmsg.h:172
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
WCHAR CurDir[MAX_PATH+1]
Definition: conmsg.h:206
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#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
#define ConsoleFreeHeap(HeapBase)
Definition: heap.h:15
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966
struct _CONSRV_API_CONNECTINFO * PCONSRV_API_CONNECTINFO

Referenced by CSR_SERVER_DLL_INIT().

◆ ConSrvDisconnect()

VOID NTAPI ConSrvDisconnect ( IN PCSR_PROCESS  CsrProcess)

Definition at line 539 of file init.c.

540 {
541  PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrProcess);
542 
543  /**************************************************************************
544  * This function is called whenever a new process (GUI or CUI) is destroyed.
545  **************************************************************************/
546 
547  if ( ProcessData->ConsoleHandle != NULL ||
548  ProcessData->HandleTable != NULL )
549  {
550  DPRINT("ConSrvDisconnect - calling ConSrvRemoveConsole\n");
551  ConSrvRemoveConsole(ProcessData);
552  }
553 
555 }
HANDLE ConsoleHandle
Definition: consrv.h:45
NTSTATUS ConSrvRemoveConsole(PCONSOLE_PROCESS_DATA ProcessData)
Definition: handle.c:735
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
struct _CONSOLE_IO_HANDLE * HandleTable
Definition: consrv.h:50
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
RTL_CRITICAL_SECTION HandleTableLock
Definition: consrv.h:48

Referenced by CSR_SERVER_DLL_INIT().

◆ ConSrvInheritHandlesTable()

NTSTATUS ConSrvInheritHandlesTable ( IN PCONSOLE_PROCESS_DATA  SourceProcessData,
IN PCONSOLE_PROCESS_DATA  TargetProcessData 
)

Definition at line 203 of file handle.c.

205 {
207  ULONG i, j;
208 
209  RtlEnterCriticalSection(&SourceProcessData->HandleTableLock);
210 
211  /* Inherit a handles table only if there is no already */
212  if (TargetProcessData->HandleTable != NULL /* || TargetProcessData->HandleTableSize != 0 */)
213  {
215  goto Quit;
216  }
217 
218  /* Allocate a new handle table for the child process */
219  TargetProcessData->HandleTable = ConsoleAllocHeap(HEAP_ZERO_MEMORY,
220  SourceProcessData->HandleTableSize
221  * sizeof(CONSOLE_IO_HANDLE));
222  if (TargetProcessData->HandleTable == NULL)
223  {
225  goto Quit;
226  }
227 
228  TargetProcessData->HandleTableSize = SourceProcessData->HandleTableSize;
229 
230  /*
231  * Parse the parent process' handles table and, for each handle,
232  * do a copy of it and reference it, if the handle is inheritable.
233  */
234  for (i = 0, j = 0; i < SourceProcessData->HandleTableSize; i++)
235  {
236  if (SourceProcessData->HandleTable[i].Object != NULL &&
237  SourceProcessData->HandleTable[i].Inheritable)
238  {
239  /*
240  * Copy the handle data and increment the reference count of the
241  * pointed object (via the call to ConSrvCreateHandleEntry == AdjustHandleCounts).
242  */
243  TargetProcessData->HandleTable[j] = SourceProcessData->HandleTable[i];
244  AdjustHandleCounts(&TargetProcessData->HandleTable[j], +1);
245  ++j;
246  }
247  }
248 
249 Quit:
250  RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock);
251  return Status;
252 }
static LONG AdjustHandleCounts(IN PCONSOLE_IO_HANDLE Handle, IN LONG Change)
Definition: handle.c:35
LONG NTSTATUS
Definition: precomp.h:26
#define ConsoleAllocHeap(Flags, Size)
Definition: heap.h:14
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
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
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
smooth NULL
Definition: ftsmooth.c:416
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 GLint GLint j
Definition: glfuncs.h:250
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
Status
Definition: gdiplustypes.h:24
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
unsigned int ULONG
Definition: retypes.h:1
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by ConSrvNewProcess().

◆ ConSrvNewProcess()

NTSTATUS NTAPI ConSrvNewProcess ( PCSR_PROCESS  SourceProcess,
PCSR_PROCESS  TargetProcess 
)

Definition at line 330 of file init.c.

332 {
333  /**************************************************************************
334  * This function is called whenever a new process (GUI or CUI) is created.
335  *
336  * Copy the parent's handles table here if both the parent and the child
337  * processes are CUI. If we must actually create our proper console (and
338  * thus do not inherit from the console handles of the parent's), then we
339  * will clean this table in the next ConSrvConnect call. Why we are doing
340  * this? It's because here, we still don't know whether or not we must create
341  * a new console instead of inherit it from the parent, and, because in
342  * ConSrvConnect we don't have any reference to the parent process anymore.
343  **************************************************************************/
344 
346  PCONSOLE_PROCESS_DATA TargetProcessData;
347 
348  /* An empty target process is invalid */
349  if (!TargetProcess) return STATUS_INVALID_PARAMETER;
350 
351  TargetProcessData = ConsoleGetPerProcessData(TargetProcess);
352 
353  /* Initialize the new (target) process */
354  RtlZeroMemory(TargetProcessData, sizeof(*TargetProcessData));
355  TargetProcessData->Process = TargetProcess;
356  TargetProcessData->ConsoleHandle = NULL;
357  TargetProcessData->ConsoleApp = FALSE;
358 
359  /*
360  * The handles table gets initialized either when inheriting from
361  * another console process, or when creating a new console.
362  */
363  TargetProcessData->HandleTableSize = 0;
364  TargetProcessData->HandleTable = NULL;
365 
366  RtlInitializeCriticalSection(&TargetProcessData->HandleTableLock);
367 
368  /* Do nothing if the source process is NULL */
369  if (!SourceProcess) return STATUS_SUCCESS;
370 
371  // SourceProcessData = ConsoleGetPerProcessData(SourceProcess);
372 
373  /*
374  * If the child process is a console application and the parent process is
375  * either a console application or just has a valid console (with a valid
376  * handles table: this can happen if it is a GUI application having called
377  * AllocConsole), then try to inherit handles from the parent process.
378  */
379  if (TargetProcess->Flags & CsrProcessIsConsoleApp /* && SourceProcessData->ConsoleHandle != NULL */)
380  {
381  PCONSOLE_PROCESS_DATA SourceProcessData = ConsoleGetPerProcessData(SourceProcess);
382  PCONSRV_CONSOLE SourceConsole;
383 
384  /* Validate and lock the parent's console */
385  if (ConSrvValidateConsole(&SourceConsole,
386  SourceProcessData->ConsoleHandle,
388  {
389  /* Inherit the parent's handles table */
390  Status = ConSrvInheritHandlesTable(SourceProcessData, TargetProcessData);
391  if (!NT_SUCCESS(Status))
392  {
393  DPRINT1("Inheriting handles table failed\n");
394  }
395 
396  /* Unlock the parent's console */
397  LeaveCriticalSection(&SourceConsole->Lock);
398  }
399  }
400 
401  return Status;
402 }
HANDLE ConsoleHandle
Definition: consrv.h:45
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define PCONSRV_CONSOLE
Definition: conio.h:27
NTSTATUS ConSrvInheritHandlesTable(IN PCONSOLE_PROCESS_DATA SourceProcessData, IN PCONSOLE_PROCESS_DATA TargetProcessData)
Definition: handle.c:203
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
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ConsoleGetPerProcessData(Process)
Definition: consrv.h:37
BOOLEAN ConsoleApp
Definition: consrv.h:46
PCSR_PROCESS Process
Definition: consrv.h:43
Status
Definition: gdiplustypes.h:24
struct _CONSOLE_IO_HANDLE * HandleTable
Definition: consrv.h:50
#define DPRINT1
Definition: precomp.h:8
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
ULONG Flags
Definition: csrsrv.h:48
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
ULONG HandleTableSize
Definition: consrv.h:49
return STATUS_SUCCESS
Definition: btrfs.c:2966
RTL_CRITICAL_SECTION HandleTableLock
Definition: consrv.h:48

Referenced by CSR_SERVER_DLL_INIT().

◆ CSR_SERVER_DLL_INIT()

CSR_SERVER_DLL_INIT ( ConServerDllInitialization  )

Definition at line 557 of file init.c.

558 {
559  /* Initialize the memory */
560  ConSrvHeap = RtlGetProcessHeap();
561 /*
562  // We can use our own heap instead of the CSR heap to investigate heap corruptions :)
563  ConSrvHeap = RtlCreateHeap(HEAP_GROWABLE |
564  HEAP_PROTECTION_ENABLED |
565  HEAP_FREE_CHECKING_ENABLED |
566  HEAP_TAIL_CHECKING_ENABLED |
567  HEAP_VALIDATE_ALL_ENABLED,
568  NULL, 0, 0, NULL, NULL);
569  if (!ConSrvHeap) return STATUS_NO_MEMORY;
570 */
571 
574 
575  /* Setup the DLL Object */
576  LoadedServerDll->ApiBase = CONSRV_FIRST_API_NUMBER;
577  LoadedServerDll->HighestApiSupported = ConsolepMaxApiNumber;
578  LoadedServerDll->DispatchTable = ConsoleServerApiDispatchTable;
579  LoadedServerDll->ValidTable = ConsoleServerApiServerValidTable;
580 #ifdef CSR_DBG
581  LoadedServerDll->NameTable = ConsoleServerApiNameTable;
582 #endif
583  LoadedServerDll->SizeOfProcessData = sizeof(CONSOLE_PROCESS_DATA);
584  LoadedServerDll->ConnectCallback = ConSrvConnect;
585  LoadedServerDll->DisconnectCallback = ConSrvDisconnect;
586  LoadedServerDll->NewProcessCallback = ConSrvNewProcess;
587  // LoadedServerDll->HardErrorCallback = ConSrvHardError;
588  LoadedServerDll->ShutdownProcessCallback = ConsoleClientShutdown;
589 
590  ConSrvDllInstance = LoadedServerDll->ServerHandle;
591 
592  /* All done */
593  return STATUS_SUCCESS;
594 }
PCSR_API_ROUTINE ConsoleServerApiDispatchTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER]
Definition: init.c:27
VOID NTAPI ConDrvInitConsoleSupport(VOID)
Definition: console.c:150
VOID NTAPI ConSrvInitConsoleSupport(VOID)
Definition: console.c:327
PCHAR ConsoleServerApiNameTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER]
Definition: init.c:212
HINSTANCE ConSrvDllInstance
Definition: init.c:21
BOOLEAN ConsoleServerApiServerValidTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER]
Definition: init.c:123
NTSTATUS NTAPI ConSrvConnect(IN PCSR_PROCESS CsrProcess, IN OUT PVOID ConnectionInfo, IN OUT PULONG ConnectionInfoLength)
Definition: init.c:406
HANDLE ConSrvHeap
Definition: init.c:24
VOID NTAPI ConSrvDisconnect(IN PCSR_PROCESS CsrProcess)
Definition: init.c:539
struct _CONSOLE_PROCESS_DATA CONSOLE_PROCESS_DATA
ULONG NTAPI ConsoleClientShutdown(IN PCSR_PROCESS CsrProcess, IN ULONG Flags, IN BOOLEAN FirstPhase)
Definition: shutdown.c:73
#define CONSRV_FIRST_API_NUMBER
Definition: conmsg.h:16
NTSTATUS NTAPI ConSrvNewProcess(PCSR_PROCESS SourceProcess, PCSR_PROCESS TargetProcess)
Definition: init.c:330
return STATUS_SUCCESS
Definition: btrfs.c:2966

Variable Documentation

◆ ConsoleServerApiDispatchTable

Definition at line 27 of file init.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ ConsoleServerApiServerValidTable

BOOLEAN ConsoleServerApiServerValidTable[ConsolepMaxApiNumber - CONSRV_FIRST_API_NUMBER]

Definition at line 123 of file init.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ ConSrvDllInstance

HINSTANCE ConSrvDllInstance = NULL

Definition at line 21 of file init.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ ConSrvHeap

HANDLE ConSrvHeap = NULL

Definition at line 24 of file init.c.

Referenced by CSR_SERVER_DLL_INIT().