e5d1280deb8ae8a08a1ab25d7ae00b68b27de111
[reactos.git] / include / reactos / subsys / csrss / server.h
1 /*
2 * PROJECT: ReactOS Native Headers
3 * FILE: include/subsys/csrss/server.h
4 * PURPOSE: Public Definitions for CSR Servers
5 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
6 * Hermes Belusca-Maito (hermes.belusca@sfr.fr)
7 */
8
9 #ifndef _CSRSERVER_H
10 #define _CSRSERVER_H
11
12 #ifdef _MSC_VER
13 #pragma warning(push)
14 #pragma warning (disable:4201)
15 #endif
16
17 #include "msg.h"
18
19 /* TYPES **********************************************************************/
20
21 typedef struct _CSR_NT_SESSION
22 {
23 ULONG ReferenceCount;
24 LIST_ENTRY SessionLink;
25 ULONG SessionId;
26 } CSR_NT_SESSION, *PCSR_NT_SESSION;
27
28 /*** old thingie, remove it later... (put it in winsrv -- console) ***/
29 typedef struct _CSRSS_CON_PROCESS_DATA
30 {
31 HANDLE ConsoleEvent;
32 struct tagCSRSS_CONSOLE *Console;
33 struct tagCSRSS_CONSOLE *ParentConsole;
34 BOOL bInheritHandles;
35 RTL_CRITICAL_SECTION HandleTableLock;
36 ULONG HandleTableSize;
37 struct _CSRSS_HANDLE *HandleTable;
38 PCONTROLDISPATCHER CtrlDispatcher;
39 LIST_ENTRY ConsoleLink;
40 } CSRSS_CON_PROCESS_DATA, *PCSRSS_CON_PROCESS_DATA;
41 /*********************************************************************/
42 typedef struct _CSR_PROCESS
43 {
44 CLIENT_ID ClientId;
45 LIST_ENTRY ListLink;
46 LIST_ENTRY ThreadList;
47 struct _CSR_PROCESS *Parent;
48 PCSR_NT_SESSION NtSession;
49 ULONG ExpectedVersion;
50 HANDLE ClientPort;
51 ULONG_PTR ClientViewBase;
52 ULONG_PTR ClientViewBounds;
53 HANDLE ProcessHandle;
54 ULONG SequenceNumber;
55 ULONG Flags;
56 ULONG DebugFlags;
57 CLIENT_ID DebugCid;
58 ULONG ReferenceCount;
59 ULONG ProcessGroupId;
60 ULONG ProcessGroupSequence;
61 ULONG fVDM;
62 ULONG ThreadCount;
63 ULONG PriorityClass;
64 ULONG Reserved;
65 ULONG ShutdownLevel;
66 ULONG ShutdownFlags;
67 // PVOID ServerData[ANYSIZE_ARRAY];
68 CSRSS_CON_PROCESS_DATA; //// FIXME: Remove it after we activate the previous member.
69 } CSR_PROCESS, *PCSR_PROCESS;
70
71 typedef struct _CSR_THREAD
72 {
73 LARGE_INTEGER CreateTime;
74 LIST_ENTRY Link;
75 LIST_ENTRY HashLinks;
76 CLIENT_ID ClientId;
77 PCSR_PROCESS Process;
78 struct _CSR_WAIT_BLOCK *WaitBlock;
79 HANDLE ThreadHandle;
80 ULONG Flags;
81 ULONG ReferenceCount;
82 ULONG ImpersonationCount;
83 } CSR_THREAD, *PCSR_THREAD;
84
85 #define CsrGetClientThread() \
86 ((PCSR_THREAD)(NtCurrentTeb()->CsrClientThread))
87
88
89 /* ENUMERATIONS ***************************************************************/
90
91 typedef enum _CSR_PROCESS_FLAGS
92 {
93 CsrProcessTerminating = 0x1,
94 CsrProcessSkipShutdown = 0x2,
95 CsrProcessNormalPriority = 0x10,
96 CsrProcessIdlePriority = 0x20,
97 CsrProcessHighPriority = 0x40,
98 CsrProcessRealtimePriority = 0x80,
99 CsrProcessCreateNewGroup = 0x100,
100 CsrProcessTerminated = 0x200,
101 CsrProcessLastThreadTerminated = 0x400,
102 CsrProcessIsConsoleApp = 0x800
103 } CSR_PROCESS_FLAGS, *PCSR_PROCESS_FLAGS;
104
105 #define CsrProcessPriorityFlags (CsrProcessNormalPriority | \
106 CsrProcessIdlePriority | \
107 CsrProcessHighPriority | \
108 CsrProcessRealtimePriority)
109
110 typedef enum _CSR_THREAD_FLAGS
111 {
112 CsrThreadAltertable = 0x1,
113 CsrThreadInTermination = 0x2,
114 CsrThreadTerminated = 0x4,
115 CsrThreadIsServerThread = 0x10
116 } CSR_THREAD_FLAGS, *PCSR_THREAD_FLAGS;
117
118 typedef enum _SHUTDOWN_RESULT
119 {
120 CsrShutdownCsrProcess = 1,
121 CsrShutdownNonCsrProcess,
122 CsrShutdownCancelled
123 } SHUTDOWN_RESULT, *PSHUTDOWN_RESULT;
124
125 typedef enum _CSR_SHUTDOWN_FLAGS
126 {
127 CsrShutdownSystem = 4,
128 CsrShutdownOther = 8
129 } CSR_SHUTDOWN_FLAGS, *PCSR_SHUTDOWN_FLAGS;
130
131 typedef enum _CSR_DEBUG_FLAGS
132 {
133 CsrDebugOnlyThisProcess = 1,
134 CsrDebugProcessChildren = 2
135 } CSR_PROCESS_DEBUG_FLAGS, *PCSR_PROCESS_DEBUG_FLAGS;
136
137
138 /*
139 * Wait block
140 */
141 typedef
142 BOOLEAN
143 (*CSR_WAIT_FUNCTION)(
144 IN PLIST_ENTRY WaitList,
145 IN PCSR_THREAD WaitThread,
146 IN PCSR_API_MESSAGE WaitApiMessage,
147 IN PVOID WaitContext,
148 IN PVOID WaitArgument1,
149 IN PVOID WaitArgument2,
150 IN ULONG WaitFlags
151 );
152
153 typedef struct _CSR_WAIT_BLOCK
154 {
155 ULONG Size;
156 LIST_ENTRY WaitList;
157 LIST_ENTRY UserWaitList;
158 PVOID WaitContext;
159 PCSR_THREAD WaitThread;
160 CSR_WAIT_FUNCTION WaitFunction;
161 CSR_API_MESSAGE WaitApiMessage;
162 } CSR_WAIT_BLOCK, *PCSR_WAIT_BLOCK;
163
164
165 /*
166 * Server DLL structure
167 */
168 typedef
169 NTSTATUS
170 (NTAPI *PCSR_API_ROUTINE)(
171 IN OUT PCSR_API_MESSAGE ApiMessage,
172 OUT PULONG Reply
173 );
174
175 #define CSR_API(n) NTSTATUS NTAPI n ( \
176 IN OUT PCSR_API_MESSAGE ApiMessage, \
177 OUT PULONG Reply)
178
179 typedef
180 NTSTATUS
181 (NTAPI *PCSR_CONNECT_CALLBACK)(
182 IN PCSR_PROCESS CsrProcess,
183 IN OUT PVOID ConnectionInfo,
184 IN OUT PULONG ConnectionInfoLength
185 );
186
187 typedef
188 VOID
189 (NTAPI *PCSR_DISCONNECT_CALLBACK)(IN PCSR_PROCESS CsrProcess);
190
191 typedef
192 NTSTATUS
193 (NTAPI *PCSR_NEWPROCESS_CALLBACK)(
194 IN PCSR_PROCESS Parent,
195 IN PCSR_PROCESS CsrProcess
196 );
197
198 typedef
199 VOID
200 (NTAPI *PCSR_HARDERROR_CALLBACK)(
201 IN PCSR_THREAD CsrThread,
202 IN PHARDERROR_MSG HardErrorMessage
203 );
204
205 typedef
206 ULONG
207 (NTAPI *PCSR_SHUTDOWNPROCESS_CALLBACK)(
208 IN PCSR_PROCESS CsrProcess,
209 IN ULONG Flags,
210 IN BOOLEAN FirstPhase
211 );
212
213 typedef struct _CSR_SERVER_DLL
214 {
215 ULONG Length;
216 HANDLE Event;
217 ANSI_STRING Name;
218 HANDLE ServerHandle;
219 ULONG ServerId;
220 ULONG Unknown;
221 ULONG ApiBase;
222 ULONG HighestApiSupported;
223 PCSR_API_ROUTINE *DispatchTable;
224 PBOOLEAN ValidTable;
225 PCHAR *NameTable;
226 ULONG SizeOfProcessData;
227 PCSR_CONNECT_CALLBACK ConnectCallback;
228 PCSR_DISCONNECT_CALLBACK DisconnectCallback;
229 PCSR_HARDERROR_CALLBACK HardErrorCallback;
230 PVOID SharedSection;
231 PCSR_NEWPROCESS_CALLBACK NewProcessCallback;
232 PCSR_SHUTDOWNPROCESS_CALLBACK ShutdownProcessCallback;
233 ULONG Unknown2[3];
234 } CSR_SERVER_DLL, *PCSR_SERVER_DLL;
235
236
237 /* FUNCTION TYPES *************************************************************/
238
239 typedef
240 NTSTATUS
241 (NTAPI *PCSR_SERVER_DLL_INIT_CALLBACK)(IN PCSR_SERVER_DLL LoadedServerDll);
242
243 /*
244 NTSTATUS
245 NTAPI
246 CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
247 */
248
249
250 /* PROTOTYPES ****************************************************************/
251
252 NTSTATUS
253 NTAPI
254 CsrServerInitialization(
255 IN ULONG ArgumentCount,
256 IN PCHAR Arguments[]
257 );
258
259 ///////////
260 BOOLEAN
261 NTAPI
262 CsrCaptureArguments(
263 IN PCSR_THREAD CsrThread,
264 IN PCSR_API_MESSAGE ApiMessage
265 );
266
267 VOID
268 NTAPI
269 CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
270 //////////
271
272 PCSR_THREAD
273 NTAPI
274 CsrAddStaticServerThread(
275 IN HANDLE hThread,
276 IN PCLIENT_ID ClientId,
277 IN ULONG ThreadFlags
278 );
279
280 PCSR_THREAD
281 NTAPI
282 CsrConnectToUser(VOID);
283
284 BOOLEAN
285 NTAPI
286 CsrImpersonateClient(IN PCSR_THREAD CsrThread);
287
288 BOOLEAN
289 NTAPI
290 CsrRevertToSelf(VOID);
291
292 VOID
293 NTAPI
294 CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess);
295
296 LONG
297 NTAPI
298 CsrUnhandledExceptionFilter(
299 IN PEXCEPTION_POINTERS ExceptionInfo
300 );
301
302
303
304 #ifdef _MSC_VER
305 #pragma warning(pop)
306 #endif
307
308 #endif // _CSRSERVER_H
309
310 /* EOF */