ReactOS 0.4.17-dev-1190-g4c812f4
connect.c File Reference
#include "csrlib.h"
#include <ndk/ldrfuncs.h>
#include <ndk/lpcfuncs.h>
#include <ndk/mmfuncs.h>
#include <ndk/obfuncs.h>
#include <ndk/umfuncs.h>
#include <csrsrv.h>
#include <debug.h>
Include dependency graph for connect.c:

Go to the source code of this file.

Macros

#define NTOS_MODE_USER
 
#define NDEBUG
 

Typedefs

typedef NTSTATUS(NTAPI * PCSR_SERVER_API_ROUTINE) (_In_ PCSR_API_MESSAGE Request, _Inout_ PCSR_API_MESSAGE Reply)
 

Functions

static NTSTATUS CsrpConnectToServer (_In_ PCWSTR ObjectDirectory)
 
NTSTATUS NTAPI CsrClientConnectToServer (_In_ PCWSTR ObjectDirectory, _In_ ULONG ServerId, _In_ PVOID ConnectionInfo, _Inout_ PULONG ConnectionInfoSize, _Out_ PBOOLEAN ServerToServerCall)
 
NTSTATUS NTAPI CsrClientCallServer (_Inout_ PCSR_API_MESSAGE ApiMessage, _Inout_opt_ PCSR_CAPTURE_BUFFER CaptureBuffer, _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

◆ NDEBUG

#define NDEBUG

Definition at line 22 of file connect.c.

◆ NTOS_MODE_USER

#define NTOS_MODE_USER

Definition at line 13 of file connect.c.

Typedef Documentation

◆ PCSR_SERVER_API_ROUTINE

typedef NTSTATUS(NTAPI * PCSR_SERVER_API_ROUTINE) (_In_ PCSR_API_MESSAGE Request, _Inout_ PCSR_API_MESSAGE Reply)

Definition at line 33 of file connect.c.

Function Documentation

◆ CsrClientCallServer()

NTSTATUS NTAPI CsrClientCallServer ( _Inout_ PCSR_API_MESSAGE  ApiMessage,
_Inout_opt_ PCSR_CAPTURE_BUFFER  CaptureBuffer,
_In_ CSR_API_NUMBER  ApiNumber,
_In_ ULONG  DataLength 
)

Definition at line 368 of file connect.c.

373{
375
376 /* Make sure the length is valid */
377 if (DataLength > (MAXSHORT - sizeof(CSR_API_MESSAGE)))
378 {
379 DPRINT1("DataLength too big: %lu\n", DataLength);
381 }
382
383 /* Fill out the Port Message Header */
384 ApiMessage->Header.u2.ZeroInit = 0;
385 /* DataLength = user_data_size + anything between
386 * header and data, including intermediate padding */
387 ApiMessage->Header.u1.s1.DataLength = (CSHORT)DataLength +
388 FIELD_OFFSET(CSR_API_MESSAGE, Data) - sizeof(ApiMessage->Header);
389 /* TotalLength = header_size + DataLength + any structure trailing padding */
390 ApiMessage->Header.u1.s1.TotalLength = (CSHORT)DataLength +
391 sizeof(CSR_API_MESSAGE) - sizeof(ApiMessage->Data);
392
393 /* Fill out the CSR Header */
394 ApiMessage->ApiNumber = ApiNumber;
395 ApiMessage->CsrCaptureData = NULL;
396
397 DPRINT("API: %lx, u1.s1.DataLength: %x, u1.s1.TotalLength: %x\n",
398 ApiNumber,
399 ApiMessage->Header.u1.s1.DataLength,
400 ApiMessage->Header.u1.s1.TotalLength);
401
402 /* Check if we are already inside a CSR Server */
403 if (!InsideCsrProcess)
404 {
405 ULONG PointerCount;
406 PULONG_PTR OffsetPointer;
407
408 /* Check if we got a Capture Buffer */
409 if (CaptureBuffer)
410 {
411 /*
412 * We have to convert from our local (client) view
413 * to the remote (server) view.
414 */
415 ApiMessage->CsrCaptureData = (PCSR_CAPTURE_BUFFER)
416 ((ULONG_PTR)CaptureBuffer + CsrPortMemoryDelta);
417
418 /* Lock the buffer */
419 CaptureBuffer->BufferEnd = NULL;
420
421 /*
422 * Each client pointer inside the CSR message is converted into
423 * a server pointer, and each pointer to these message pointers
424 * is converted into an offset.
425 */
426 PointerCount = CaptureBuffer->PointerCount;
427 OffsetPointer = CaptureBuffer->PointerOffsetsArray;
428 while (PointerCount--)
429 {
430 if (*OffsetPointer != 0)
431 {
432 *(PULONG_PTR)*OffsetPointer += CsrPortMemoryDelta;
433 *OffsetPointer -= (ULONG_PTR)ApiMessage;
434 }
435 ++OffsetPointer;
436 }
437 }
438
439 /* Send the LPC Message */
441 &ApiMessage->Header,
442 &ApiMessage->Header);
443
444 /* Check if we got a Capture Buffer */
445 if (CaptureBuffer)
446 {
447 /*
448 * We have to convert back from the remote (server) view
449 * to our local (client) view.
450 */
451 ApiMessage->CsrCaptureData = (PCSR_CAPTURE_BUFFER)
452 ((ULONG_PTR)ApiMessage->CsrCaptureData - CsrPortMemoryDelta);
453
454 /*
455 * Convert back the offsets into pointers to CSR message
456 * pointers, and convert back these message server pointers
457 * into client pointers.
458 */
459 PointerCount = CaptureBuffer->PointerCount;
460 OffsetPointer = CaptureBuffer->PointerOffsetsArray;
461 while (PointerCount--)
462 {
463 if (*OffsetPointer != 0)
464 {
465 *OffsetPointer += (ULONG_PTR)ApiMessage;
466 *(PULONG_PTR)*OffsetPointer -= CsrPortMemoryDelta;
467 }
468 ++OffsetPointer;
469 }
470 }
471
472 /* Check for success */
473 if (!NT_SUCCESS(Status))
474 {
475 /* We failed. Overwrite the return value with the failure. */
476 DPRINT1("LPC Failed: %lx\n", Status);
477 ApiMessage->Status = Status;
478 }
479 }
480 else
481 {
482 /* This is a server-to-server call */
483 DPRINT("Server-to-server call\n");
484
485 /* Save our CID; we check this equality inside CsrValidateMessageBuffer */
486 ApiMessage->Header.ClientId = NtCurrentTeb()->ClientId;
487
488 /* Do a direct call */
489 Status = CsrServerApiRoutine(ApiMessage, ApiMessage);
490
491 /* Check for success */
492 if (!NT_SUCCESS(Status))
493 {
494 /* We failed. Overwrite the return value with the failure. */
495 ApiMessage->Status = Status;
496 }
497 }
498
499 /* Return the CSR Result */
500 DPRINT("Got back: 0x%lx\n", ApiMessage->Status);
501 return ApiMessage->Status;
502}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
struct _CSR_CAPTURE_BUFFER * PCSR_CAPTURE_BUFFER
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG DataLength
Definition: dispmprt.h:233
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ULONG_PTR
Definition: config.h:101
Status
Definition: gdiplustypes.h:24
#define NtCurrentTeb
NTSTATUS NTAPI NtRequestWaitReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE LpcRequest, IN OUT PPORT_MESSAGE LpcReply)
Definition: send.c:696
#define DPRINT
Definition: sndvol32.h:73
ULONG_PTR CsrPortMemoryDelta
Definition: connect.c:30
HANDLE CsrApiPort
Definition: connect.c:27
BOOLEAN InsideCsrProcess
Definition: connect.c:31
PCSR_SERVER_API_ROUTINE CsrServerApiRoutine
Definition: connect.c:38
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define MAXSHORT
Definition: umtypes.h:114
short CSHORT
Definition: umtypes.h:127

Referenced by BaseCheckForVDM(), BaseCheckVDM(), BasepNotifyCsrOfThread(), BaseUpdateVDMEntry(), CloseConsoleHandle(), ConsoleMenuControl(), CreateConsoleScreenBuffer(), CreateProcessInternalW(), CsrClientConnectToServer(), CsrIdentifyAlertableThread(), CsrSetPriorityClass(), DefineDosDeviceW(), DeviceEventWorker(), DuplicateConsoleHandle(), EndTask(), ExitProcess(), ExitVDM(), ExitWindowsWorker(), FlushConsoleInputBuffer(), FreeConsole(), GenerateConsoleCtrlEvent(), GetConsoleCP(), GetConsoleCursorInfo(), GetConsoleDisplayMode(), GetConsoleFontInfo(), GetConsoleFontSize(), GetConsoleHandleInformation(), GetConsoleHardwareState(), GetConsoleHistoryInfo(), 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(), IntRegisterConsoleIME(), IntScrollConsoleScreenBuffer(), IntSetConsoleNumberOfCommands(), IntSetConsoleTitle(), IntUnregisterConsoleIME(), IntWriteConsole(), IntWriteConsoleInput(), IntWriteConsoleOutput(), IntWriteConsoleOutputCode(), InvalidateConsoleDIBits(), Logon(), NotifySoundSentry(), OpenConsoleW(), RegisterConsoleVDM(), RegisterLogonProcess(), RegisterServicesProcess(), SetConsoleActiveScreenBuffer(), SetConsoleCommandHistoryMode(), SetConsoleCP(), SetConsoleCursor(), SetConsoleCursorInfo(), SetConsoleCursorPosition(), SetConsoleDisplayMode(), SetConsoleFont(), SetConsoleHandleInformation(), SetConsoleHardwareState(), SetConsoleHistoryInfo(), SetConsoleIcon(), SetConsoleMenuClose(), SetConsoleMode(), SetConsoleOutputCP(), SetConsolePalette(), SetConsoleScreenBufferSize(), SetConsoleTextAttribute(), SetConsoleWindowInfo(), SetLastConsoleEventActive(), SetProcessShutdownParameters(), SetTEBLangID(), SetVDMCurrentDirectories(), ShowConsoleCursor(), and VerifyConsoleIoHandle().

◆ CsrClientConnectToServer()

NTSTATUS NTAPI CsrClientConnectToServer ( _In_ PCWSTR  ObjectDirectory,
_In_ ULONG  ServerId,
_In_ PVOID  ConnectionInfo,
_Inout_ PULONG  ConnectionInfoSize,
_Out_ PBOOLEAN  ServerToServerCall 
)

Definition at line 198 of file connect.c.

204{
206 PIMAGE_NT_HEADERS NtHeader;
207
208 DPRINT("CsrClientConnectToServer: %lx %p\n", ServerId, ConnectionInfo);
209
210 /* Validate the Connection Info */
211 if (ConnectionInfo && (!ConnectionInfoSize || !*ConnectionInfoSize))
212 {
213 DPRINT1("Connection info given, but no length\n");
215 }
216
217 /* Check if we're inside a CSR Process */
219 {
220 /* Tell the client that we're already inside CSR */
221 if (ServerToServerCall) *ServerToServerCall = TRUE;
222 return STATUS_SUCCESS;
223 }
224
225 /*
226 * We might be in a CSR Process but not know it, if this is the first call.
227 * So let's find out.
228 */
229 if (!(NtHeader = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress)))
230 {
231 /* The image isn't valid */
232 DPRINT1("Invalid image\n");
234 }
236
237 /* Now we can check if we are inside or not */
239 {
240 UNICODE_STRING CsrSrvName;
241 HANDLE hCsrSrv;
242 ANSI_STRING CsrServerRoutineName;
243
244 /* We're inside, so let's find csrsrv */
245 RtlInitUnicodeString(&CsrSrvName, L"csrsrv");
247 NULL,
248 &CsrSrvName,
249 &hCsrSrv);
250
251 /* Now get the Server to Server routine */
252 RtlInitAnsiString(&CsrServerRoutineName, "CsrCallServerFromServer");
254 &CsrServerRoutineName,
255 0L,
257
258 /* Use the local heap as port heap */
259 CsrPortHeap = RtlGetProcessHeap();
260
261 /* Tell the caller we're inside the server */
262 if (ServerToServerCall) *ServerToServerCall = InsideCsrProcess;
263 return STATUS_SUCCESS;
264 }
265
266 /* Now check if connection info is given */
267 if (ConnectionInfo)
268 {
269 CSR_API_MESSAGE ApiMessage;
270 PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage.Data.CsrClientConnect;
271 PCSR_CAPTURE_BUFFER CaptureBuffer;
272
273 /* Well, we're definitely in a client now */
275
276 /* Do we have a connection to CSR yet? */
277 if (!CsrApiPort)
278 {
279 /* No, set it up now */
280 Status = CsrpConnectToServer(ObjectDirectory);
281 if (!NT_SUCCESS(Status))
282 {
283 /* Failed */
284 DPRINT1("Failure to connect to CSR\n");
285 return Status;
286 }
287 }
288
289 /* Setup the connect message header */
290 ClientConnect->ServerId = ServerId;
291 ClientConnect->ConnectionInfoSize = *ConnectionInfoSize;
292
293 /* Setup a buffer for the connection info */
294 CaptureBuffer = CsrAllocateCaptureBuffer(1, ClientConnect->ConnectionInfoSize);
295 if (CaptureBuffer == NULL)
296 {
298 }
299
300 /* Capture the connection info data */
301 CsrCaptureMessageBuffer(CaptureBuffer,
302 ConnectionInfo,
303 ClientConnect->ConnectionInfoSize,
304 &ClientConnect->ConnectionInfo);
305
306 /* Return the allocated length */
307 *ConnectionInfoSize = ClientConnect->ConnectionInfoSize;
308
309 /* Call CSR */
310 Status = CsrClientCallServer(&ApiMessage,
311 CaptureBuffer,
313 sizeof(*ClientConnect));
314
315 /* Copy the updated connection info data back into the user buffer */
316 RtlMoveMemory(ConnectionInfo,
317 ClientConnect->ConnectionInfo,
318 *ConnectionInfoSize);
319
320 /* Free the capture buffer */
321 CsrFreeCaptureBuffer(CaptureBuffer);
322 }
323 else
324 {
325 /* No connection info, just return */
327 }
328
329 /* Let the caller know if this was server to server */
330 DPRINT("Status was: 0x%lx. Are we in server: 0x%x\n", Status, InsideCsrProcess);
331 if (ServerToServerCall) *ServerToServerCall = InsideCsrProcess;
332
333 return Status;
334}
#define NtCurrentPeb()
Definition: FLS.c:22
#define CSR_CREATE_API_NUMBER(ServerId, ApiId)
Definition: csrmsg.h:37
#define CSRSRV_SERVERDLL_INDEX
Definition: csrmsg.h:20
@ CsrpClientConnect
Definition: csrmsg.h:25
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RtlImageNtHeader
Definition: compat.h:806
#define L(x)
Definition: resources.c:13
NTSTATUS NTAPI LdrGetDllHandle(_In_opt_ PWSTR DllPath, _In_opt_ PULONG DllCharacteristics, _In_ PUNICODE_STRING DllName, _Out_ PVOID *DllHandle)
Definition: ldrapi.c:770
NTSTATUS NTAPI LdrGetProcedureAddress(_In_ PVOID BaseAddress, _In_opt_ _When_(Ordinal==0, _Notnull_) PANSI_STRING Name, _In_opt_ _When_(Name==NULL, _In_range_(>, 0)) ULONG Ordinal, _Out_ PVOID *ProcedureAddress)
Definition: ldrapi.c:789
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define IMAGE_SUBSYSTEM_NATIVE
Definition: ntimage.h:436
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:453
PCSR_CAPTURE_BUFFER NTAPI CsrAllocateCaptureBuffer(_In_ ULONG ArgumentCount, _In_ ULONG BufferSize)
Definition: capture.c:87
VOID NTAPI CsrFreeCaptureBuffer(_In_ _Frees_ptr_ PCSR_CAPTURE_BUFFER CaptureBuffer)
Definition: capture.c:210
VOID NTAPI CsrCaptureMessageBuffer(_Inout_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_opt_ PVOID MessageBuffer, _In_ ULONG MessageLength, _Out_ PVOID *CapturedData)
Definition: capture.c:189
#define STATUS_SUCCESS
Definition: shellext.h:65
union _CSR_API_MESSAGE::@4310::@4312::@4314 Data
CSR_CLIENT_CONNECT CsrClientConnect
Definition: csrmsg.h:114
ULONG ConnectionInfoSize
Definition: csrmsg.h:87
PVOID ConnectionInfo
Definition: csrmsg.h:86
IMAGE_OPTIONAL_HEADER32 OptionalHeader
Definition: ntddk_ex.h:184
static NTSTATUS CsrpConnectToServer(_In_ PCWSTR ObjectDirectory)
Definition: connect.c:43
HANDLE CsrPortHeap
Definition: connect.c:29
NTSTATUS NTAPI CsrClientCallServer(_Inout_ PCSR_API_MESSAGE ApiMessage, _Inout_opt_ PCSR_CAPTURE_BUFFER CaptureBuffer, _In_ CSR_API_NUMBER ApiNumber, _In_ ULONG DataLength)
Definition: connect.c:368
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by ConnectConsole(), and DllMain().

◆ CsrGetProcessId()

HANDLE NTAPI CsrGetProcessId ( VOID  )

Definition at line 509 of file connect.c.

510{
511 return CsrProcessId;
512}
HANDLE CsrProcessId
Definition: connect.c:28

Referenced by ProcessIdToHandle().

◆ CsrpConnectToServer()

static NTSTATUS CsrpConnectToServer ( _In_ PCWSTR  ObjectDirectory)
static

Definition at line 43 of file connect.c.

45{
47 SIZE_T PortNameLength;
49 LARGE_INTEGER CsrSectionViewSize;
50 HANDLE CsrSectionHandle;
51 PORT_VIEW LpcWrite;
52 REMOTE_PORT_VIEW LpcRead;
55 PSID SystemSid = NULL;
56 CSR_API_CONNECTINFO ConnectionInfo;
57 ULONG ConnectionInfoLength = sizeof(ConnectionInfo);
58
59 DPRINT("%s(%S)\n", __FUNCTION__, ObjectDirectory);
60
61 /* Calculate the total port name size */
62 PortNameLength = ((wcslen(ObjectDirectory) + 1) * sizeof(WCHAR)) +
63 sizeof(CSR_PORT_NAME);
64 if (PortNameLength > UNICODE_STRING_MAX_BYTES)
65 {
66 DPRINT1("PortNameLength too big: %Iu\n", PortNameLength);
68 }
69
70 /* Set the port name */
71 PortName.Length = 0;
72 PortName.MaximumLength = (USHORT)PortNameLength;
73
74 /* Allocate a buffer for it */
75 PortName.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, PortNameLength);
76 if (PortName.Buffer == NULL)
77 {
79 }
80
81 /* Create the name */
82 RtlAppendUnicodeToString(&PortName, ObjectDirectory);
85
86 /* Create a section for the port memory */
87 CsrSectionViewSize.QuadPart = CSR_CSRSS_SECTION_SIZE;
88 Status = NtCreateSection(&CsrSectionHandle,
90 NULL,
91 &CsrSectionViewSize,
94 NULL);
95 if (!NT_SUCCESS(Status))
96 {
97 DPRINT1("Failure allocating CSR Section\n");
98 return Status;
99 }
100
101 /* Set up the port view structures to match them with the section */
102 LpcWrite.Length = sizeof(LpcWrite);
103 LpcWrite.SectionHandle = CsrSectionHandle;
104 LpcWrite.SectionOffset = 0;
105 LpcWrite.ViewSize = CsrSectionViewSize.u.LowPart;
106 LpcWrite.ViewBase = 0;
107 LpcWrite.ViewRemoteBase = 0;
108 LpcRead.Length = sizeof(LpcRead);
109 LpcRead.ViewSize = 0;
110 LpcRead.ViewBase = 0;
111
112 /* Setup the QoS */
115 SecurityQos.EffectiveOnly = TRUE;
116
117 /* Setup the connection info */
118 ConnectionInfo.DebugFlags = 0;
119
120 /* Create a SID for us */
122 1,
124 0,
125 0,
126 0,
127 0,
128 0,
129 0,
130 0,
131 &SystemSid);
132 if (!NT_SUCCESS(Status))
133 {
134 /* Failure */
135 DPRINT1("Couldn't allocate SID\n");
136 NtClose(CsrSectionHandle);
137 return Status;
138 }
139
140 /* Connect to the port */
142 &PortName,
143 &SecurityQos,
144 &LpcWrite,
145 SystemSid,
146 &LpcRead,
147 NULL,
148 &ConnectionInfo,
149 &ConnectionInfoLength);
150 RtlFreeSid(SystemSid);
151 NtClose(CsrSectionHandle);
152 if (!NT_SUCCESS(Status))
153 {
154 /* Failure */
155 DPRINT1("Couldn't connect to CSR port\n");
156 return Status;
157 }
158
159 /* Save the delta between the sections, for capture usage later */
161 (ULONG_PTR)LpcWrite.ViewBase;
162
163 /* Save the Process */
164 CsrProcessId = ConnectionInfo.ServerProcessId;
165
166 /* Save CSR Section data */
167 NtCurrentPeb()->ReadOnlySharedMemoryBase = ConnectionInfo.SharedSectionBase;
168#if (NTDDI_VERSION < NTDDI_LONGHORN)
169 NtCurrentPeb()->ReadOnlySharedMemoryHeap = ConnectionInfo.SharedSectionHeap;
170#endif
171 NtCurrentPeb()->ReadOnlyStaticServerData = ConnectionInfo.SharedStaticServerData;
172
173 /* Create the port heap */
175 LpcWrite.ViewBase,
176 LpcWrite.ViewSize,
177 PAGE_SIZE,
178 0,
179 0);
180 if (CsrPortHeap == NULL)
181 {
182 /* Failure */
183 DPRINT1("Couldn't create heap for CSR port\n");
187 }
188
189 /* Return success */
190 return STATUS_SUCCESS;
191}
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:3097
static UNICODE_STRING PortName
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
#define CSR_PORT_NAME
Definition: csrmsg.h:17
#define CSR_CSRSS_SECTION_SIZE
Definition: csrsrv.h:27
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define __FUNCTION__
Definition: types.h:116
#define PAGE_SIZE
Definition: env_spec_w32.h:49
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
@ SecurityImpersonation
Definition: lsa.idl:57
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
#define PAGE_READWRITE
Definition: nt_native.h:1307
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1296
#define SEC_RESERVE
Definition: nt_native.h:1326
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)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3434
#define UNICODE_STRING_MAX_BYTES
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
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
#define STATUS_NAME_TOO_LONG
Definition: ntstatus.h:592
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
static SID_IDENTIFIER_AUTHORITY NtSidAuthority
Definition: samrpc.c:14
HANDLE ServerProcessId
Definition: csrmsg.h:57
PVOID SharedStaticServerData
Definition: csrmsg.h:51
PVOID SharedSectionBase
Definition: csrmsg.h:50
PVOID SharedSectionHeap
Definition: csrmsg.h:52
LPC_PVOID ViewBase
LPC_HANDLE SectionHandle
LPC_PVOID ViewRemoteBase
ULONG SectionOffset
LPC_SIZE_T ViewSize
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: lsa.idl:65
USHORT MaximumLength
Definition: env_spec_w32.h:370
ULONG_PTR SIZE_T
Definition: typedefs.h:80
LONGLONG QuadPart
Definition: typedefs.h:114
struct _LARGE_INTEGER::@2753 u
#define SECURITY_LOCAL_SYSTEM_RID
Definition: setypes.h:574
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103

Referenced by CsrClientConnectToServer().

Variable Documentation

◆ CsrApiPort

◆ CsrPortHeap

◆ CsrPortMemoryDelta

ULONG_PTR CsrPortMemoryDelta

Definition at line 30 of file connect.c.

Referenced by CsrClientCallServer(), and CsrpConnectToServer().

◆ CsrProcessId

HANDLE CsrProcessId

Definition at line 28 of file connect.c.

Referenced by CsrGetProcessId(), and CsrpConnectToServer().

◆ CsrServerApiRoutine

PCSR_SERVER_API_ROUTINE CsrServerApiRoutine

Definition at line 38 of file connect.c.

Referenced by CsrClientCallServer(), and CsrClientConnectToServer().

◆ InsideCsrProcess

BOOLEAN InsideCsrProcess = FALSE

Definition at line 31 of file connect.c.

Referenced by CsrClientCallServer(), and CsrClientConnectToServer().