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