ReactOS 0.4.16-dev-297-gc569aee
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(NTAPIPCSR_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 366 of file connect.c.

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

202{
204 PIMAGE_NT_HEADERS NtHeader;
205
206 DPRINT("CsrClientConnectToServer: %lx %p\n", ServerId, ConnectionInfo);
207
208 /* Validate the Connection Info */
209 if (ConnectionInfo && (!ConnectionInfoSize || !*ConnectionInfoSize))
210 {
211 DPRINT1("Connection info given, but no length\n");
213 }
214
215 /* Check if we're inside a CSR Process */
217 {
218 /* Tell the client that we're already inside CSR */
219 if (ServerToServerCall) *ServerToServerCall = TRUE;
220 return STATUS_SUCCESS;
221 }
222
223 /*
224 * We might be in a CSR Process but not know it, if this is the first call.
225 * So let's find out.
226 */
227 if (!(NtHeader = RtlImageNtHeader(NtCurrentPeb()->ImageBaseAddress)))
228 {
229 /* The image isn't valid */
230 DPRINT1("Invalid image\n");
232 }
234
235 /* Now we can check if we are inside or not */
237 {
238 UNICODE_STRING CsrSrvName;
239 HANDLE hCsrSrv;
240 ANSI_STRING CsrServerRoutineName;
241
242 /* We're inside, so let's find csrsrv */
243 RtlInitUnicodeString(&CsrSrvName, L"csrsrv");
245 NULL,
246 &CsrSrvName,
247 &hCsrSrv);
248
249 /* Now get the Server to Server routine */
250 RtlInitAnsiString(&CsrServerRoutineName, "CsrCallServerFromServer");
252 &CsrServerRoutineName,
253 0L,
255
256 /* Use the local heap as port heap */
257 CsrPortHeap = RtlGetProcessHeap();
258
259 /* Tell the caller we're inside the server */
260 if (ServerToServerCall) *ServerToServerCall = InsideCsrProcess;
261 return STATUS_SUCCESS;
262 }
263
264 /* Now check if connection info is given */
265 if (ConnectionInfo)
266 {
267 CSR_API_MESSAGE ApiMessage;
268 PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage.Data.CsrClientConnect;
269 PCSR_CAPTURE_BUFFER CaptureBuffer;
270
271 /* Well, we're definitely in a client now */
273
274 /* Do we have a connection to CSR yet? */
275 if (!CsrApiPort)
276 {
277 /* No, set it up now */
278 Status = CsrpConnectToServer(ObjectDirectory);
279 if (!NT_SUCCESS(Status))
280 {
281 /* Failed */
282 DPRINT1("Failure to connect to CSR\n");
283 return Status;
284 }
285 }
286
287 /* Setup the connect message header */
288 ClientConnect->ServerId = ServerId;
289 ClientConnect->ConnectionInfoSize = *ConnectionInfoSize;
290
291 /* Setup a buffer for the connection info */
292 CaptureBuffer = CsrAllocateCaptureBuffer(1, ClientConnect->ConnectionInfoSize);
293 if (CaptureBuffer == NULL)
294 {
296 }
297
298 /* Capture the connection info data */
299 CsrCaptureMessageBuffer(CaptureBuffer,
300 ConnectionInfo,
301 ClientConnect->ConnectionInfoSize,
302 &ClientConnect->ConnectionInfo);
303
304 /* Return the allocated length */
305 *ConnectionInfoSize = ClientConnect->ConnectionInfoSize;
306
307 /* Call CSR */
308 Status = CsrClientCallServer(&ApiMessage,
309 CaptureBuffer,
311 sizeof(*ClientConnect));
312
313 /* Copy the updated connection info data back into the user buffer */
314 RtlMoveMemory(ConnectionInfo,
315 ClientConnect->ConnectionInfo,
316 *ConnectionInfoSize);
317
318 /* Free the capture buffer */
319 CsrFreeCaptureBuffer(CaptureBuffer);
320 }
321 else
322 {
323 /* No connection info, just return */
325 }
326
327 /* Let the caller know if this was server to server */
328 DPRINT("Status was: 0x%lx. Are we in server: 0x%x\n", Status, InsideCsrProcess);
329 if (ServerToServerCall) *ServerToServerCall = InsideCsrProcess;
330
331 return Status;
332}
#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
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:359
#define L(x)
Definition: ntvdm.h:50
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::@3485::@3487::@3489 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:366
#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 507 of file connect.c.

508{
509 return CsrProcessId;
510}
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 NtCurrentPeb()->ReadOnlySharedMemoryHeap = ConnectionInfo.SharedSectionHeap;
169 NtCurrentPeb()->ReadOnlyStaticServerData = ConnectionInfo.SharedStaticServerData;
170
171 /* Create the port heap */
173 LpcWrite.ViewBase,
174 LpcWrite.ViewSize,
175 PAGE_SIZE,
176 0,
177 0);
178 if (CsrPortHeap == NULL)
179 {
180 /* Failure */
181 DPRINT1("Couldn't create heap for CSR port\n");
185 }
186
187 /* Return success */
188 return STATUS_SUCCESS;
189}
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:3074
static UNICODE_STRING PortName
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
#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
#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
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
@ SecurityImpersonation
Definition: lsa.idl:57
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
#define PAGE_READWRITE
Definition: nt_native.h:1304
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define SEC_RESERVE
Definition: nt_native.h:1323
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:3402
#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:498
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::@2302 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
__wchar_t WCHAR
Definition: xmlstorage.h:180

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