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