67 DPRINT1(
"CSRSS: %lx is invalid ServerDllIndex (%08x)\n", ServerId, ServerDll);
83 DPRINT1(
"CSRSS: %lx (%s) is invalid ApiTableIndex for %Z or is an " 84 "invalid API to call from the server.\n",
86 ((ServerDll->NameTable) && (ServerDll->NameTable[ApiId])) ?
87 ServerDll->NameTable[ApiId] :
"*** UNKNOWN ***",
99 DPRINT1(
"CSRSS: %s Api Request received from server process\n",
100 ServerDll->NameTable[ApiId]);
108 ReplyMsg->Status = ServerDll->
DispatchTable[ApiId](ReceiveMsg, &ReplyCode);
172 AllowConnection =
TRUE;
201 DPRINT1(
"CSRSS: NtAcceptConnectPort - failed. Status == %X\n",
Status);
203 else if (AllowConnection)
207 DPRINT1(
"CSRSS: ClientId: %lx.%lx has ClientView: Base=%p, Size=%lx\n",
208 ApiMessage->Header.ClientId.UniqueProcess,
209 ApiMessage->Header.ClientId.UniqueThread,
224 DPRINT1(
"CSRSS: NtCompleteConnectPort - failed. Status == %X\n",
Status);
229 DPRINT1(
"CSRSS: Rejecting Connection Request from ClientId: %lx.%lx\n",
230 ApiMessage->Header.ClientId.UniqueProcess,
231 ApiMessage->Header.ClientId.UniqueThread);
347 ULONG ServerId, ApiId, MessageType,
i;
358 TimeOut.
QuadPart = -30 * 1000 * 1000 * 10;
390 DPRINT1(
"CSRSRV: FATAL ERROR. CsrThread is Idle while holding %lu critical sections\n",
392 DPRINT1(
"CSRSRV: Last Receive Message %lx ReplyMessage %lx\n",
393 &ReceiveMsg, ReplyMsg);
417 DPRINT1(
"CSRSS: ReceivePort failed - Status == %X\n",
Status);
430 DPRINT1(
"NtReplyWaitReceivePort returned \"success\" status 0x%x\n",
Status);
442 MessageType = ReceiveMsg.
Header.u2.s2.Type;
471 ReplyMsg = &ReceiveMsg;
516 if (HardErrorMsg->
Response == 0xFFFFFFFF)
523 ReplyMsg = &ReceiveMsg;
530 ReplyMsg = &ReceiveMsg;
546 DPRINT1(
"CSRSS: %lx is invalid ServerDllIndex (%08x)\n",
547 ServerId, ServerDll);
563 DPRINT1(
"CSRSS: %lx is invalid ApiTableIndex for %Z\n",
575 DPRINT1(
"[%02x] CSRSS: [%02x,%02x] - %s Api called from %08x\n",
579 ServerDll->NameTable[ApiId],
673 ReplyMsg = &ReceiveMsg;
713 if (HardErrorMsg->
Response == 0xFFFFFFFF)
721 ReplyMsg = &ReceiveMsg;
750 DPRINT1(
"CSRSS: %lx is invalid ServerDllIndex (%08x)\n",
751 ServerId, ServerDll);
756 ReplyMsg = &ReceiveMsg;
769 DPRINT1(
"CSRSS: %lx is invalid ApiTableIndex for %Z\n",
774 ReplyMsg = &ReceiveMsg;
783 DPRINT1(
"[%02x] CSRSS: [%02x,%02x] - %s Api called from %08x, Process %08x - %08x\n",
787 ServerDll->NameTable[ApiId],
795 ReplyMsg = &ReceiveMsg;
846 DPRINT1(
"CSRSS: Error while replying to the death message, Status 0x%lx\n", Status2);
922 DPRINT1(
"CSRSS: sizeof( CONNECTINFO ) == %ld sizeof( API_MSG ) == %ld\n",
959 (
PVOID)hRequestEvent,
969 NextEntry = ListHead->
Flink;
972 while (NextEntry != ListHead)
989 NextEntry = NextEntry->
Flink;
1064 DPRINT1(
"CSRSS: CsrConnectToUser failed\n");
1125 SIZE_T SizeOfBufferThroughOffsetsArray;
1133 ClientCaptureBuffer = ApiMessage->CsrCaptureData;
1139 if ( ((
ULONG_PTR)ClientCaptureBuffer < CsrProcess->ClientViewBase) ||
1144 DPRINT1(
"*** CSRSS: CaptureBuffer outside of ClientView 1\n");
1160 if ( (EndOfClientBuffer < (
ULONG_PTR)ClientCaptureBuffer) ||
1161 (EndOfClientBuffer >=
CsrProcess->ClientViewBounds) )
1164 DPRINT1(
"*** CSRSS: CaptureBuffer outside of ClientView 2\n");
1179 SizeOfBufferThroughOffsetsArray =
1181 (PointerCount *
sizeof(
PVOID));
1183 (SizeOfBufferThroughOffsetsArray >
Length) )
1186 DPRINT1(
"*** CSRSS: CaptureBuffer %p has bad length\n", ClientCaptureBuffer);
1208 if (!ServerCaptureBuffer)
1248 while (PointerCount--)
1250 CurrentOffset = *OffsetPointer;
1252 if (CurrentOffset != 0)
1258 if ( ((CurrentOffset & (
sizeof(
PVOID)-1)) != 0) ||
1263 DPRINT1(
"*** CSRSS: CaptureBuffer MessagePointer outside of message\n");
1276 SizeOfBufferThroughOffsetsArray)) &&
1280 *(
PULONG_PTR)CurrentOffset += BufferDistance;
1285 DPRINT1(
"*** CSRSS: CaptureBuffer MessagePointer outside of ClientView\n");
1308 ApiMessage->CsrCaptureData = ServerCaptureBuffer;
1342 ServerCaptureBuffer = ApiMessage->CsrCaptureData;
1345 if (!ServerCaptureBuffer)
return;
1352 ApiMessage->CsrCaptureData = ClientCaptureBuffer;
1364 while (PointerCount--)
1366 CurrentOffset = *OffsetPointer;
1368 if (CurrentOffset != 0)
1374 *(
PULONG_PTR)CurrentOffset -= BufferDistance;
1383 RtlMoveMemory(ClientCaptureBuffer, ServerCaptureBuffer, ServerCaptureBuffer->
Size);
1440 if (!
Buffer || ElementSize == 0 ||
1448 if (!*
Buffer && ElementCount == 0)
1456 ApiMessage->Header.ClientId.UniqueProcess)
1465 (ElementCount * ElementSize))
1468 PointerCount = CaptureBuffer->PointerCount;
1469 OffsetPointer = CaptureBuffer->PointerOffsetsArray;
1470 while (PointerCount--)
1476 if (*OffsetPointer == BufferDistance)
1487 DPRINT1(
"CSRSRV: Bad message buffer %p\n", ApiMessage);
1519 (
PVOID*)MessageString,
1520 wcslen(*MessageString) + 1,
ULONG HighestApiSupported
VOID NTAPI CsrLockedReferenceThread(IN PCSR_THREAD CsrThread)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
ULONG Win32ClientInfo[31]
NTSTATUS NTAPI LdrGetDllHandle(IN PWSTR DllPath OPTIONAL, IN PULONG DllCharacteristics OPTIONAL, IN PUNICODE_STRING DllName, OUT PVOID *DllHandle)
_In_ ULONG _In_ ULONG _In_ ULONG Length
BOOLEAN NTAPI CsrCaptureArguments(IN PCSR_THREAD CsrThread, IN PCSR_API_MESSAGE ApiMessage)
#define STATUS_INVALID_PARAMETER
_Must_inspect_result_ _Outptr_ PFLT_PORT * ServerPort
BOOLEAN(* CsrClientThreadSetup)(VOID)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
#define NtCurrentThread()
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
IN PVOID IN PVOID IN USHORT IN USHORT Size
NTSTATUS NTAPI CsrDestroyProcess(IN PCLIENT_ID Cid, IN NTSTATUS ExitStatus)
VOID NTAPI CsrDereferenceThread(IN PCSR_THREAD CsrThread)
PCSR_CAPTURE_BUFFER CsrCaptureData
#define CSR_SERVER_DLL_MAX
#define CsrReleaseProcessLock()
PCSR_THREAD NTAPI CsrConnectToUser(VOID)
static int Link(const char **args)
#define STATUS_INVALID_HANDLE
#define RtlMoveMemory(Destination, Source, Length)
NTSTATUS NTAPI NtReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE ReplyMessage)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
PCSR_PROCESS CsrRootProcess
EXCEPTION_DISPOSITION NTAPI CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
struct _CLIENT_DIED_MSG * PCLIENT_DIED_MSG
NTSTATUS NTAPI CsrApiHandleConnectionRequest(IN PCSR_API_MESSAGE ApiMessage)
PCSR_THREAD NTAPI CsrAddStaticServerThread(IN HANDLE hThread, IN PCLIENT_ID ClientId, IN ULONG ThreadFlags)
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
VOID NTAPI CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage)
#define STATUS_INVALID_CID
ULONG CountOfOwnedCriticalSections
VOID NTAPI CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread)
#define _SEH2_GetExceptionInformation()
#define EXCEPTION_EXECUTE_HANDLER
NTSTATUS NTAPI LdrGetProcedureAddress(IN PVOID BaseAddress, IN PANSI_STRING Name, IN ULONG Ordinal, OUT PVOID *ProcedureAddress)
NTSTATUS NTAPI CsrCallServerFromServer(IN PCSR_API_MESSAGE ReceiveMsg, IN OUT PCSR_API_MESSAGE ReplyMsg)
UINT CALLBACK ServerThread(_Inout_ PVOID Parameter)
struct _REMOTE_PORT_VIEW REMOTE_PORT_VIEW
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
HANDLE NTAPI CsrQueryApiPort(VOID)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
NTSTATUS NTAPI NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval)
#define NtCurrentProcess()
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
NTSTATUS NTAPI CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL, OUT PCSR_API_CONNECTINFO ConnectInfo)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
struct _LIST_ENTRY * Flink
NTSTATUS NtTerminateThread(IN HANDLE ThreadHandle OPTIONAL, IN NTSTATUS ExitStatus)
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
NTSTATUS NTAPI NtAcceptConnectPort(OUT PHANDLE PortHandle, IN PVOID PortContext OPTIONAL, IN PPORT_MESSAGE ReplyMessage, IN BOOLEAN AcceptConnection, IN OUT PPORT_VIEW ServerView OPTIONAL, OUT PREMOTE_PORT_VIEW ClientView OPTIONAL)
_Out_ PCLIENT_ID ClientId
NTSTATUS NTAPI NtCreatePort(OUT PHANDLE PortHandle, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG MaxConnectInfoLength, IN ULONG MaxDataLength, IN ULONG MaxPoolUsage)
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
#define _SEH2_YIELD(STMT_)
#define NT_SUCCESS(StatCode)
ULONG CsrMaxApiRequestThreads
struct _CSR_CAPTURE_BUFFER * PreviousCaptureBuffer
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define CSR_API_NUMBER_TO_SERVER_ID(ApiNumber)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define STATUS_UNSUCCESSFUL
PCSR_HARDERROR_CALLBACK HardErrorCallback
#define CsrAcquireProcessLock()
NTSTATUS NTAPI NtReplyWaitReceivePort(IN HANDLE PortHandle, OUT PVOID *PortContext OPTIONAL, IN PPORT_MESSAGE ReplyMessage OPTIONAL, OUT PPORT_MESSAGE ReceiveMessage)
#define CSR_API_NUMBER_TO_API_ID(ApiNumber)
NTSTATUS NTAPI CsrDestroyThread(IN PCLIENT_ID Cid)
NTSTATUS NTAPI CsrApiRequestThread(IN PVOID Parameter)
#define InterlockedDecrementUL(Addend)
UNICODE_STRING CsrDirectoryName
volatile ULONG CsrpStaticThreadCount
NTSYSAPI NTSTATUS NTAPI RtlCreateUserThread(_In_ PVOID ThreadContext, _Out_ HANDLE *OutThreadHandle, _Reserved_ PVOID Reserved1, _Reserved_ PVOID Reserved2, _Reserved_ PVOID Reserved3, _Reserved_ PVOID Reserved4, _Reserved_ PVOID Reserved5, _Reserved_ PVOID Reserved6, _Reserved_ PVOID Reserved7, _Reserved_ PVOID Reserved8)
PCSR_THREAD NTAPI CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL, IN PCLIENT_ID ClientId)
PCSR_THREAD NTAPI CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL, IN PCLIENT_ID Cid)
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
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
struct _HARDERROR_MSG * PHARDERROR_MSG
#define STATUS_ACCESS_VIOLATION
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define InterlockedIncrementUL(Addend)
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
struct _DBGKM_MSG * PDBGKM_MSG
volatile ULONG CsrpDynamicThreadTotal
#define FIELD_OFFSET(t, f)
enum _CSR_REPLY_CODE CSR_REPLY_CODE
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PCSR_API_ROUTINE * DispatchTable
UNICODE_STRING CsrApiPortName
NTSTATUS NTAPI NtCompleteConnectPort(IN HANDLE PortHandle)
NTSTATUS NTAPI CsrpCheckRequestThreads(VOID)
NTSTATUS NTAPI CsrApiPortInitialize(VOID)
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
#define InitializeObjectAttributes(p, n, a, r, s)
VOID NTAPI CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess)
BOOLEAN NTAPI CsrValidateMessageString(IN PCSR_API_MESSAGE ApiMessage, IN PWSTR *MessageString)
#define _SEH2_EXCEPT(...)
#define _SEH2_GetExceptionCode()
#define STATUS_ILLEGAL_FUNCTION
VOID NTAPI CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess)
ULONG_PTR PointerOffsetsArray[ANYSIZE_ARRAY]
PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX]
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)