a621d9cad363922cd8c8b198c0062da27ecc913b
[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 <csrss/server.h>
15
16
17 #define CsrAcquireProcessLock() \
18 RtlEnterCriticalSection(&CsrProcessLock);
19
20 #define CsrReleaseProcessLock() \
21 RtlLeaveCriticalSection(&CsrProcessLock);
22
23 #define ProcessStructureListLocked() \
24 (CsrProcessLock.OwningThread == NtCurrentTeb()->ClientId.UniqueThread)
25
26 #define CsrAcquireWaitLock() \
27 RtlEnterCriticalSection(&CsrWaitListsLock);
28
29 #define CsrReleaseWaitLock() \
30 RtlLeaveCriticalSection(&CsrWaitListsLock);
31
32 #define CsrAcquireNtSessionLock() \
33 RtlEnterCriticalSection(&CsrNtSessionLock);
34
35 #define CsrReleaseNtSessionLock() \
36 RtlLeaveCriticalSection(&CsrNtSessionLock);
37
38
39
40 typedef struct _CSRSS_API_DEFINITION
41 {
42 ULONG ApiID;
43 ULONG MinRequestSize;
44 PCSR_API_ROUTINE Handler;
45 } CSRSS_API_DEFINITION, *PCSRSS_API_DEFINITION;
46
47 #define CSRSS_DEFINE_API(Func, Handler) \
48 { Func, sizeof(CSRSS_##Func), Handler }
49
50
51
52 typedef struct _CSRSS_LISTEN_DATA
53 {
54 HANDLE ApiPortHandle;
55 ULONG ApiDefinitionsCount;
56 PCSRSS_API_DEFINITION *ApiDefinitions;
57 } CSRSS_LISTEN_DATA, *PCSRSS_LISTEN_DATA;
58
59
60
61
62 /******************************************************************************
63 ******************************************************************************
64 ******************************************************************************/
65
66
67
68 /* init.c */
69 extern HANDLE hBootstrapOk;
70 NTSTATUS NTAPI CsrServerInitialization(ULONG ArgumentCount, PCHAR Arguments[]);
71
72 /* api/process.c */
73 CSR_API(CsrConnectProcess);
74 CSR_API(BaseSrvCreateProcess);
75 CSR_API(BaseSrvExitProcess);
76 CSR_API(BaseSrvCreateThread);
77 CSR_API(BaseSrvGetProcessShutdownParam);
78 CSR_API(BaseSrvSetProcessShutdownParam);
79
80 VOID
81 NTAPI
82 CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess);
83
84 PCSR_THREAD
85 NTAPI
86 CsrAllocateThread(IN PCSR_PROCESS CsrProcess);
87
88 PCSR_PROCESS
89 NTAPI
90 CsrAllocateProcess(VOID);
91
92 VOID
93 NTAPI
94 CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess);
95
96 VOID
97 NTAPI
98 CsrRemoveProcess(IN PCSR_PROCESS CsrProcess);
99
100 VOID
101 NTAPI
102 CsrDereferenceThread(IN PCSR_THREAD CsrThread);
103
104 VOID
105 NTAPI
106 CsrInsertProcess(IN PCSR_PROCESS Parent OPTIONAL,
107 IN PCSR_PROCESS CurrentProcess OPTIONAL,
108 IN PCSR_PROCESS CsrProcess);
109
110
111 /* api/wapi.c */
112 NTSTATUS FASTCALL CsrApiRegisterDefinitions(PCSRSS_API_DEFINITION NewDefinitions);
113 VOID FASTCALL CsrApiCallHandler(IN OUT PCSR_API_MESSAGE ApiMessage, OUT PULONG Reply);
114 VOID WINAPI CsrSbApiRequestThread (PVOID PortHandle);
115 VOID NTAPI ClientConnectionThread(HANDLE ServerPort);
116
117 extern HANDLE CsrApiPort;
118 extern HANDLE CsrSmApiPort;
119 extern HANDLE CsrSbApiPort;
120 extern LIST_ENTRY CsrThreadHashTable[256];
121 extern PCSR_PROCESS CsrRootProcess;
122 extern RTL_CRITICAL_SECTION CsrProcessLock, CsrWaitListsLock;
123 extern UNICODE_STRING CsrDirectoryName;
124 extern ULONG CsrDebug;
125 extern ULONG CsrTotalPerProcessDataLength;
126 extern SYSTEM_BASIC_INFORMATION CsrNtSysInfo;
127 extern PVOID CsrSrvSharedSectionHeap;
128 extern PVOID *CsrSrvSharedStaticServerData;
129 extern HANDLE CsrInitializationEvent;
130 extern PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX];
131 extern ULONG CsrMaxApiRequestThreads;
132
133 NTSTATUS
134 NTAPI
135 CsrApiPortInitialize(VOID);
136
137 NTSTATUS
138 NTAPI
139 CsrCreateProcess(IN HANDLE hProcess,
140 IN HANDLE hThread,
141 IN PCLIENT_ID ClientId,
142 IN PCSR_NT_SESSION NtSession,
143 IN ULONG Flags,
144 IN PCLIENT_ID DebugCid);
145
146 BOOLEAN
147 NTAPI
148 ProtectHandle(IN HANDLE ObjectHandle);
149
150 VOID
151 NTAPI
152 CsrInsertThread(IN PCSR_PROCESS Process,
153 IN PCSR_THREAD Thread);
154
155 VOID
156 NTAPI
157 CsrLockedReferenceThread(IN PCSR_THREAD CsrThread);
158
159 /* api/process.c */
160 typedef NTSTATUS (WINAPI *CSRSS_ENUM_PROCESS_PROC)(PCSR_PROCESS ProcessData,
161 PVOID Context);
162 NTSTATUS WINAPI CsrInitializeProcessStructure(VOID);
163
164 NTSTATUS WINAPI CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc, PVOID Context);
165 PCSR_THREAD NTAPI CsrAddStaticServerThread(IN HANDLE hThread, IN PCLIENT_ID ClientId, IN ULONG ThreadFlags);
166 PCSR_THREAD NTAPI CsrLocateThreadInProcess(IN PCSR_PROCESS CsrProcess OPTIONAL, IN PCLIENT_ID Cid);
167 PCSR_THREAD NTAPI CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL, IN PCLIENT_ID ClientId);
168 NTSTATUS NTAPI CsrLockProcessByClientId(IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess OPTIONAL);
169 NTSTATUS NTAPI CsrCreateThread(IN PCSR_PROCESS CsrProcess, IN HANDLE hThread, IN PCLIENT_ID ClientId);
170 NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess);
171
172 //hack
173 VOID NTAPI CsrThreadRefcountZero(IN PCSR_THREAD CsrThread);
174
175 NTSTATUS
176 NTAPI
177 CsrInitializeNtSessionList(VOID);
178
179 NTSTATUS
180 NTAPI
181 CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
182 OUT PCSR_CONNECTION_INFO ConnectInfo);
183
184 NTSTATUS
185 NTAPI
186 CsrSrvCreateSharedSection(IN PCHAR ParameterValue);
187
188 NTSTATUS
189 NTAPI
190 CsrSrvClientConnect(
191 IN OUT PCSR_API_MESSAGE ApiMessage,
192 IN OUT PULONG Reply
193 );
194
195 NTSTATUS
196 NTAPI
197 CsrSrvUnusedFunction(
198 IN OUT PCSR_API_MESSAGE ApiMessage,
199 IN OUT PULONG Reply
200 );
201
202 NTSTATUS
203 NTAPI
204 CsrSrvIdentifyAlertableThread(
205 IN OUT PCSR_API_MESSAGE ApiMessage,
206 IN OUT PULONG Reply
207 );
208
209 NTSTATUS
210 NTAPI
211 CsrSrvSetPriorityClass(
212 IN OUT PCSR_API_MESSAGE ApiMessage,
213 IN OUT PULONG Reply
214 );
215
216 NTSTATUS
217 NTAPI
218 CsrDestroyProcess(IN PCLIENT_ID Cid,
219 IN NTSTATUS ExitStatus);
220
221 NTSTATUS
222 NTAPI
223 CsrDestroyThread(IN PCLIENT_ID Cid);
224
225 VOID
226 NTAPI
227 CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread);
228
229 BOOLEAN
230 NTAPI
231 CsrNotifyWaitBlock(IN PCSR_WAIT_BLOCK WaitBlock,
232 IN PLIST_ENTRY WaitList,
233 IN PVOID WaitArgument1,
234 IN PVOID WaitArgument2,
235 IN ULONG WaitFlags,
236 IN BOOLEAN DereferenceThread);
237
238 VOID
239 NTAPI
240 CsrReferenceNtSession(IN PCSR_NT_SESSION Session);
241
242 LONG
243 NTAPI
244 CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo);
245
246 VOID
247 NTAPI
248 CsrDereferenceNtSession(IN PCSR_NT_SESSION Session,
249 IN NTSTATUS ExitStatus);
250
251 VOID
252 NTAPI
253 CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess);
254
255 VOID
256 NTAPI
257 CsrDereferenceProcess(IN PCSR_PROCESS CsrProcess);
258
259 NTSTATUS
260 NTAPI
261 CsrLoadServerDll(IN PCHAR DllString,
262 IN PCHAR EntryPoint OPTIONAL,
263 IN ULONG ServerId);
264
265 /* api/user.c */
266 CSR_API(SrvRegisterServicesProcess);
267
268 /* EOF */