[CSR]
[reactos.git] / reactos / subsystems / win32 / csrsrv / api.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: subsystems/win32/csrsrv/api.h
5 * PURPOSE: CSRSS Internal API
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 // Debug Flag
45 extern ULONG CsrDebug;
46
47 extern HANDLE hBootstrapOk;
48 extern HANDLE CsrApiPort;
49 extern HANDLE CsrSmApiPort;
50 extern HANDLE CsrSbApiPort;
51 #define NUMBER_THREAD_HASH_BUCKETS 257
52 extern LIST_ENTRY CsrThreadHashTable[NUMBER_THREAD_HASH_BUCKETS];
53 extern PCSR_PROCESS CsrRootProcess;
54 extern UNICODE_STRING CsrDirectoryName;
55 extern ULONG CsrTotalPerProcessDataLength;
56 extern SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
57 extern HANDLE CsrHeap;
58 extern PVOID CsrSrvSharedSectionHeap;
59 extern PVOID *CsrSrvSharedStaticServerData;
60 extern HANDLE CsrInitializationEvent;
61 extern PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX];
62 extern ULONG CsrMaxApiRequestThreads;
63
64 /****************************************************/
65 extern UNICODE_STRING CsrSbApiPortName;
66 extern UNICODE_STRING CsrApiPortName;
67 extern RTL_CRITICAL_SECTION CsrProcessLock;
68 extern RTL_CRITICAL_SECTION CsrWaitListsLock;
69 extern HANDLE CsrObjectDirectory;
70 /****************************************************/
71
72
73
74 CSR_API(CsrSrvClientConnect);
75 CSR_API(CsrSrvUnusedFunction);
76 CSR_API(CsrSrvIdentifyAlertableThread);
77 CSR_API(CsrSrvSetPriorityClass);
78
79
80 NTSTATUS
81 NTAPI
82 CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll);
83
84
85 BOOLEAN
86 NTAPI
87 CsrCaptureArguments(IN PCSR_THREAD CsrThread,
88 IN PCSR_API_MESSAGE ApiMessage);
89
90 VOID
91 NTAPI
92 CsrReleaseCapturedArguments(IN PCSR_API_MESSAGE ApiMessage);
93
94 NTSTATUS
95 NTAPI
96 CsrLoadServerDll(IN PCHAR DllString,
97 IN PCHAR EntryPoint OPTIONAL,
98 IN ULONG ServerId);
99
100
101 PCSR_THREAD
102 NTAPI
103 CsrAllocateThread(IN PCSR_PROCESS CsrProcess);
104
105 PCSR_PROCESS
106 NTAPI
107 CsrAllocateProcess(VOID);
108
109 VOID
110 NTAPI
111 CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess);
112
113 VOID
114 NTAPI
115 CsrInsertProcess(IN PCSR_PROCESS ParentProcess OPTIONAL,
116 IN PCSR_PROCESS CsrProcess);
117
118 VOID
119 NTAPI
120 CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
121
122 NTSTATUS
123 NTAPI
124 CsrApiRequestThread(IN PVOID Parameter);
125
126 VOID
127 NTAPI
128 CsrSbApiRequestThread(IN PVOID Parameter);
129
130 NTSTATUS
131 NTAPI
132 CsrApiPortInitialize(VOID);
133
134 BOOLEAN
135 NTAPI
136 ProtectHandle(IN HANDLE ObjectHandle);
137
138 BOOLEAN
139 NTAPI
140 UnProtectHandle(IN HANDLE ObjectHandle);
141
142 NTSTATUS
143 NTAPI
144 CsrInsertThread(IN PCSR_PROCESS Process,
145 IN PCSR_THREAD Thread);
146
147 VOID
148 NTAPI
149 CsrDeallocateThread(IN PCSR_THREAD CsrThread);
150
151 VOID
152 NTAPI
153 CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess);
154
155 VOID
156 NTAPI
157 CsrLockedReferenceThread(IN PCSR_THREAD CsrThread);
158
159 NTSTATUS
160 NTAPI
161 CsrInitializeProcessStructure(VOID);
162
163 // NTSTATUS WINAPI CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
164 // PVOID Context);
165 PCSR_THREAD
166 NTAPI
167 CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL,
168 IN PCLIENT_ID Cid);
169 PCSR_THREAD
170 NTAPI
171 CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL,
172 IN PCLIENT_ID ClientId);
173
174 NTSTATUS
175 NTAPI
176 CsrInitializeNtSessionList(VOID);
177
178 NTSTATUS
179 NTAPI
180 CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
181 OUT PCSR_API_CONNECTINFO ConnectInfo);
182
183 NTSTATUS
184 NTAPI
185 CsrSrvCreateSharedSection(IN PCHAR ParameterValue);
186
187 VOID
188 NTAPI
189 CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess);
190
191 VOID
192 NTAPI
193 CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread);
194
195 BOOLEAN
196 NTAPI
197 CsrNotifyWaitBlock(IN PCSR_WAIT_BLOCK WaitBlock,
198 IN PLIST_ENTRY WaitList,
199 IN PVOID WaitArgument1,
200 IN PVOID WaitArgument2,
201 IN ULONG WaitFlags,
202 IN BOOLEAN DereferenceThread);
203
204 VOID
205 NTAPI
206 CsrReferenceNtSession(IN PCSR_NT_SESSION Session);
207
208 VOID
209 NTAPI
210 CsrDereferenceNtSession(IN PCSR_NT_SESSION Session,
211 IN NTSTATUS ExitStatus);
212
213 /******************************************************************************
214 ******************************************************************************/
215
216 NTSTATUS
217 NTAPI
218 CsrCreateSessionObjectDirectory(IN ULONG SessionId);
219
220 NTSTATUS
221 NTAPI
222 CsrCreateObjectDirectory(IN PCHAR ObjectDirectory);
223
224 NTSTATUS
225 NTAPI
226 CsrSbApiPortInitialize(VOID);
227
228 BOOLEAN
229 NTAPI
230 CsrSbCreateSession(IN PSB_API_MSG ApiMessage);
231
232 BOOLEAN
233 NTAPI
234 CsrSbTerminateSession(IN PSB_API_MSG ApiMessage);
235
236 BOOLEAN
237 NTAPI
238 CsrSbForeignSessionComplete(IN PSB_API_MSG ApiMessage);
239
240 BOOLEAN
241 NTAPI
242 CsrSbCreateProcess(IN PSB_API_MSG ApiMessage);
243
244 NTSTATUS
245 NTAPI
246 CsrSbApiHandleConnectionRequest(IN PSB_API_MSG Message);
247
248 NTSTATUS
249 NTAPI
250 CsrApiHandleConnectionRequest(IN PCSR_API_MESSAGE ApiMessage);
251
252 /** this API is used with CsrPopulateDosDevices, deprecated in r55585.
253 NTSTATUS
254 NTAPI
255 CsrPopulateDosDevicesDirectory(IN HANDLE DosDevicesDirectory,
256 IN PPROCESS_DEVICEMAP_INFORMATION DeviceMap);
257 **/
258
259 NTSTATUS
260 NTAPI
261 CsrCreateLocalSystemSD(OUT PSECURITY_DESCRIPTOR *LocalSystemSd);
262
263 NTSTATUS
264 NTAPI
265 CsrSetDirectorySecurity(IN HANDLE ObjectDirectory);
266
267 /* EOF */