[NTDLL]
[reactos.git] / subsystems / win32 / csrsrv / include / api.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: subsys/csrss/include/api.h
5 * PURPOSE: CSRSS API interface
6 */
7
8 #pragma once
9
10 #define NTOS_MODE_USER
11 #include <ndk/psfuncs.h>
12 #include <ndk/rtlfuncs.h>
13
14 #include <csr/csrsrv.h>
15
16
17 extern RTL_CRITICAL_SECTION CsrProcessLock, CsrWaitListsLock;
18
19 #define CsrAcquireProcessLock() \
20 RtlEnterCriticalSection(&CsrProcessLock);
21
22 #define CsrReleaseProcessLock() \
23 RtlLeaveCriticalSection(&CsrProcessLock);
24
25 #define ProcessStructureListLocked() \
26 (CsrProcessLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread)
27
28 #define CsrAcquireWaitLock() \
29 RtlEnterCriticalSection(&CsrWaitListsLock);
30
31 #define CsrReleaseWaitLock() \
32 RtlLeaveCriticalSection(&CsrWaitListsLock);
33
34 #define CsrAcquireNtSessionLock() \
35 RtlEnterCriticalSection(&CsrNtSessionLock);
36
37 #define CsrReleaseNtSessionLock() \
38 RtlLeaveCriticalSection(&CsrNtSessionLock);
39
40
41 #define CSR_SERVER_DLL_MAX 4
42
43
44 /***
45 *** Old structure. Deprecated.
46 ***/
47 typedef struct _CSRSS_API_DEFINITION
48 {
49 ULONG ApiID;
50 ULONG MinRequestSize;
51 PCSR_API_ROUTINE Handler;
52 } CSRSS_API_DEFINITION, *PCSRSS_API_DEFINITION;
53
54 #define CSRSS_DEFINE_API(Func, Handler) \
55 { Func, sizeof(CSRSS_##Func), Handler }
56
57
58
59
60 typedef struct _CSRSS_LISTEN_DATA
61 {
62 HANDLE ApiPortHandle;
63 ULONG ApiDefinitionsCount;
64 PCSRSS_API_DEFINITION *ApiDefinitions;
65 } CSRSS_LISTEN_DATA, *PCSRSS_LISTEN_DATA;
66
67
68
69
70 /******************************************************************************
71 ******************************************************************************
72 ******************************************************************************/
73
74
75 extern HANDLE hBootstrapOk;
76 extern HANDLE CsrApiPort;
77 extern HANDLE CsrSmApiPort;
78 extern HANDLE CsrSbApiPort;
79 extern LIST_ENTRY CsrThreadHashTable[256];
80 extern PCSR_PROCESS CsrRootProcess;
81 extern UNICODE_STRING CsrDirectoryName;
82 extern ULONG CsrDebug;
83 extern ULONG CsrTotalPerProcessDataLength;
84 extern SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
85 extern HANDLE CsrHeap;
86 extern PVOID CsrSrvSharedSectionHeap;
87 extern PVOID *CsrSrvSharedStaticServerData;
88 extern HANDLE CsrInitializationEvent;
89 extern PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX];
90 extern ULONG CsrMaxApiRequestThreads;
91
92 /****************************************************/
93 extern UNICODE_STRING CsrSbApiPortName;
94 extern UNICODE_STRING CsrApiPortName;
95 extern RTL_CRITICAL_SECTION CsrProcessLock;
96 extern RTL_CRITICAL_SECTION CsrWaitListsLock;
97 extern HANDLE CsrObjectDirectory;
98 extern PSB_API_ROUTINE CsrServerSbApiDispatch[5];
99 /****************************************************/
100
101
102
103 CSR_API(CsrSrvClientConnect);
104 CSR_API(CsrSrvUnusedFunction);
105 CSR_API(CsrSrvIdentifyAlertableThread);
106 CSR_API(CsrSrvSetPriorityClass);
107 CSR_API(SrvRegisterServicesProcess);
108
109
110 /***
111
112 BOOLEAN
113 NTAPI
114 CsrCaptureArguments(
115 IN PCSR_THREAD CsrThread,
116 IN PCSR_API_MESSAGE ApiMessage
117 );
118
119 VOID
120 NTAPI
121 CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
122
123 NTSTATUS
124 NTAPI
125 CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
126
127 ***/
128
129 NTSTATUS
130 NTAPI
131 CsrLoadServerDll(IN PCHAR DllString,
132 IN PCHAR EntryPoint OPTIONAL,
133 IN ULONG ServerId);
134
135
136 PCSR_THREAD
137 NTAPI
138 CsrAllocateThread(IN PCSR_PROCESS CsrProcess);
139
140 PCSR_PROCESS
141 NTAPI
142 CsrAllocateProcess(VOID);
143
144 VOID
145 NTAPI
146 CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess);
147
148 VOID
149 NTAPI
150 CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
151
152 VOID
153 NTAPI
154 CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
155 IN PCSR_PROCESS CurrentProcess OPTIONAL,
156 IN PCSR_PROCESS CsrProcess);
157
158
159 NTSTATUS FASTCALL CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions);
160 VOID FASTCALL CsrApiCallHandler(IN OUT PCSR_API_MESSAGE ApiMessage, OUT PULONG Reply);
161
162 NTSTATUS
163 NTAPI
164 CsrApiRequestThread(IN PVOID Parameter); // HANDLE ServerPort ??
165
166 VOID
167 NTAPI
168 CsrSbApiRequestThread(IN PVOID Parameter);
169
170 NTSTATUS
171 NTAPI
172 CsrApiPortInitialize(VOID);
173
174 BOOLEAN
175 NTAPI
176 ProtectHandle(IN HANDLE ObjectHandle);
177
178 BOOLEAN
179 NTAPI
180 UnProtectHandle(IN HANDLE ObjectHandle);
181
182 VOID
183 NTAPI
184 CsrInsertThread(IN PCSR_PROCESS Process,
185 IN PCSR_THREAD Thread);
186
187 VOID
188 NTAPI
189 CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess);
190
191 VOID
192 NTAPI
193 CsrLockedReferenceThread(IN PCSR_THREAD CsrThread);
194
195 NTSTATUS
196 NTAPI
197 CsrInitializeProcessStructure(VOID);
198
199 // NTSTATUS WINAPI CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
200 // PVOID Context);
201 PCSR_THREAD
202 NTAPI
203 CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL,
204 IN PCLIENT_ID Cid);
205 PCSR_THREAD
206 NTAPI
207 CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL,
208 IN PCLIENT_ID ClientId);
209
210 // HACK
211 VOID
212 NTAPI
213 CsrProcessRefcountZero(IN PCSR_PROCESS CsrProcess);
214
215 // HACK
216 VOID
217 NTAPI
218 CsrThreadRefcountZero(IN PCSR_THREAD CsrThread);
219
220 NTSTATUS
221 NTAPI
222 CsrInitializeNtSessionList(VOID);
223
224 NTSTATUS
225 NTAPI
226 CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
227 OUT PCSR_CONNECTION_INFO ConnectInfo);
228
229 NTSTATUS
230 NTAPI
231 CsrSrvCreateSharedSection(IN PCHAR ParameterValue);
232
233 VOID
234 NTAPI
235 CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess);
236
237 VOID
238 NTAPI
239 CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread);
240
241 BOOLEAN
242 NTAPI
243 CsrNotifyWaitBlock(IN PCSR_WAIT_BLOCK WaitBlock,
244 IN PLIST_ENTRY WaitList,
245 IN PVOID WaitArgument1,
246 IN PVOID WaitArgument2,
247 IN ULONG WaitFlags,
248 IN BOOLEAN DereferenceThread);
249
250 VOID
251 NTAPI
252 CsrReferenceNtSession(IN PCSR_NT_SESSION Session);
253
254 VOID
255 NTAPI
256 CsrDereferenceNtSession(IN PCSR_NT_SESSION Session,
257 IN NTSTATUS ExitStatus);
258
259 /******************************************************************************
260 ******************************************************************************/
261
262 NTSTATUS
263 NTAPI
264 CsrCreateSessionObjectDirectory(IN ULONG SessionId);
265
266 NTSTATUS
267 NTAPI
268 CsrCreateObjectDirectory(IN PCHAR ObjectDirectory);
269
270 NTSTATUS
271 NTAPI
272 CsrSbApiPortInitialize(VOID);
273
274 BOOLEAN
275 NTAPI
276 CsrSbCreateSession(IN PSB_API_MSG ApiMessage);
277
278 BOOLEAN
279 NTAPI
280 CsrSbTerminateSession(IN PSB_API_MSG ApiMessage);
281
282 BOOLEAN
283 NTAPI
284 CsrSbForeignSessionComplete(IN PSB_API_MSG ApiMessage);
285
286 BOOLEAN
287 NTAPI
288 CsrSbCreateProcess(IN PSB_API_MSG ApiMessage);
289
290 NTSTATUS
291 NTAPI
292 CsrSbApiHandleConnectionRequest(IN PSB_API_MSG Message);
293
294 NTSTATUS
295 NTAPI
296 CsrApiHandleConnectionRequest(IN PCSR_API_MESSAGE ApiMessage);
297
298 /** this API is used with CsrPopulateDosDevices, deprecated in r55585.
299 NTSTATUS
300 NTAPI
301 CsrPopulateDosDevicesDirectory(IN HANDLE DosDevicesDirectory,
302 IN PPROCESS_DEVICEMAP_INFORMATION DeviceMap);
303 **/
304
305 NTSTATUS
306 NTAPI
307 CsrCreateLocalSystemSD(OUT PSECURITY_DESCRIPTOR *LocalSystemSd);
308
309 NTSTATUS
310 NTAPI
311 CsrSetDirectorySecurity(IN HANDLE ObjectDirectory);
312
313 /* EOF */