ReactOS  r76032
connect.c File Reference
#include <ntdll.h>
#include <ndk/lpcfuncs.h>
#include <csr/csrsrv.h>
#include <debug.h>
Include dependency graph for connect.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define UNICODE_PATH_SEP   L"\\"
 

Typedefs

typedef NTSTATUS(NTAPIPCSR_SERVER_API_ROUTINE )(IN PPORT_MESSAGE Request, IN PPORT_MESSAGE Reply)
 

Functions

NTSTATUS NTAPI CsrpConnectToServer (IN PWSTR ObjectDirectory)
 
NTSTATUS NTAPI CsrClientConnectToServer (IN PWSTR ObjectDirectory, IN ULONG ServerId, IN PVOID ConnectionInfo, IN OUT PULONG ConnectionInfoSize, OUT PBOOLEAN ServerToServerCall)
 
NTSTATUS NTAPI CsrClientCallServer (IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
 
HANDLE NTAPI CsrGetProcessId (VOID)
 

Variables

HANDLE CsrApiPort
 
HANDLE CsrProcessId
 
HANDLE CsrPortHeap
 
ULONG_PTR CsrPortMemoryDelta
 
BOOLEAN InsideCsrProcess = FALSE
 
PCSR_SERVER_API_ROUTINE CsrServerApiRoutine
 

Macro Definition Documentation

#define NDEBUG

Definition at line 16 of file connect.c.

#define UNICODE_PATH_SEP   L"\\"

Definition at line 33 of file connect.c.

Referenced by CsrApiPortInitialize(), CsrpConnectToServer(), and CsrSbApiPortInitialize().

Typedef Documentation

typedef NTSTATUS(NTAPI * PCSR_SERVER_API_ROUTINE)(IN PPORT_MESSAGE Request, IN PPORT_MESSAGE Reply)

Definition at line 28 of file connect.c.

Function Documentation

NTSTATUS NTAPI CsrClientCallServer ( IN OUT PCSR_API_MESSAGE  ApiMessage,
IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer  OPTIONAL,
IN CSR_API_NUMBER  ApiNumber,
IN ULONG  DataLength 
)

Definition at line 360 of file connect.c.

Referenced by BaseCheckForVDM(), BaseCheckVDM(), BasepNotifyCsrOfThread(), BaseUpdateVDMEntry(), CloseConsoleHandle(), ConsoleMenuControl(), CreateConsoleScreenBuffer(), CreateProcessInternalW(), CsrClientConnectToServer(), CsrIdentifyAlertableThread(), CsrSetPriorityClass(), DefineDosDeviceW(), DuplicateConsoleHandle(), EndTask(), ExitProcess(), ExitVDM(), ExitWindowsWorker(), FlushConsoleInputBuffer(), FreeConsole(), GenerateConsoleCtrlEvent(), GetConsoleCP(), GetConsoleCursorInfo(), GetConsoleDisplayMode(), GetConsoleFontInfo(), GetConsoleFontSize(), GetConsoleHandleInformation(), GetConsoleHardwareState(), GetConsoleMode(), GetConsoleOutputCP(), GetConsoleProcessList(), GetConsoleScreenBufferInfo(), GetConsoleSelectionInfo(), GetConsoleWindow(), GetCurrentConsoleFont(), GetLargestConsoleWindowSize(), GetNextVDMCommand(), GetNumberOfConsoleFonts(), GetNumberOfConsoleInputEvents(), GetNumberOfConsoleMouseButtons(), GetProcessShutdownParameters(), GetTempFileNameW(), GetThreadDesktop(), GetVDMCurrentDirectories(), IntAddConsoleAlias(), IntAllocConsole(), IntAttachConsole(), IntExpungeConsoleCommandHistory(), IntFillConsoleOutputCode(), IntGetConsoleAlias(), IntGetConsoleAliases(), IntGetConsoleAliasesLength(), IntGetConsoleAliasExes(), IntGetConsoleAliasExesLength(), IntGetConsoleCommandHistory(), IntGetConsoleCommandHistoryLength(), IntGetConsoleInput(), IntGetConsoleKeyboardLayoutName(), IntGetConsoleTitle(), IntReadConsole(), IntReadConsoleOutput(), IntReadConsoleOutputCode(), IntScrollConsoleScreenBuffer(), IntSetConsoleNumberOfCommands(), IntSetConsoleTitle(), IntWriteConsole(), IntWriteConsoleInput(), IntWriteConsoleOutput(), IntWriteConsoleOutputCode(), InvalidateConsoleDIBits(), Logon(), NotifySoundSentry(), OpenConsoleW(), RegisterConsoleVDM(), RegisterLogonProcess(), RegisterServicesProcess(), SetConsoleActiveScreenBuffer(), SetConsoleCommandHistoryMode(), SetConsoleCP(), SetConsoleCursor(), SetConsoleCursorInfo(), SetConsoleCursorPosition(), SetConsoleDisplayMode(), SetConsoleFont(), SetConsoleHandleInformation(), SetConsoleHardwareState(), SetConsoleIcon(), SetConsoleMenuClose(), SetConsoleMode(), SetConsoleOutputCP(), SetConsolePalette(), SetConsoleScreenBufferSize(), SetConsoleTextAttribute(), SetConsoleWindowInfo(), SetLastConsoleEventActive(), SetProcessShutdownParameters(), SetVDMCurrentDirectories(), ShowConsoleCursor(), and VerifyConsoleIoHandle().

364 {
366  ULONG PointerCount;
367  PULONG_PTR OffsetPointer;
368 
369  /* Fill out the Port Message Header */
370  ApiMessage->Header.u2.ZeroInit = 0;
371  ApiMessage->Header.u1.s1.TotalLength = DataLength +
372  sizeof(CSR_API_MESSAGE) - sizeof(ApiMessage->Data); // FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength;
373  ApiMessage->Header.u1.s1.DataLength = DataLength +
374  FIELD_OFFSET(CSR_API_MESSAGE, Data) - sizeof(ApiMessage->Header); // ApiMessage->Header.u1.s1.TotalLength - sizeof(PORT_MESSAGE);
375 
376  /* Fill out the CSR Header */
377  ApiMessage->ApiNumber = ApiNumber;
378  ApiMessage->CsrCaptureData = NULL;
379 
380  DPRINT("API: %lx, u1.s1.DataLength: %x, u1.s1.TotalLength: %x\n",
381  ApiNumber,
382  ApiMessage->Header.u1.s1.DataLength,
383  ApiMessage->Header.u1.s1.TotalLength);
384 
385  /* Check if we are already inside a CSR Server */
386  if (!InsideCsrProcess)
387  {
388  /* Check if we got a Capture Buffer */
389  if (CaptureBuffer)
390  {
391  /*
392  * We have to convert from our local (client) view
393  * to the remote (server) view.
394  */
395  ApiMessage->CsrCaptureData = (PCSR_CAPTURE_BUFFER)
396  ((ULONG_PTR)CaptureBuffer + CsrPortMemoryDelta);
397 
398  /* Lock the buffer. */
399  CaptureBuffer->BufferEnd = NULL;
400 
401  /*
402  * Each client pointer inside the CSR message is converted into
403  * a server pointer, and each pointer to these message pointers
404  * is converted into an offset.
405  */
406  PointerCount = CaptureBuffer->PointerCount;
407  OffsetPointer = CaptureBuffer->PointerOffsetsArray;
408  while (PointerCount--)
409  {
410  if (*OffsetPointer != 0)
411  {
412  *(PULONG_PTR)*OffsetPointer += CsrPortMemoryDelta;
413  *OffsetPointer -= (ULONG_PTR)ApiMessage;
414  }
415  ++OffsetPointer;
416  }
417  }
418 
419  /* Send the LPC Message */
421  &ApiMessage->Header,
422  &ApiMessage->Header);
423 
424  /* Check if we got a Capture Buffer */
425  if (CaptureBuffer)
426  {
427  /*
428  * We have to convert back from the remote (server) view
429  * to our local (client) view.
430  */
431  ApiMessage->CsrCaptureData = (PCSR_CAPTURE_BUFFER)
432  ((ULONG_PTR)ApiMessage->CsrCaptureData - CsrPortMemoryDelta);
433 
434  /*
435  * Convert back the offsets into pointers to CSR message
436  * pointers, and convert back these message server pointers
437  * into client pointers.
438  */
439  PointerCount = CaptureBuffer->PointerCount;
440  OffsetPointer = CaptureBuffer->PointerOffsetsArray;
441  while (PointerCount--)
442  {
443  if (*OffsetPointer != 0)
444  {
445  *OffsetPointer += (ULONG_PTR)ApiMessage;
446  *(PULONG_PTR)*OffsetPointer -= CsrPortMemoryDelta;
447  }
448  ++OffsetPointer;
449  }
450  }
451 
452  /* Check for success */
453  if (!NT_SUCCESS(Status))
454  {
455  /* We failed. Overwrite the return value with the failure. */
456  DPRINT1("LPC Failed: %lx\n", Status);
457  ApiMessage->Status = Status;
458  }
459  }
460  else
461  {
462  /* This is a server-to-server call. Save our CID and do a direct call. */
463  DPRINT("Next gen server-to-server call\n");
464 
465  /* We check this equality inside CsrValidateMessageBuffer */
466  ApiMessage->Header.ClientId = NtCurrentTeb()->ClientId;
467 
468  Status = CsrServerApiRoutine(&ApiMessage->Header,
469  &ApiMessage->Header);
470 
471  /* Check for success */
472  if (!NT_SUCCESS(Status))
473  {
474  /* We failed. Overwrite the return value with the failure. */
475  ApiMessage->Status = Status;
476  }
477  }
478 
479  /* Return the CSR Result */
480  DPRINT("Got back: 0x%lx\n", ApiMessage->Status);
481  return ApiMessage->Status;
482 }
PCSR_SERVER_API_ROUTINE CsrServerApiRoutine
Definition: connect.c:31
NTSTATUS NTAPI NtRequestWaitReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE LpcRequest, IN OUT PPORT_MESSAGE LpcReply)
Definition: send.c:695
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:557
void DPRINT(...)
Definition: polytest.cpp:61
struct _CSR_CAPTURE_BUFFER * PCSR_CAPTURE_BUFFER
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
BOOLEAN InsideCsrProcess
Definition: connect.c:25
ULONG_PTR CsrPortMemoryDelta
Definition: connect.c:24
Status
Definition: gdiplustypes.h:24
LONG NTSTATUS
Definition: DriverTester.h:11
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
HANDLE CsrApiPort
Definition: connect.c:21
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
struct _CSR_API_MESSAGE CSR_API_MESSAGE
NTSTATUS NTAPI CsrClientConnectToServer ( IN PWSTR  ObjectDirectory,
IN ULONG  ServerId,
IN PVOID  ConnectionInfo,
IN OUT PULONG  ConnectionInfoSize,
OUT PBOOLEAN  ServerToServerCall 
)

Definition at line 192 of file connect.c.

Referenced by ConnectConsole(), and DllMain().

197 {
199  PIMAGE_NT_HEADERS NtHeader;
200  UNICODE_STRING CsrSrvName;
201  HANDLE hCsrSrv;
202  ANSI_STRING CsrServerRoutineName;
203  CSR_API_MESSAGE ApiMessage;
204  PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage.Data.CsrClientConnect;
205  PCSR_CAPTURE_BUFFER CaptureBuffer;
206 
207  DPRINT("CsrClientConnectToServer: %lx %p\n", ServerId, ConnectionInfo);
208 
209  /* Validate the Connection Info */
210  if (ConnectionInfo && (!ConnectionInfoSize || !*ConnectionInfoSize))
211  {
212  DPRINT1("Connection info given, but no length\n");
214  }
215 
216  /* Check if we're inside a CSR Process */
217  if (InsideCsrProcess)
218  {
219  /* Tell the client that we're already inside CSR */
220  if (ServerToServerCall) *ServerToServerCall = TRUE;
221  return STATUS_SUCCESS;
222  }
223 
224  /*
225  * We might be in a CSR Process but not know it, if this is the first call.
226  * So let's find out.
227  */
228  if (!(NtHeader = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress)))
229  {
230  /* The image isn't valid */
231  DPRINT1("Invalid image\n");
233  }
235 
236  /* Now we can check if we are inside or not */
237  if (InsideCsrProcess)
238  {
239  /* We're inside, so let's find csrsrv */
240  DPRINT("Next-GEN CSRSS support\n");
241  RtlInitUnicodeString(&CsrSrvName, L"csrsrv");
242  Status = LdrGetDllHandle(NULL,
243  NULL,
244  &CsrSrvName,
245  &hCsrSrv);
246 
247  /* Now get the Server to Server routine */
248  RtlInitAnsiString(&CsrServerRoutineName, "CsrCallServerFromServer");
249  Status = LdrGetProcedureAddress(hCsrSrv,
250  &CsrServerRoutineName,
251  0L,
253 
254  /* Use the local heap as port heap */
255  CsrPortHeap = RtlGetProcessHeap();
256 
257  /* Tell the caller we're inside the server */
258  if (ServerToServerCall) *ServerToServerCall = InsideCsrProcess;
259  return STATUS_SUCCESS;
260  }
261 
262  /* Now check if connection info is given */
263  if (ConnectionInfo)
264  {
265  /* Well, we're definitely in a client now */
267 
268  /* Do we have a connection to CSR yet? */
269  if (!CsrApiPort)
270  {
271  /* No, set it up now */
272  Status = CsrpConnectToServer(ObjectDirectory);
273  if (!NT_SUCCESS(Status))
274  {
275  /* Failed */
276  DPRINT1("Failure to connect to CSR\n");
277  return Status;
278  }
279  }
280 
281  /* Setup the connect message header */
282  ClientConnect->ServerId = ServerId;
283  ClientConnect->ConnectionInfoSize = *ConnectionInfoSize;
284 
285  /* Setup a buffer for the connection info */
286  CaptureBuffer = CsrAllocateCaptureBuffer(1, ClientConnect->ConnectionInfoSize);
287  if (CaptureBuffer == NULL)
288  {
290  }
291 
292  /* Capture the connection info data */
293  CsrCaptureMessageBuffer(CaptureBuffer,
294  ConnectionInfo,
295  ClientConnect->ConnectionInfoSize,
296  &ClientConnect->ConnectionInfo);
297 
298  /* Return the allocated length */
299  *ConnectionInfoSize = ClientConnect->ConnectionInfoSize;
300 
301  /* Call CSR */
302  Status = CsrClientCallServer(&ApiMessage,
303  CaptureBuffer,
305  sizeof(CSR_CLIENT_CONNECT));
306 
307  /* Copy the updated connection info data back into the user buffer */
308  RtlMoveMemory(ConnectionInfo,
309  ClientConnect->ConnectionInfo,
310  *ConnectionInfoSize);
311 
312  /* Free the capture buffer */
313  CsrFreeCaptureBuffer(CaptureBuffer);
314  }
315  else
316  {
317  /* No connection info, just return */
318  Status = STATUS_SUCCESS;
319  }
320 
321  /* Let the caller know if this was server to server */
322  DPRINT("Status was: 0x%lx. Are we in server: 0x%x\n", Status, InsideCsrProcess);
323  if (ServerToServerCall) *ServerToServerCall = InsideCsrProcess;
324 
325  return Status;
326 }
DWORD *typedef PVOID
Definition: winlogon.h:52
VOID NTAPI CsrFreeCaptureBuffer(IN PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:189
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS NTAPI LdrGetDllHandle(IN PWSTR DllPath OPTIONAL, IN PULONG DllCharacteristics OPTIONAL, IN PUNICODE_STRING DllName, OUT PVOID *DllHandle)
Definition: ldrapi.c:798
PCSR_SERVER_API_ROUTINE CsrServerApiRoutine
Definition: connect.c:31
union _CSR_API_MESSAGE::@3138::@3140::@3142 Data
Definition: bidi.c:75
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(IN ULONG ArgumentCount, IN ULONG BufferSize)
Definition: capture.c:90
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
return STATUS_SUCCESS
Definition: btrfs.c:2664
NTSTATUS NTAPI CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
Definition: connect.c:360
PVOID ConnectionInfo
Definition: csrmsg.h:88
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:263
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
VOID NTAPI CsrCaptureMessageBuffer(IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer, IN PVOID MessageBuffer OPTIONAL, IN ULONG MessageLength, OUT PVOID *CapturedData)
Definition: capture.c:169
#define FALSE
Definition: types.h:117
NTSTATUS NTAPI LdrGetProcedureAddress(IN PVOID BaseAddress, IN PANSI_STRING Name, IN ULONG Ordinal, OUT PVOID *ProcedureAddress)
Definition: ldrapi.c:816
smooth NULL
Definition: ftsmooth.c:557
#define IMAGE_SUBSYSTEM_NATIVE
Definition: ntimage.h:436
void DPRINT(...)
Definition: polytest.cpp:61
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:345
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
ULONG ConnectionInfoSize
Definition: csrmsg.h:89
BOOLEAN InsideCsrProcess
Definition: connect.c:25
NTSTATUS NTAPI CsrpConnectToServer(IN PWSTR ObjectDirectory)
Definition: connect.c:39
Status
Definition: gdiplustypes.h:24
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
#define CSRSRV_SERVERDLL_INDEX
Definition: csrmsg.h:20
HANDLE CsrApiPort
Definition: connect.c:21
#define DPRINT1
Definition: precomp.h:8
#define RtlImageNtHeader
Definition: compat.h:457
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define NtCurrentPeb()
Definition: rtlfuncs.h:1073
HANDLE CsrPortHeap
Definition: connect.c:23
HANDLE NTAPI CsrGetProcessId ( VOID  )

Definition at line 489 of file connect.c.

Referenced by ProcessIdToHandle().

490 {
491  return CsrProcessId;
492 }
HANDLE CsrProcessId
Definition: connect.c:22
NTSTATUS NTAPI CsrpConnectToServer ( IN PWSTR  ObjectDirectory)

Definition at line 39 of file connect.c.

Referenced by CsrClientConnectToServer().

40 {
42  ULONG PortNameLength;
44  LARGE_INTEGER CsrSectionViewSize;
45  HANDLE CsrSectionHandle;
46  PORT_VIEW LpcWrite;
47  REMOTE_PORT_VIEW LpcRead;
48  SECURITY_QUALITY_OF_SERVICE SecurityQos;
50  PSID SystemSid = NULL;
51  CSR_API_CONNECTINFO ConnectionInfo;
52  ULONG ConnectionInfoLength = sizeof(CSR_API_CONNECTINFO);
53 
54  DPRINT("%s(%S)\n", __FUNCTION__, ObjectDirectory);
55 
56  /* Binary compatibility with MS KERNEL32 */
57  if (NULL == ObjectDirectory)
58  {
59  ObjectDirectory = L"\\Windows";
60  }
61 
62  /* Calculate the total port name size */
63  PortNameLength = ((wcslen(ObjectDirectory) + 1) * sizeof(WCHAR)) +
64  sizeof(CSR_PORT_NAME);
65 
66  /* Set the port name */
67  PortName.Length = 0;
68  PortName.MaximumLength = PortNameLength;
69 
70  /* Allocate a buffer for it */
71  PortName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, PortNameLength);
72  if (PortName.Buffer == NULL)
73  {
75  }
76 
77  /* Create the name */
78  RtlAppendUnicodeToString(&PortName, ObjectDirectory );
81 
82  /* Create a section for the port memory */
83  CsrSectionViewSize.QuadPart = CSR_CSRSS_SECTION_SIZE;
84  Status = NtCreateSection(&CsrSectionHandle,
86  NULL,
87  &CsrSectionViewSize,
90  NULL);
91  if (!NT_SUCCESS(Status))
92  {
93  DPRINT1("Failure allocating CSR Section\n");
94  return Status;
95  }
96 
97  /* Set up the port view structures to match them with the section */
98  LpcWrite.Length = sizeof(PORT_VIEW);
99  LpcWrite.SectionHandle = CsrSectionHandle;
100  LpcWrite.SectionOffset = 0;
101  LpcWrite.ViewSize = CsrSectionViewSize.u.LowPart;
102  LpcWrite.ViewBase = 0;
103  LpcWrite.ViewRemoteBase = 0;
104  LpcRead.Length = sizeof(REMOTE_PORT_VIEW);
105  LpcRead.ViewSize = 0;
106  LpcRead.ViewBase = 0;
107 
108  /* Setup the QoS */
111  SecurityQos.EffectiveOnly = TRUE;
112 
113  /* Setup the connection info */
114  ConnectionInfo.DebugFlags = 0;
115 
116  /* Create a SID for us */
117  Status = RtlAllocateAndInitializeSid(&NtSidAuthority,
118  1,
120  0,
121  0,
122  0,
123  0,
124  0,
125  0,
126  0,
127  &SystemSid);
128  if (!NT_SUCCESS(Status))
129  {
130  /* Failure */
131  DPRINT1("Couldn't allocate SID\n");
132  NtClose(CsrSectionHandle);
133  return Status;
134  }
135 
136  /* Connect to the port */
138  &PortName,
139  &SecurityQos,
140  &LpcWrite,
141  SystemSid,
142  &LpcRead,
143  NULL,
144  &ConnectionInfo,
145  &ConnectionInfoLength);
146  RtlFreeSid(SystemSid);
147  NtClose(CsrSectionHandle);
148  if (!NT_SUCCESS(Status))
149  {
150  /* Failure */
151  DPRINT1("Couldn't connect to CSR port\n");
152  return Status;
153  }
154 
155  /* Save the delta between the sections, for capture usage later */
157  (ULONG_PTR)LpcWrite.ViewBase;
158 
159  /* Save the Process */
160  CsrProcessId = ConnectionInfo.ServerProcessId;
161 
162  /* Save CSR Section data */
163  NtCurrentPeb()->ReadOnlySharedMemoryBase = ConnectionInfo.SharedSectionBase;
164  NtCurrentPeb()->ReadOnlySharedMemoryHeap = ConnectionInfo.SharedSectionHeap;
165  NtCurrentPeb()->ReadOnlyStaticServerData = ConnectionInfo.SharedStaticServerData;
166 
167  /* Create the port heap */
169  LpcWrite.ViewBase,
170  LpcWrite.ViewSize,
171  PAGE_SIZE,
172  0,
173  0);
174  if (CsrPortHeap == NULL)
175  {
176  /* Failure */
177  DPRINT1("Couldn't create heap for CSR port\n");
179  CsrApiPort = NULL;
181  }
182 
183  /* Return success */
184  return STATUS_SUCCESS;
185 }
struct _PORT_VIEW PORT_VIEW
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:546
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3369
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: bidi.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
HANDLE CsrProcessId
Definition: connect.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2664
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
PVOID SharedStaticServerData
Definition: csrmsg.h:51
#define CSR_PORT_NAME
Definition: csrmsg.h:17
ULONG SectionOffset
NTSYSAPI NTSTATUS NTAPI RtlAllocateAndInitializeSid(IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount, IN ULONG SubAuthority0, IN ULONG SubAuthority1, IN ULONG SubAuthority2, IN ULONG SubAuthority3, IN ULONG SubAuthority4, IN ULONG SubAuthority5, IN ULONG SubAuthority6, IN ULONG SubAuthority7, OUT PSID *Sid)
Definition: sid.c:290
struct _LARGE_INTEGER::@2037 u
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID SharedSectionBase
Definition: csrmsg.h:50
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
HANDLE ServerProcessId
Definition: csrmsg.h:57
NTSTATUS NTAPI NtSecureConnectPort(OUT PHANDLE PortHandle, IN PUNICODE_STRING PortName, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, IN OUT PPORT_VIEW ClientView OPTIONAL, IN PSID ServerSid OPTIONAL, IN OUT PREMOTE_PORT_VIEW ServerView OPTIONAL, OUT PULONG MaxMessageLength OPTIONAL, IN OUT PVOID ConnectionInformation OPTIONAL, IN OUT PULONG ConnectionInformationLength OPTIONAL)
Definition: connect.c:80
PVOID SharedSectionHeap
Definition: csrmsg.h:52
#define SEC_RESERVE
Definition: nt_native.h:1323
LPC_PVOID ViewRemoteBase
smooth NULL
Definition: ftsmooth.c:557
static SID_IDENTIFIER_AUTHORITY NtSidAuthority
Definition: samrpc.c:14
struct _REMOTE_PORT_VIEW REMOTE_PORT_VIEW
void DPRINT(...)
Definition: polytest.cpp:61
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:526
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:585
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
LPC_SIZE_T ViewSize
struct _CSR_API_CONNECTINFO CSR_API_CONNECTINFO
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3392
#define CSR_CSRSS_SECTION_SIZE
Definition: csrsrv.h:27
ULONG_PTR CsrPortMemoryDelta
Definition: connect.c:24
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103
NTSYSAPI PVOID NTAPI RtlCreateHeap(IN ULONG Flags, IN PVOID HeapBase OPTIONAL, IN ULONG ReserveSize OPTIONAL, IN ULONG CommitSize OPTIONAL, IN PVOID Lock OPTIONAL, IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL)
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Status
Definition: gdiplustypes.h:24
LPC_PVOID ViewBase
DWORD *typedef HANDLE
Definition: winlogon.h:52
LONG NTSTATUS
Definition: DriverTester.h:11
#define UNICODE_PATH_SEP
Definition: connect.c:33
HANDLE CsrApiPort
Definition: connect.c:21
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: lsa.idl:65
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
#define __FUNCTION__
Definition: compiler.h:205
LPC_HANDLE SectionHandle
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LONGLONG QuadPart
Definition: typedefs.h:112
#define NtCurrentPeb()
Definition: rtlfuncs.h:1073
#define PAGE_READWRITE
Definition: nt_native.h:1304
IN PUNICODE_STRING PortName
Definition: conport.c:35
HANDLE CsrPortHeap
Definition: connect.c:23

Variable Documentation

HANDLE CsrApiPort

Definition at line 21 of file connect.c.

Referenced by CsrClientCallServer(), CsrClientConnectToServer(), and CsrpConnectToServer().

ULONG_PTR CsrPortMemoryDelta

Definition at line 24 of file connect.c.

Referenced by CsrClientCallServer(), and CsrpConnectToServer().

HANDLE CsrProcessId

Definition at line 22 of file connect.c.

Referenced by CsrGetProcessId(), and CsrpConnectToServer().

PCSR_SERVER_API_ROUTINE CsrServerApiRoutine

Definition at line 31 of file connect.c.

Referenced by CsrClientCallServer().

BOOLEAN InsideCsrProcess = FALSE

Definition at line 25 of file connect.c.

Referenced by CsrClientCallServer(), and CsrClientConnectToServer().