/* INCLUDES *******************************************************************/
#include <ntdll.h>
+
+#include <ndk/lpcfuncs.h>
+#include <csr/csrsrv.h>
+
#define NDEBUG
#include <debug.h>
SecurityQos.EffectiveOnly = TRUE;
/* Setup the connection info */
- ConnectionInfo.Version = CSRSRV_VERSION;
+ ConnectionInfo.DebugFlags = 0;
/* Create a SID for us */
Status = RtlAllocateAndInitializeSid(&NtSidAuthority,
(ULONG_PTR)LpcWrite.ViewBase;
/* Save the Process */
- CsrProcessId = ConnectionInfo.ProcessId;
+ CsrProcessId = ConnectionInfo.ServerProcessId;
/* Save CSR Section data */
NtCurrentPeb()->ReadOnlySharedMemoryBase = ConnectionInfo.SharedSectionBase;
NtCurrentPeb()->ReadOnlySharedMemoryHeap = ConnectionInfo.SharedSectionHeap;
- NtCurrentPeb()->ReadOnlyStaticServerData = ConnectionInfo.SharedSectionData;
+ NtCurrentPeb()->ReadOnlyStaticServerData = ConnectionInfo.SharedStaticServerData;
/* Create the port heap */
CsrPortHeap = RtlCreateHeap(0,
if (InsideCsrProcess)
{
/* We're inside, so let's find csrsrv */
- DPRINT1("Next-GEN CSRSS support\n");
+ DPRINT("Next-GEN CSRSS support\n");
RtlInitUnicodeString(&CsrSrvName, L"csrsrv");
Status = LdrGetDllHandle(NULL,
NULL,
CsrPortHeap = RtlGetProcessHeap();
/* Tell the caller we're inside the server */
- *ServerToServerCall = InsideCsrProcess;
+ if (ServerToServerCall) *ServerToServerCall = InsideCsrProcess;
return STATUS_SUCCESS;
}
/* Now check if connection info is given */
if (ConnectionInfo)
{
- /* Well, we're defintely in a client now */
+ /* Well, we're definitely in a client now */
InsideCsrProcess = FALSE;
/* Do we have a connection to CSR yet? */
return Status;
}
+#if 0
+//
+// Structures can be padded at the end, causing the size of the entire structure
+// minus the size of the last field, not to be equal to the offset of the last
+// field.
+//
+typedef struct _TEST_EMBEDDED
+{
+ ULONG One;
+ ULONG Two;
+ ULONG Three;
+} TEST_EMBEDDED;
+
+typedef struct _TEST
+{
+ PORT_MESSAGE h;
+ TEST_EMBEDDED Three;
+} TEST;
+
+C_ASSERT(sizeof(PORT_MESSAGE) == 0x18);
+C_ASSERT(FIELD_OFFSET(TEST, Three) == 0x18);
+C_ASSERT(sizeof(TEST_EMBEDDED) == 0xC);
+
+C_ASSERT(sizeof(TEST) != (sizeof(TEST_EMBEDDED) + sizeof(PORT_MESSAGE)));
+C_ASSERT((sizeof(TEST) - sizeof(TEST_EMBEDDED)) != FIELD_OFFSET(TEST, Three));
+#endif
+
/*
* @implemented
*/
-NTSTATUS
+NTSTATUS
NTAPI
CsrClientCallServer(IN OUT PCSR_API_MESSAGE ApiMessage,
IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL,
/* Fill out the Port Message Header */
ApiMessage->Header.u2.ZeroInit = 0;
- ApiMessage->Header.u1.s1.TotalLength =
- FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength;
- ApiMessage->Header.u1.s1.DataLength =
- ApiMessage->Header.u1.s1.TotalLength - sizeof(PORT_MESSAGE);
+ ApiMessage->Header.u1.s1.TotalLength = DataLength +
+ sizeof(CSR_API_MESSAGE) - sizeof(ApiMessage->Data); // FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength;
+ ApiMessage->Header.u1.s1.DataLength = DataLength +
+ FIELD_OFFSET(CSR_API_MESSAGE, Data) - sizeof(ApiMessage->Header); // ApiMessage->Header.u1.s1.TotalLength - sizeof(PORT_MESSAGE);
/* Fill out the CSR Header */
ApiMessage->ApiNumber = ApiNumber;
ApiNumber,
ApiMessage->Header.u1.s1.DataLength,
ApiMessage->Header.u1.s1.TotalLength);
-
+
/* Check if we are already inside a CSR Server */
if (!InsideCsrProcess)
{
else
{
/* This is a server-to-server call. Save our CID and do a direct call. */
- DPRINT1("Next gen server-to-server call\n");
+ DPRINT("Next gen server-to-server call\n");
/* We check this equality inside CsrValidateMessageBuffer */
ApiMessage->Header.ClientId = NtCurrentTeb()->ClientId;