[CRT] Massively improve performance of rand_s
[reactos.git] / base / services / svchost / svchost.h
1 /*
2 * PROJECT: ReactOS Service Host
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: base/services/svchost/svchost.h
5 * PURPOSE: Precompiled Header for Service Host
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 #ifndef _SVCHOST_PCH_
10 #define _SVCHOST_PCH_
11
12 #define WIN32_NO_STATUS
13 #define WIN32_LEAN_AND_MEAN
14
15 #include <rpc.h>
16 #include <ndk/rtlfuncs.h>
17 #include <ndk/kdtypes.h>
18
19 //
20 // FIXME: Should go in public headers
21 //
22 #define DPFLTR_SVCHOST_ID 28
23
24 //
25 // This prints out a SVCHOST-specific debug print, with the PID/TID
26 //
27 #define SvchostDbgPrint(lev, fmt, ...) \
28 DbgPrintEx(DPFLTR_SVCHOST_ID, \
29 DPFLTR_MASK | lev, \
30 "[SVCHOST] %lx.%lx: " fmt, \
31 GetCurrentProcessId(), \
32 GetCurrentThreadId(), \
33 __VA_ARGS__);
34
35 #define DBG_ERR(fmt, ...) SvchostDbgPrint(1, fmt, __VA_ARGS__)
36 #define DBG_TRACE(fmt, ...) SvchostDbgPrint(4, fmt, __VA_ARGS__)
37
38 //
39 // This is the callback that a hosted service can register for stop notification
40 // FIXME: GLOBAL HEADER
41 //
42 typedef VOID
43 (CALLBACK *PSVCHOST_STOP_CALLBACK) (
44 _In_ PVOID lpParameter,
45 _In_ BOOLEAN TimerOrWaitFired
46 );
47
48 //
49 // Hosted Services and SvcHost Use this Structure
50 // FIXME: GLOBAL HEADER
51 //
52 typedef struct _SVCHOST_GLOBALS
53 {
54 PVOID NullSid;
55 PVOID WorldSid;
56 PVOID LocalSid;
57 PVOID NetworkSid;
58 PVOID LocalSystemSid;
59 PVOID LocalServiceSid;
60 PVOID NetworkServiceSid;
61 PVOID BuiltinDomainSid;
62 PVOID AuthenticatedUserSid;
63 PVOID AnonymousLogonSid;
64 PVOID AliasAdminsSid;
65 PVOID AliasUsersSid;
66 PVOID AliasGuestsSid;
67 PVOID AliasPowerUsersSid;
68 PVOID AliasAccountOpsSid;
69 PVOID AliasSystemOpsSid;
70 PVOID AliasPrintOpsSid;
71 PVOID AliasBackupOpsSid;
72 PVOID RpcpStartRpcServer;
73 PVOID RpcpStopRpcServer;
74 PVOID RpcpStopRpcServerEx;
75 PVOID SvcNetBiosOpen;
76 PVOID SvcNetBiosClose;
77 PVOID SvcNetBiosReset;
78 PVOID SvcRegisterStopCallback;
79 } SVCHOST_GLOBALS, *PSVCHOST_GLOBALS;
80
81 //
82 // This is the callback for them to receive it
83 //
84 typedef VOID
85 (WINAPI *PSVCHOST_INIT_GLOBALS) (
86 _In_ PSVCHOST_GLOBALS Globals
87 );
88 //
89 // Initialization Stages
90 //
91 #define SVCHOST_RPC_INIT_COMPLETE 1
92 #define SVCHOST_NBT_INIT_COMPLETE 2
93 #define SVCHOST_SID_INIT_COMPLETE 4
94
95 //
96 // Domain Alias SID Structure
97 //
98 typedef struct _DOMAIN_SID_DATA
99 {
100 PSID Sid;
101 DWORD SubAuthority;
102 } DOMAIN_SID_DATA;
103
104 //
105 // Well-known SID Structure
106 //
107 typedef struct _SID_DATA
108 {
109 PSID Sid;
110 SID_IDENTIFIER_AUTHORITY Authority;
111 DWORD SubAuthority;
112 } SID_DATA;
113
114 //
115 // This contains all the settings (from the registry) for a hosted service
116 //
117 typedef struct _SVCHOST_OPTIONS
118 {
119 PWCHAR CmdLineBuffer;
120 PWCHAR CmdLine;
121 BOOL HasServiceGroup;
122 LPWSTR ServiceGroupName;
123 DWORD CoInitializeSecurityParam;
124 DWORD AuthenticationLevel;
125 SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
126 DWORD AuthenticationCapabilities;
127 DWORD DefaultRpcStackSize;
128 BOOLEAN SystemCritical;
129 } SVCHOST_OPTIONS, *PSVCHOST_OPTIONS;
130
131 //
132 // This represents the DLL used to hold a hosted service
133 //
134 typedef struct _SVCHOST_DLL
135 {
136 LIST_ENTRY DllList;
137 HINSTANCE hModule;
138 LPCWSTR pszDllPath;
139 LPCWSTR pszManifestPath;
140 HANDLE hActCtx;
141 struct _SVCHOST_SERVICE* pService;
142 } SVCHOST_DLL, *PSVCHOST_DLL;
143
144 //
145 // This represents an actual hosted service
146 //
147 typedef struct _SVCHOST_SERVICE
148 {
149 LPCWSTR pszServiceName;
150 LPCSTR pszServiceMain;
151 LONG cServiceActiveThreadCount;
152 PSVCHOST_DLL pDll;
153 PSVCHOST_STOP_CALLBACK pfnStopCallback;
154 } SVCHOST_SERVICE, *PSVCHOST_SERVICE;
155
156 //
157 // This is the context that a hosted service with a stop callback has
158 //
159 typedef struct _SVCHOST_CALLBACK_CONTEXT
160 {
161 PVOID pContext;
162 PSVCHOST_SERVICE pService;
163 } SVCHOST_CALLBACK_CONTEXT, *PSVCHOST_CALLBACK_CONTEXT;
164
165 NTSTATUS
166 NTAPI
167 RpcpInitRpcServer (
168 VOID
169 );
170
171 NTSTATUS
172 NTAPI
173 RpcpStopRpcServer (
174 _In_ RPC_IF_HANDLE IfSpec
175 );
176
177 NTSTATUS
178 NTAPI
179 RpcpStopRpcServerEx (
180 _In_ RPC_IF_HANDLE IfSpec
181 );
182
183 NTSTATUS
184 NTAPI
185 RpcpStartRpcServer (
186 _In_ LPCWSTR IfName,
187 _In_ RPC_IF_HANDLE IfSpec
188 );
189
190 VOID
191 WINAPI
192 SvchostBuildSharedGlobals (
193 VOID
194 );
195
196 VOID
197 WINAPI
198 SvchostCharLowerW (
199 _In_ LPCWSTR lpSrcStr
200 );
201
202 NTSTATUS
203 NTAPI
204 ScCreateWellKnownSids (
205 VOID
206 );
207
208 VOID
209 WINAPI
210 MemInit (
211 _In_ HANDLE Heap
212 );
213
214 BOOL
215 WINAPI
216 MemFree (
217 _In_ LPVOID lpMem
218 );
219
220 PVOID
221 WINAPI
222 MemAlloc (
223 _In_ DWORD dwFlags,
224 _In_ DWORD dwBytes
225 );
226
227 VOID
228 WINAPI
229 SvcNetBiosInit (
230 VOID
231 );
232
233 VOID
234 WINAPI
235 SvcNetBiosClose (
236 VOID
237 );
238
239 VOID
240 WINAPI
241 SvcNetBiosOpen (
242 VOID
243 );
244
245 DWORD
246 WINAPI
247 SvcNetBiosReset (
248 _In_ UCHAR LanaNum
249 );
250
251 BOOL
252 WINAPI
253 InitializeSecurity (
254 _In_ DWORD dwParam,
255 _In_ DWORD dwAuthnLevel,
256 _In_ DWORD dwImpLevel,
257 _In_ DWORD dwCapabilities
258 );
259
260
261 DWORD
262 WINAPI
263 RegQueryDword (
264 _In_ HKEY hKey,
265 _In_ LPCWSTR pszValueName,
266 _Out_ PDWORD pdwValue
267 );
268
269 DWORD
270 WINAPI
271 RegQueryString (
272 _In_ HKEY hKey,
273 _In_ LPCWSTR pszValueName,
274 _In_ DWORD dwExpectedType,
275 _Out_ PBYTE* ppbData
276 );
277
278 DWORD
279 WINAPI
280 RegQueryStringA (
281 _In_ HKEY hKey,
282 _In_ LPCWSTR pszValueName,
283 _In_ DWORD dwExpectedType,
284 _Out_ LPCSTR* ppszData
285 );
286
287 DWORD
288 WINAPI
289 SvcRegisterStopCallback (
290 _In_ PHANDLE phNewWaitObject,
291 _In_ LPCWSTR ServiceName,
292 _In_ HANDLE hObject,
293 _In_ PSVCHOST_STOP_CALLBACK pfnStopCallback,
294 _In_ PVOID pContext,
295 _In_ ULONG dwFlags
296 );
297
298 extern PSVCHOST_GLOBALS g_pSvchostSharedGlobals;
299
300 #endif /* _SVCHOST_PCH_ */