[REACTOS]
[reactos.git] / reactos / deprecated / csr / csrsrv / srv.h
1 #ifndef _SRV_H
2 #define _SRV_H
3
4 /* PSDK/NDK Headers */
5 #define NTOS_MODE_USER
6 #include <stdio.h>
7 #define WIN32_NO_STATUS
8 #include <windows.h>
9 #include <winnt.h>
10 #include <ndk/ntndk.h>
11
12 /* CSR Header */
13 #include <csr/server.h>
14 #include <sm/smmsg.h>
15
16 /* PSEH for SEH Support */
17 #include <pseh/pseh2.h>
18
19 /* DEFINES *******************************************************************/
20
21 #define CSR_SERVER_DLL_MAX 4
22
23 #define CsrAcquireProcessLock() \
24 RtlEnterCriticalSection(&CsrProcessLock);
25
26 #define CsrReleaseProcessLock() \
27 RtlLeaveCriticalSection(&CsrProcessLock);
28
29 #define CsrAcquireWaitLock() \
30 RtlEnterCriticalSection(&CsrWaitListsLock);
31
32 #define CsrReleaseWaitLock() \
33 RtlLeaveCriticalSection(&CsrWaitListsLock);
34
35 #define CsrAcquireNtSessionLock() \
36 RtlEnterCriticalSection(&CsrNtSessionLock)
37
38 #define CsrReleaseNtSessionLock() \
39 RtlLeaveCriticalSection(&CsrNtSessionLock)
40
41 #define CsrHashThread(t) \
42 (HandleToUlong(t)&(256 - 1))
43
44 #define ProcessStructureListLocked() \
45 (CsrProcessLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread)
46
47 #define SM_REG_KEY \
48 L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager"
49
50 #define SESSION_ROOT L"\\Sessions"
51 #define GLOBAL_ROOT L"\\GLOBAL??"
52 #define SYMLINK_NAME L"SymbolicLink"
53 #define SB_PORT_NAME L"SbAbiPort"
54 #define CSR_PORT_NAME L"ApiPort"
55 #define UNICODE_PATH_SEP L"\\"
56
57 #define ROUND_UP(n, align) ROUND_DOWN(((ULONG)n) + (align) - 1, (align))
58 #define ROUND_DOWN(n, align) (((ULONG)n) & ~((align) - 1l))
59
60 /* DATA **********************************************************************/
61
62 extern ULONG CsrTotalPerProcessDataLength;
63 extern ULONG CsrMaxApiRequestThreads;
64 extern PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX];
65 extern PCSR_PROCESS CsrRootProcess;
66 extern UNICODE_STRING CsrSbApiPortName;
67 extern UNICODE_STRING CsrApiPortName;
68 extern HANDLE CsrSbApiPort;
69 extern HANDLE CsrSmApiPort;
70 extern HANDLE CsrApiPort;
71 extern HANDLE CsrHeap;
72 extern RTL_CRITICAL_SECTION CsrProcessLock;
73 extern RTL_CRITICAL_SECTION CsrWaitListsLock;
74 extern LIST_ENTRY CsrThreadHashTable[256];
75 extern HANDLE CsrInitializationEvent;
76 extern SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
77 extern UNICODE_STRING CsrDirectoryName;
78 extern HANDLE CsrObjectDirectory;
79 extern PSB_API_ROUTINE CsrServerSbApiDispatch[5];
80 extern ULONG CsrDebug;
81
82 /* FUNCTIONS *****************************************************************/
83
84 /* FIXME: Public APIs should go in the CSR Server Include */
85 BOOLEAN
86 NTAPI
87 CsrCaptureArguments(
88 IN PCSR_THREAD CsrThread,
89 IN PCSR_API_MESSAGE ApiMessage
90 );
91
92 NTSTATUS
93 NTAPI
94 CsrLoadServerDll(
95 IN PCHAR DllString,
96 IN PCHAR EntryPoint,
97 IN ULONG ServerId
98 );
99
100 NTSTATUS
101 NTAPI
102 CsrServerInitialization(
103 ULONG ArgumentCount,
104 PCHAR Arguments[]
105 );
106
107 BOOLEAN
108 NTAPI
109 UnProtectHandle(IN HANDLE ObjectHandle);
110
111 VOID
112 NTAPI
113 CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess);
114
115 VOID
116 NTAPI
117 CsrLockedReferenceThread(IN PCSR_THREAD CsrThread);
118
119 NTSTATUS
120 NTAPI
121 CsrCreateSessionObjectDirectory(IN ULONG SessionId);
122
123 NTSTATUS
124 NTAPI
125 CsrCreateObjectDirectory(IN PCHAR ObjectDirectory);
126
127 NTSTATUS
128 NTAPI
129 CsrSrvCreateSharedSection(IN PCHAR ParameterValue);
130
131 NTSTATUS
132 NTAPI
133 CsrInitializeNtSessionList(VOID);
134
135 NTSTATUS
136 NTAPI
137 CsrInitializeProcessStructure(VOID);
138
139 NTSTATUS
140 NTAPI
141 CsrApiPortInitialize(VOID);
142
143 NTSTATUS
144 NTAPI
145 CsrSbApiPortInitialize(VOID);
146
147 BOOLEAN
148 NTAPI
149 CsrSbCreateSession(IN PSB_API_MSG ApiMessage);
150
151 BOOLEAN
152 NTAPI
153 CsrSbTerminateSession(IN PSB_API_MSG ApiMessage);
154
155 BOOLEAN
156 NTAPI
157 CsrSbForeignSessionComplete(IN PSB_API_MSG ApiMessage);
158
159 BOOLEAN
160 NTAPI
161 CsrSbCreateProcess(IN PSB_API_MSG ApiMessage);
162
163 PCSR_PROCESS
164 NTAPI
165 CsrAllocateProcess(VOID);
166
167 PCSR_THREAD
168 NTAPI
169 CsrAllocateThread(IN PCSR_PROCESS CsrProcess);
170
171 VOID
172 NTAPI
173 CsrInsertThread(
174 IN PCSR_PROCESS Process,
175 IN PCSR_THREAD Thread
176 );
177
178 VOID
179 NTAPI
180 CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess);
181
182 VOID
183 NTAPI
184 CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess);
185
186 NTSTATUS
187 NTAPI
188 CsrGetProcessLuid(
189 HANDLE hProcess,
190 PLUID Luid
191 );
192
193 BOOLEAN
194 NTAPI
195 CsrImpersonateClient(IN PCSR_THREAD CsrThread);
196
197 BOOLEAN
198 NTAPI
199 CsrRevertToSelf(VOID);
200
201 PCSR_THREAD
202 NTAPI
203 CsrLocateThreadByClientId(
204 OUT PCSR_PROCESS *Process,
205 IN PCLIENT_ID ClientId
206 );
207
208 VOID
209 NTAPI
210 CsrDereferenceNtSession(
211 IN PCSR_NT_SESSION Session,
212 NTSTATUS ExitStatus
213 );
214
215 VOID
216 NTAPI
217 CsrReferenceNtSession(PCSR_NT_SESSION Session);
218
219 VOID
220 NTAPI
221 CsrLockedDereferenceThread(PCSR_THREAD CsrThread);
222
223 VOID
224 NTAPI
225 CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess);
226
227 NTSTATUS
228 NTAPI
229 CsrLockProcessByClientId(
230 IN HANDLE Pid,
231 OUT PCSR_PROCESS *CsrProcess OPTIONAL
232 );
233
234 NTSTATUS
235 NTAPI
236 CsrUnlockProcess(PCSR_PROCESS CsrProcess);
237
238 NTSTATUS
239 NTAPI
240 CsrSrvClientConnect(
241 IN OUT PCSR_API_MESSAGE ApiMessage,
242 IN OUT PULONG Reply
243 );
244
245 NTSTATUS
246 NTAPI
247 CsrSrvUnusedFunction(
248 IN OUT PCSR_API_MESSAGE ApiMessage,
249 IN OUT PULONG Reply
250 );
251
252 NTSTATUS
253 NTAPI
254 CsrSrvIdentifyAlertableThread(
255 IN OUT PCSR_API_MESSAGE ApiMessage,
256 IN OUT PULONG Reply
257 );
258
259 NTSTATUS
260 NTAPI
261 CsrSrvSetPriorityClass(
262 IN OUT PCSR_API_MESSAGE ApiMessage,
263 IN OUT PULONG Reply
264 );
265
266 NTSTATUS
267 NTAPI
268 CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
269
270 VOID
271 NTAPI
272 CsrDereferenceThread(PCSR_THREAD CsrThread);
273
274 VOID
275 NTAPI
276 CsrSbApiRequestThread(IN PVOID Parameter);
277
278 NTSTATUS
279 NTAPI
280 CsrApiRequestThread(IN PVOID Parameter);
281
282 BOOLEAN
283 NTAPI
284 ProtectHandle(IN HANDLE ObjectHandle);
285
286 PCSR_THREAD
287 NTAPI
288 CsrAddStaticServerThread(
289 IN HANDLE hThread,
290 IN PCLIENT_ID ClientId,
291 IN ULONG ThreadFlags
292 );
293
294 PCSR_THREAD
295 NTAPI
296 CsrConnectToUser(VOID);
297
298 PCSR_THREAD
299 NTAPI
300 CsrLocateThreadInProcess(
301 IN PCSR_PROCESS CsrProcess OPTIONAL,
302 IN PCLIENT_ID Cid
303 );
304
305 NTSTATUS
306 NTAPI
307 CsrSbApiHandleConnectionRequest(IN PSB_API_MSG Message);
308
309 NTSTATUS
310 NTAPI
311 CsrApiHandleConnectionRequest(IN PCSR_API_MESSAGE ApiMessage);
312
313 NTSTATUS
314 NTAPI
315 CsrSrvAttachSharedSection(
316 IN PCSR_PROCESS CsrProcess OPTIONAL,
317 OUT PCSR_CONNECTION_INFO ConnectInfo
318 );
319
320 VOID
321 NTAPI
322 CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
323
324 BOOLEAN
325 NTAPI
326 CsrNotifyWaitBlock(
327 IN PCSR_WAIT_BLOCK WaitBlock,
328 IN PLIST_ENTRY WaitList,
329 IN PVOID WaitArgument1,
330 IN PVOID WaitArgument2,
331 IN ULONG WaitFlags,
332 IN BOOLEAN DereferenceThread
333 );
334
335 VOID
336 NTAPI
337 CsrDereferenceProcess(PCSR_PROCESS CsrProcess);
338
339 VOID
340 NTAPI
341 CsrInsertProcess(
342 IN PCSR_PROCESS Parent OPTIONAL,
343 IN PCSR_PROCESS CurrentProcess OPTIONAL,
344 IN PCSR_PROCESS CsrProcess
345 );
346
347 NTSTATUS
348 NTAPI
349 CsrPopulateDosDevicesDirectory(
350 IN HANDLE DosDevicesDirectory,
351 IN PPROCESS_DEVICEMAP_INFORMATION DeviceMap
352 );
353
354 BOOLEAN
355 NTAPI
356 CsrValidateMessageBuffer(
357 IN PCSR_API_MESSAGE ApiMessage,
358 IN PVOID *Buffer,
359 IN ULONG ArgumentSize,
360 IN ULONG ArgumentCount
361 );
362
363 NTSTATUS
364 NTAPI
365 CsrCreateLocalSystemSD(OUT PSECURITY_DESCRIPTOR *LocalSystemSd);
366
367 NTSTATUS
368 NTAPI
369 CsrDestroyThread(IN PCLIENT_ID Cid);
370
371 NTSTATUS
372 NTAPI
373 CsrDestroyProcess(
374 IN PCLIENT_ID Cid,
375 IN NTSTATUS ExitStatus
376 );
377
378 LONG
379 NTAPI
380 CsrUnhandledExceptionFilter(
381 IN PEXCEPTION_POINTERS ExceptionInfo
382 );
383
384 VOID
385 NTAPI
386 CsrProcessRefcountZero(IN PCSR_PROCESS CsrProcess);
387
388 VOID
389 NTAPI
390 CsrThreadRefcountZero(IN PCSR_THREAD CsrThread);
391
392 NTSTATUS
393 NTAPI
394 CsrSetDirectorySecurity(IN HANDLE ObjectDirectory);
395 #endif