ReactOS 0.4.16-dev-136-g52192f1
csrsrv.h
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Client/Server Runtime SubSystem
4 * FILE: include/reactos/subsys/csr/csrsrv.h
5 * PURPOSE: Public definitions for CSR Servers
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
8 */
9
10#ifndef _CSRSRV_H
11#define _CSRSRV_H
12
13/*
14 * The CSR_DBG macro is defined for building CSR Servers
15 * with extended debugging information.
16 */
17#if DBG
18#define CSR_DBG
19#endif
20
21#include "csrmsg.h"
22
23
24/* TYPES **********************************************************************/
25
26// Used in csr/connect.c
27#define CSR_CSRSS_SECTION_SIZE 65536
28
29typedef struct _CSR_NT_SESSION
30{
35
36typedef struct _CSR_PROCESS
37{
60 PVOID ServerData[ANYSIZE_ARRAY]; // One structure per CSR server.
62
63typedef struct _CSR_THREAD
64{
76
77#define CsrGetClientThread() \
78 ((PCSR_THREAD)(NtCurrentTeb()->CsrClientThread))
79
80
81/* ENUMERATIONS ***************************************************************/
82
84{
96
97#define CsrProcessPriorityFlags (CsrProcessNormalPriority | \
98 CsrProcessIdlePriority | \
99 CsrProcessHighPriority | \
100 CsrProcessRealtimePriority)
101
103{
109
111{
116
118{
122
124{
128
129typedef enum _CSR_REPLY_CODE
130{
136
137
138/* FUNCTION TYPES AND STRUCTURES **********************************************/
139
140/*
141 * Wait block
142 */
143typedef
150 IN PVOID WaitArgument1,
151 IN PVOID WaitArgument2,
152 IN ULONG WaitFlags
153);
154
155typedef struct _CSR_WAIT_BLOCK
156{
157 ULONG Size; // Size of the wait block (variable-sized)
162 CSR_API_MESSAGE WaitApiMessage; // Variable-sized CSR API message
164
165
166/*
167 * Server DLL structure
168 */
169typedef
172 IN OUT PCSR_API_MESSAGE ApiMessage,
174);
175
176#define CSR_API(n) \
177 NTSTATUS NTAPI n(IN OUT PCSR_API_MESSAGE ApiMessage, \
178 IN OUT PCSR_REPLY_CODE ReplyCode OPTIONAL)
179
180typedef
184 IN OUT PVOID ConnectionInfo,
185 IN OUT PULONG ConnectionInfoLength
186);
187
188typedef
191
192typedef
197);
198
199typedef
202 IN PCSR_THREAD CsrThread,
203 IN PHARDERROR_MSG HardErrorMessage
204);
205
206typedef
210 IN ULONG Flags,
211 IN BOOLEAN FirstPhase
212);
213
214// See http://redplait.blogspot.fr/2011/07/csrserverdll.html
215typedef struct _CSR_SERVER_DLL
216{
225 PBOOLEAN ValidTable; // Table of booleans which describe whether or not a server function call is valid when it is called via CsrCallServerFromServer.
226/*
227 * On Windows Server 2003, CSR Servers contain
228 * the API Names Table only in Debug Builds.
229 */
230#ifdef CSR_DBG
231 PCHAR *NameTable;
232#endif
233
243#ifndef _WIN64
244 #ifdef CSR_DBG
245 C_ASSERT(FIELD_OFFSET(CSR_SERVER_DLL, SharedSection) == 0x3C);
246 #else
247 C_ASSERT(FIELD_OFFSET(CSR_SERVER_DLL, SharedSection) == 0x38);
248 #endif
249#endif
250
251typedef
254
255#define CSR_SERVER_DLL_INIT(n) \
256 NTSTATUS NTAPI n(IN PCSR_SERVER_DLL LoadedServerDll)
257
258
259/* PROTOTYPES ****************************************************************/
260
262NTAPI
263CsrServerInitialization(IN ULONG ArgumentCount,
264 IN PCHAR Arguments[]);
265
267NTAPI
270 IN ULONG ThreadFlags);
271
273NTAPI
275 IN OUT PCSR_API_MESSAGE ReplyMsg);
276
278NTAPI
280
282NTAPI
286 IN PCSR_NT_SESSION NtSession,
287 IN ULONG Flags,
288 IN PCLIENT_ID DebugCid);
289
291NTAPI
294
296NTAPI
300 IN BOOLEAN HaveClient);
301
303NTAPI
305 IN CSR_WAIT_FUNCTION WaitFunction,
306 IN PCSR_THREAD CsrWaitThread,
307 IN OUT PCSR_API_MESSAGE WaitApiMessage,
308 IN PVOID WaitContext);
309
311NTAPI
313
315NTAPI
317
318VOID
319NTAPI
321
322VOID
323NTAPI
325
326VOID
327NTAPI
329
331NTAPI
334
336NTAPI
338
340NTAPI
341CsrExecServerThread(IN PVOID ThreadHandler,
342 IN ULONG Flags);
343
345NTAPI
347 OUT PLUID Luid);
348
350NTAPI
352
354NTAPI
357
359NTAPI
361 OUT PCSR_THREAD *CsrThread);
362
363VOID
364NTAPI
365CsrMoveSatisfiedWait(IN PLIST_ENTRY DestinationList,
366 IN PLIST_ENTRY WaitList);
367
369NTAPI
371 IN BOOLEAN NotifyAll,
372 IN PVOID WaitArgument1,
373 IN PVOID WaitArgument2);
374
375VOID
376NTAPI
378
379HANDLE
380NTAPI
382
383VOID
384NTAPI
386
388NTAPI
390
391VOID
392NTAPI
394
395VOID
396NTAPI
398
399VOID
400NTAPI
402
404NTAPI
405CsrShutdownProcesses(IN PLUID CallerLuid,
406 IN ULONG Flags);
407
409NTAPI
411
413NTAPI
415
417NTAPI
419
421NTAPI
423 IN PVOID *Buffer,
424 IN ULONG ElementCount,
425 IN ULONG ElementSize);
426
428NTAPI
430 IN PWSTR *MessageString);
431
432#endif // _CSRSRV_H
433
434/* EOF */
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
HANDLE NTAPI CsrQueryApiPort(VOID)
Definition: api.c:1097
EXCEPTION_DISPOSITION NTAPI CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: server.c:643
NTSTATUS NTAPI CsrLockThreadByClientId(IN HANDLE Tid, OUT PCSR_THREAD *CsrThread)
Definition: thredsup.c:965
VOID NTAPI CsrReferenceThread(IN PCSR_THREAD CsrThread)
Definition: thredsup.c:1043
enum _SHUTDOWN_RESULT SHUTDOWN_RESULT
NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1410
NTSTATUS NTAPI CsrCreateRemoteThread(IN HANDLE hThread, IN PCLIENT_ID ClientId)
Definition: thredsup.c:569
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:932
NTSTATUS NTAPI CsrDestroyProcess(IN PCLIENT_ID Cid, IN NTSTATUS ExitStatus)
Definition: procsup.c:735
enum _CSR_REPLY_CODE CSR_REPLY_CODE
struct _CSR_SERVER_DLL CSR_SERVER_DLL
ULONG(NTAPI * PCSR_SHUTDOWNPROCESS_CALLBACK)(IN PCSR_PROCESS CsrProcess, IN ULONG Flags, IN BOOLEAN FirstPhase)
Definition: csrsrv.h:208
NTSTATUS NTAPI CsrCreateThread(IN PCSR_PROCESS CsrProcess, IN HANDLE hThread, IN PCLIENT_ID ClientId, IN BOOLEAN HaveClient)
Definition: thredsup.c:678
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1057
VOID NTAPI CsrDereferenceWait(IN PLIST_ENTRY WaitList)
Definition: wait.c:266
VOID NTAPI CsrSetForegroundPriority(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1138
NTSTATUS NTAPI CsrDestroyThread(IN PCLIENT_ID Cid)
Definition: thredsup.c:814
BOOLEAN(NTAPI * CSR_WAIT_FUNCTION)(IN PLIST_ENTRY WaitList, IN PCSR_THREAD WaitThread, IN PCSR_API_MESSAGE WaitApiMessage, IN PVOID WaitContext, IN PVOID WaitArgument1, IN PVOID WaitArgument2, IN ULONG WaitFlags)
Definition: csrsrv.h:145
VOID NTAPI CsrDereferenceThread(IN PCSR_THREAD CsrThread)
Definition: thredsup.c:776
enum _CSR_PROCESS_FLAGS CSR_PROCESS_FLAGS
enum _CSR_DEBUG_FLAGS * PCSR_PROCESS_DEBUG_FLAGS
PCSR_THREAD NTAPI CsrAddStaticServerThread(IN HANDLE hThread, IN PCLIENT_ID ClientId, IN ULONG ThreadFlags)
Definition: thredsup.c:512
_CSR_PROCESS_FLAGS
Definition: csrsrv.h:84
@ CsrProcessTerminated
Definition: csrsrv.h:92
@ CsrProcessLastThreadTerminated
Definition: csrsrv.h:93
@ CsrProcessRealtimePriority
Definition: csrsrv.h:90
@ CsrProcessSkipShutdown
Definition: csrsrv.h:86
@ CsrProcessCreateNewGroup
Definition: csrsrv.h:91
@ CsrProcessIsConsoleApp
Definition: csrsrv.h:94
@ CsrProcessHighPriority
Definition: csrsrv.h:89
@ CsrProcessTerminating
Definition: csrsrv.h:85
@ CsrProcessIdlePriority
Definition: csrsrv.h:88
@ CsrProcessNormalPriority
Definition: csrsrv.h:87
struct _CSR_THREAD * PCSR_THREAD
enum _CSR_PROCESS_FLAGS * PCSR_PROCESS_FLAGS
NTSTATUS(NTAPI * PCSR_API_ROUTINE)(IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_REPLY_CODE ReplyCode OPTIONAL)
Definition: csrsrv.h:171
struct _CSR_PROCESS CSR_PROCESS
VOID(NTAPI * PCSR_HARDERROR_CALLBACK)(IN PCSR_THREAD CsrThread, IN PHARDERROR_MSG HardErrorMessage)
Definition: csrsrv.h:201
enum _CSR_REPLY_CODE * PCSR_REPLY_CODE
_CSR_DEBUG_FLAGS
Definition: csrsrv.h:124
@ CsrDebugProcessChildren
Definition: csrsrv.h:126
@ CsrDebugOnlyThisProcess
Definition: csrsrv.h:125
enum _CSR_DEBUG_FLAGS CSR_PROCESS_DEBUG_FLAGS
NTSTATUS(NTAPI * PCSR_SERVER_DLL_INIT_CALLBACK)(IN PCSR_SERVER_DLL LoadedServerDll)
Definition: csrsrv.h:253
enum _SHUTDOWN_RESULT * PSHUTDOWN_RESULT
enum _CSR_THREAD_FLAGS CSR_THREAD_FLAGS
NTSTATUS NTAPI CsrCallServerFromServer(IN PCSR_API_MESSAGE ReceiveMsg, IN OUT PCSR_API_MESSAGE ReplyMsg)
Definition: api.c:51
VOID NTAPI CsrMoveSatisfiedWait(IN PLIST_ENTRY DestinationList, IN PLIST_ENTRY WaitList)
Definition: wait.c:330
VOID NTAPI CsrSetCallingSpooler(ULONG Reserved)
Definition: server.c:620
_CSR_SHUTDOWN_FLAGS
Definition: csrsrv.h:118
@ CsrShutdownOther
Definition: csrsrv.h:120
@ CsrShutdownSystem
Definition: csrsrv.h:119
NTSTATUS NTAPI CsrLockProcessByClientId(IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess OPTIONAL)
struct _CSR_WAIT_BLOCK CSR_WAIT_BLOCK
struct _CSR_THREAD CSR_THREAD
_CSR_REPLY_CODE
Definition: csrsrv.h:130
@ CsrReplyAlreadySent
Definition: csrsrv.h:134
@ CsrReplyImmediately
Definition: csrsrv.h:131
@ CsrReplyDeadClient
Definition: csrsrv.h:133
@ CsrReplyPending
Definition: csrsrv.h:132
struct _CSR_SERVER_DLL * PCSR_SERVER_DLL
enum _CSR_SHUTDOWN_FLAGS CSR_SHUTDOWN_FLAGS
enum _CSR_SHUTDOWN_FLAGS * PCSR_SHUTDOWN_FLAGS
NTSTATUS NTAPI CsrUnlockThread(IN PCSR_THREAD CsrThread)
Definition: thredsup.c:1075
VOID NTAPI CsrPopulateDosDevices(VOID)
Definition: init.c:1146
_CSR_THREAD_FLAGS
Definition: csrsrv.h:103
@ CsrThreadAlertable
Definition: csrsrv.h:104
@ CsrThreadTerminated
Definition: csrsrv.h:106
@ CsrThreadInTermination
Definition: csrsrv.h:105
@ CsrThreadIsServerThread
Definition: csrsrv.h:107
NTSTATUS NTAPI CsrShutdownProcesses(IN PLUID CallerLuid, IN ULONG Flags)
Definition: procsup.c:1277
enum _CSR_THREAD_FLAGS * PCSR_THREAD_FLAGS
NTSTATUS NTAPI CsrDebugProcessStop(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:667
NTSTATUS NTAPI CsrGetProcessLuid(IN HANDLE hProcess OPTIONAL, OUT PLUID Luid)
Definition: procsup.c:828
NTSTATUS(NTAPI * PCSR_CONNECT_CALLBACK)(IN PCSR_PROCESS CsrProcess, IN OUT PVOID ConnectionInfo, IN OUT PULONG ConnectionInfoLength)
Definition: csrsrv.h:182
BOOLEAN NTAPI CsrValidateMessageString(IN PCSR_API_MESSAGE ApiMessage, IN PWSTR *MessageString)
Definition: api.c:1517
PCSR_THREAD NTAPI CsrConnectToUser(VOID)
Definition: api.c:1021
VOID(NTAPI * PCSR_DISCONNECT_CALLBACK)(IN PCSR_PROCESS CsrProcess)
Definition: csrsrv.h:190
NTSTATUS NTAPI CsrDebugProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:643
NTSTATUS NTAPI CsrExecServerThread(IN PVOID ThreadHandler, IN ULONG Flags)
Definition: thredsup.c:886
BOOLEAN NTAPI CsrCreateWait(IN PLIST_ENTRY WaitList, IN CSR_WAIT_FUNCTION WaitFunction, IN PCSR_THREAD CsrWaitThread, IN OUT PCSR_API_MESSAGE WaitApiMessage, IN PVOID WaitContext)
Definition: wait.c:209
NTSTATUS(NTAPI * PCSR_NEWPROCESS_CALLBACK)(IN PCSR_PROCESS Parent, IN PCSR_PROCESS CsrProcess)
Definition: csrsrv.h:194
struct _CSR_NT_SESSION * PCSR_NT_SESSION
_SHUTDOWN_RESULT
Definition: csrsrv.h:111
@ CsrShutdownNonCsrProcess
Definition: csrsrv.h:113
@ CsrShutdownCsrProcess
Definition: csrsrv.h:112
@ CsrShutdownCancelled
Definition: csrsrv.h:114
NTSTATUS NTAPI CsrServerInitialization(IN ULONG ArgumentCount, IN PCHAR Arguments[])
Definition: init.c:1011
struct _CSR_NT_SESSION CSR_NT_SESSION
VOID NTAPI CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1107
NTSTATUS NTAPI CsrCreateProcess(IN HANDLE hProcess, IN HANDLE hThread, IN PCLIENT_ID ClientId, IN PCSR_NT_SESSION NtSession, IN ULONG Flags, IN PCLIENT_ID DebugCid)
Definition: procsup.c:422
BOOLEAN NTAPI CsrNotifyWait(IN PLIST_ENTRY WaitList, IN BOOLEAN NotifyAll, IN PVOID WaitArgument1, IN PVOID WaitArgument2)
Definition: wait.c:388
VOID NTAPI CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:691
struct _CSR_PROCESS * PCSR_PROCESS
struct _CSR_WAIT_BLOCK * PCSR_WAIT_BLOCK
#define NTSTATUS
Definition: precomp.h:21
enum _EXCEPTION_DISPOSITION EXCEPTION_DISPOSITION
#define C_ASSERT(e)
Definition: intsafe.h:73
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
_In_ NTSTATUS ExitStatus
Definition: psfuncs.h:867
HANDLE hThread
Definition: wizard.c:28
#define BOOLEAN
Definition: pedump.c:73
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
ULONG SessionId
Definition: csrsrv.h:33
LIST_ENTRY SessionLink
Definition: csrsrv.h:32
ULONG ReferenceCount
Definition: csrsrv.h:31
ULONG ThreadCount
Definition: csrsrv.h:55
ULONG DebugFlags
Definition: csrsrv.h:49
CLIENT_ID ClientId
Definition: csrsrv.h:38
ULONG ShutdownFlags
Definition: csrsrv.h:59
LIST_ENTRY ThreadList
Definition: csrsrv.h:40
ULONG ShutdownLevel
Definition: csrsrv.h:58
ULONG fVDM
Definition: csrsrv.h:54
ULONG ProcessGroupId
Definition: csrsrv.h:52
PCSR_NT_SESSION NtSession
Definition: csrsrv.h:41
ULONG Flags
Definition: csrsrv.h:48
ULONG ExpectedVersion
Definition: csrsrv.h:42
ULONG SequenceNumber
Definition: csrsrv.h:47
ULONG ProcessGroupSequence
Definition: csrsrv.h:53
LIST_ENTRY ListLink
Definition: csrsrv.h:39
ULONG_PTR ClientViewBase
Definition: csrsrv.h:44
ULONG PriorityClass
Definition: csrsrv.h:56
HANDLE ClientPort
Definition: csrsrv.h:43
ULONG_PTR ClientViewBounds
Definition: csrsrv.h:45
PVOID ServerData[ANYSIZE_ARRAY]
Definition: csrsrv.h:60
ULONG ReferenceCount
Definition: csrsrv.h:51
CLIENT_ID DebugCid
Definition: csrsrv.h:50
ULONG Reserved
Definition: csrsrv.h:57
HANDLE ProcessHandle
Definition: csrsrv.h:46
PCSR_HARDERROR_CALLBACK HardErrorCallback
Definition: csrsrv.h:237
ULONG HighestApiSupported
Definition: csrsrv.h:223
PBOOLEAN ValidTable
Definition: csrsrv.h:225
ULONG Unknown2[3]
Definition: csrsrv.h:241
PCSR_DISCONNECT_CALLBACK DisconnectCallback
Definition: csrsrv.h:236
ANSI_STRING Name
Definition: csrsrv.h:218
PCSR_NEWPROCESS_CALLBACK NewProcessCallback
Definition: csrsrv.h:239
PVOID SharedSection
Definition: csrsrv.h:238
PCSR_API_ROUTINE * DispatchTable
Definition: csrsrv.h:224
ULONG Unknown
Definition: csrsrv.h:221
PCSR_SHUTDOWNPROCESS_CALLBACK ShutdownProcessCallback
Definition: csrsrv.h:240
ULONG ServerId
Definition: csrsrv.h:220
ULONG ApiBase
Definition: csrsrv.h:222
ULONG Length
Definition: csrsrv.h:217
HANDLE ServerHandle
Definition: csrsrv.h:219
ULONG SizeOfProcessData
Definition: csrsrv.h:234
PCSR_CONNECT_CALLBACK ConnectCallback
Definition: csrsrv.h:235
ULONG Flags
Definition: csrsrv.h:72
LARGE_INTEGER CreateTime
Definition: csrsrv.h:65
struct _CSR_WAIT_BLOCK * WaitBlock
Definition: csrsrv.h:70
ULONG ReferenceCount
Definition: csrsrv.h:73
LIST_ENTRY HashLinks
Definition: csrsrv.h:67
HANDLE ThreadHandle
Definition: csrsrv.h:71
ULONG ImpersonationCount
Definition: csrsrv.h:74
CLIENT_ID ClientId
Definition: csrsrv.h:68
LIST_ENTRY Link
Definition: csrsrv.h:66
PCSR_PROCESS Process
Definition: csrsrv.h:69
PVOID WaitContext
Definition: csrsrv.h:159
PCSR_THREAD WaitThread
Definition: csrsrv.h:160
ULONG Size
Definition: csrsrv.h:157
LIST_ENTRY WaitList
Definition: csrsrv.h:158
CSR_WAIT_FUNCTION WaitFunction
Definition: csrsrv.h:161
CSR_API_MESSAGE WaitApiMessage
Definition: csrsrv.h:162
Definition: typedefs.h:120
uint16_t * PWSTR
Definition: typedefs.h:56
#define OPTIONAL
Definition: typedefs.h:41
uint32_t * PULONG
Definition: typedefs.h:59
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
unsigned char * PBOOLEAN
Definition: typedefs.h:53
#define ANYSIZE_ARRAY
Definition: typedefs.h:46
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
PKPROCESS CsrProcess
Definition: videoprt.c:39
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1151