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