68 DPRINT1(
"CSRSS: %lx is invalid ServerDllIndex (%08x)\n",
87 DPRINT1(
"CSRSS: %lx (%s) is invalid ApiTableIndex for %Z or is an "
88 "invalid API to call from the server.\n",
90 ((ServerDll->NameTable) && (ServerDll->NameTable[ApiId])) ?
91 ServerDll->NameTable[ApiId] :
"*** UNKNOWN ***",
103 DPRINT1(
"CSRSS: %s Api Request received from server process\n",
104 ServerDll->NameTable[ApiId]);
112 ReplyMsg->Status = ServerDll->
DispatchTable[ApiId](ReceiveMsg, &ReplyCode);
176 AllowConnection =
TRUE;
205 DPRINT1(
"CSRSS: NtAcceptConnectPort - failed. Status == %X\n",
Status);
207 else if (AllowConnection)
211 DPRINT1(
"CSRSS: ClientId: %lx.%lx has ClientView: Base=%p, Size=%lx\n",
212 ApiMessage->Header.ClientId.UniqueProcess,
213 ApiMessage->Header.ClientId.UniqueThread,
228 DPRINT1(
"CSRSS: NtCompleteConnectPort - failed. Status == %X\n",
Status);
233 DPRINT1(
"CSRSS: Rejecting Connection Request from ClientId: %lx.%lx\n",
234 ApiMessage->Header.ClientId.UniqueProcess,
235 ApiMessage->Header.ClientId.UniqueThread);
351 ULONG ServerId, ApiId, MessageType,
i;
362 TimeOut.
QuadPart = -30 * 1000 * 1000 * 10;
394 DPRINT1(
"CSRSRV: FATAL ERROR. CsrThread is Idle while holding %lu critical sections\n",
396 DPRINT1(
"CSRSRV: Last Receive Message %lx ReplyMessage %lx\n",
397 &ReceiveMsg, ReplyMsg);
421 DPRINT1(
"CSRSS: ReceivePort failed - Status == %X\n",
Status);
434 DPRINT1(
"NtReplyWaitReceivePort returned \"success\" status 0x%x\n",
Status);
446 MessageType = ReceiveMsg.
Header.u2.s2.Type;
475 ReplyMsg = &ReceiveMsg;
520 if (HardErrorMsg->
Response == 0xFFFFFFFF)
527 ReplyMsg = &ReceiveMsg;
534 ReplyMsg = &ReceiveMsg;
550 DPRINT1(
"CSRSS: %lx is invalid ServerDllIndex (%08x)\n",
551 ServerId, ServerDll);
567 DPRINT1(
"CSRSS: %lx is invalid ApiTableIndex for %Z\n",
579 DPRINT1(
"[%02x] CSRSS: [%02x,%02x] - %s Api called from %08x\n",
583 ServerDll->NameTable[ApiId],
677 ReplyMsg = &ReceiveMsg;
717 if (HardErrorMsg->
Response == 0xFFFFFFFF)
725 ReplyMsg = &ReceiveMsg;
754 DPRINT1(
"CSRSS: %lx is invalid ServerDllIndex (%08x)\n",
755 ServerId, ServerDll);
759 ReplyMsg = &ReceiveMsg;
773 DPRINT1(
"CSRSS: %lx is invalid ApiTableIndex for %Z\n",
778 ReplyMsg = &ReceiveMsg;
787 DPRINT1(
"[%02x] CSRSS: [%02x,%02x] - %s Api called from %08x, Process %08x - %08x\n",
791 ServerDll->NameTable[ApiId],
799 ReplyMsg = &ReceiveMsg;
850 DPRINT1(
"CSRSS: Error while replying to the death message, Status 0x%lx\n", Status2);
926 DPRINT1(
"CSRSS: sizeof( CONNECTINFO ) == %ld sizeof( API_MSG ) == %ld\n",
963 (
PVOID)hRequestEvent,
973 NextEntry = ListHead->
Flink;
976 while (NextEntry != ListHead)
993 NextEntry = NextEntry->
Flink;
1068 DPRINT1(
"CSRSS: CsrConnectToUser failed\n");
1129 SIZE_T SizeOfBufferThroughOffsetsArray;
1137 ClientCaptureBuffer = ApiMessage->CsrCaptureData;
1143 if ( ((
ULONG_PTR)ClientCaptureBuffer < CsrProcess->ClientViewBase) ||
1148 DPRINT1(
"*** CSRSS: CaptureBuffer outside of ClientView 1\n");
1164 if ( (EndOfClientBuffer < (
ULONG_PTR)ClientCaptureBuffer) ||
1165 (EndOfClientBuffer >=
CsrProcess->ClientViewBounds) )
1168 DPRINT1(
"*** CSRSS: CaptureBuffer outside of ClientView 2\n");
1183 SizeOfBufferThroughOffsetsArray =
1185 (PointerCount *
sizeof(
PVOID));
1187 (SizeOfBufferThroughOffsetsArray >
Length) )
1190 DPRINT1(
"*** CSRSS: CaptureBuffer %p has bad length\n", ClientCaptureBuffer);
1212 if (!ServerCaptureBuffer)
1252 while (PointerCount--)
1254 CurrentOffset = *OffsetPointer;
1256 if (CurrentOffset != 0)
1262 if ( ((CurrentOffset & (
sizeof(
PVOID)-1)) != 0) ||
1267 DPRINT1(
"*** CSRSS: CaptureBuffer MessagePointer outside of message\n");
1280 SizeOfBufferThroughOffsetsArray)) &&
1284 *(
PULONG_PTR)CurrentOffset += BufferDistance;
1289 DPRINT1(
"*** CSRSS: CaptureBuffer MessagePointer outside of ClientView\n");
1312 ApiMessage->CsrCaptureData = ServerCaptureBuffer;
1346 ServerCaptureBuffer = ApiMessage->CsrCaptureData;
1349 if (!ServerCaptureBuffer)
return;
1356 ApiMessage->CsrCaptureData = ClientCaptureBuffer;
1368 while (PointerCount--)
1370 CurrentOffset = *OffsetPointer;
1372 if (CurrentOffset != 0)
1378 *(
PULONG_PTR)CurrentOffset -= BufferDistance;
1387 RtlMoveMemory(ClientCaptureBuffer, ServerCaptureBuffer, ServerCaptureBuffer->
Size);
1444 if (!
Buffer || ElementSize == 0 ||
1452 if (!*
Buffer && ElementCount == 0)
1460 ApiMessage->Header.ClientId.UniqueProcess)
1469 (ElementCount * ElementSize))
1472 PointerCount = CaptureBuffer->PointerCount;
1473 OffsetPointer = CaptureBuffer->PointerOffsetsArray;
1474 while (PointerCount--)
1480 if (*OffsetPointer == BufferDistance)
1491 DPRINT1(
"CSRSRV: Bad message buffer %p\n", ApiMessage);
1523 (
PVOID*)MessageString,
1524 wcslen(*MessageString) + 1,
static const INTERNET_PORT ServerPort
UINT CALLBACK ServerThread(_Inout_ PVOID Parameter)
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
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)
NTSTATUS NTAPI NtCompleteConnectPort(IN HANDLE PortHandle)
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define CSR_API_NUMBER_TO_API_ID(ApiNumber)
#define CSR_API_NUMBER_TO_SERVER_ID(ApiNumber)
EXCEPTION_DISPOSITION NTAPI CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
NTSTATUS NTAPI CsrDestroyProcess(IN PCLIENT_ID Cid, IN NTSTATUS ExitStatus)
enum _CSR_REPLY_CODE CSR_REPLY_CODE
NTSTATUS NTAPI CsrDestroyThread(IN PCLIENT_ID Cid)
VOID NTAPI CsrDereferenceThread(IN PCSR_THREAD CsrThread)
PCSR_THREAD NTAPI CsrAddStaticServerThread(IN HANDLE hThread, IN PCLIENT_ID ClientId, IN ULONG ThreadFlags)
@ CsrThreadIsServerThread
struct _DBGKM_MSG * PDBGKM_MSG
#define NT_SUCCESS(StatCode)
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
#define InterlockedDecrementUL(Addend)
#define InterlockedIncrementUL(Addend)
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
#define EXCEPTION_EXECUTE_HANDLER
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
NTSYSAPI void WINAPI DbgBreakPoint(void)
NTSTATUS NTAPI LdrGetDllHandle(_In_opt_ PWSTR DllPath, _In_opt_ PULONG DllCharacteristics, _In_ PUNICODE_STRING DllName, _Out_ PVOID *DllHandle)
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)
struct _CLIENT_DIED_MSG * PCLIENT_DIED_MSG
#define LPC_CONNECTION_REQUEST
#define InitializeObjectAttributes(p, n, a, r, s)
struct _HARDERROR_MSG * PHARDERROR_MSG
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)
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
NTSTATUS NtTerminateThread(IN HANDLE ThreadHandle OPTIONAL, IN NTSTATUS ExitStatus)
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
#define NtCurrentProcess()
NTSTATUS NTAPI NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
_In_ ULONG _In_ ULONG _In_ ULONG Length
struct _REMOTE_PORT_VIEW REMOTE_PORT_VIEW
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
NTSTATUS NTAPI NtCreatePort(OUT PHANDLE PortHandle, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG MaxConnectInfoLength, IN ULONG MaxDataLength, IN ULONG MaxPoolUsage)
NTSTATUS NTAPI NtReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE ReplyMessage)
NTSTATUS NTAPI NtReplyWaitReceivePort(IN HANDLE PortHandle, OUT PVOID *PortContext OPTIONAL, IN PPORT_MESSAGE ReplyMessage OPTIONAL, OUT PPORT_MESSAGE ReceiveMessage)
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
#define STATUS_INVALID_HANDLE
#define STATUS_INVALID_CID
#define STATUS_ACCESS_VIOLATION
#define STATUS_ILLEGAL_FUNCTION
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define _SEH2_GetExceptionInformation()
#define _SEH2_YIELD(__stmt)
PCSR_CAPTURE_BUFFER CsrCaptureData
ULONG_PTR PointerOffsetsArray[ANYSIZE_ARRAY]
struct _CSR_CAPTURE_BUFFER * PreviousCaptureBuffer
PCSR_HARDERROR_CALLBACK HardErrorCallback
ULONG HighestApiSupported
PCSR_API_ROUTINE * DispatchTable
struct _LIST_ENTRY * Flink
ULONG Win32ClientInfo[31]
ULONG CountOfOwnedCriticalSections
BOOLEAN(* CsrClientThreadSetup)(VOID)
HANDLE NTAPI CsrQueryApiPort(VOID)
VOID NTAPI CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage)
UNICODE_STRING CsrApiPortName
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
volatile ULONG CsrpStaticThreadCount
NTSTATUS NTAPI CsrApiRequestThread(IN PVOID Parameter)
NTSTATUS NTAPI CsrApiHandleConnectionRequest(IN PCSR_API_MESSAGE ApiMessage)
volatile ULONG CsrpDynamicThreadTotal
NTSTATUS NTAPI CsrCallServerFromServer(IN PCSR_API_MESSAGE ReceiveMsg, IN OUT PCSR_API_MESSAGE ReplyMsg)
NTSTATUS NTAPI CsrApiPortInitialize(VOID)
ULONG CsrMaxApiRequestThreads
BOOLEAN NTAPI CsrValidateMessageString(IN PCSR_API_MESSAGE ApiMessage, IN PWSTR *MessageString)
PCSR_THREAD NTAPI CsrConnectToUser(VOID)
NTSTATUS NTAPI CsrpCheckRequestThreads(VOID)
BOOLEAN NTAPI CsrCaptureArguments(IN PCSR_THREAD CsrThread, IN PCSR_API_MESSAGE ApiMessage)
VOID NTAPI CsrLockedReferenceThread(IN PCSR_THREAD CsrThread)
PCSR_PROCESS CsrRootProcess
VOID NTAPI CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread)
UNICODE_STRING CsrDirectoryName
NTSTATUS NTAPI CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL, OUT PCSR_API_CONNECTINFO ConnectInfo)
PCSR_THREAD NTAPI CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL, IN PCLIENT_ID Cid)
#define CSR_SERVER_DLL_MAX
PCSR_THREAD NTAPI CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL, IN PCLIENT_ID ClientId)
VOID NTAPI CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess)
#define CsrAcquireProcessLock()
PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX]
#define CsrReleaseProcessLock()
VOID NTAPI CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess)
#define FIELD_OFFSET(t, f)
#define RtlMoveMemory(Destination, Source, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
static int Link(const char **args)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Out_ PCLIENT_ID ClientId
_Inout_opt_ PVOID Parameter
#define NtCurrentThread()