xref: /reactos/base/services/svchost/svchost.h (revision bbccad0e)
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 #define NTOS_MODE_USER
16 #include <ndk/rtlfuncs.h>
17 #include <ndk/kdtypes.h>
18 #include <dpfilter.h>
19 
20 #include <rpc.h>
21 #include <svc.h>
22 
23 //
24 // This prints out a SVCHOST-specific debug print, with the PID/TID
25 //
26 #define SvchostDbgPrint(lev, fmt, ...)              \
27     DbgPrintEx(DPFLTR_SVCHOST_ID,                   \
28                DPFLTR_MASK | lev,                   \
29                "[SVCHOST] %lx.%lx: " fmt,           \
30                GetCurrentProcessId(),               \
31                GetCurrentThreadId(),                \
32                __VA_ARGS__);
33 
34 #define DBG_ERR(fmt, ...)   SvchostDbgPrint(1, fmt, __VA_ARGS__)
35 #define DBG_TRACE(fmt, ...) SvchostDbgPrint(4, fmt, __VA_ARGS__)
36 
37 //
38 // This is the callback for them to receive it
39 //
40 typedef VOID
41 (WINAPI *PSVCHOST_INIT_GLOBALS) (
42     _In_ PSVCHOST_GLOBAL_DATA Globals
43 );
44 
45 //
46 // Initialization Stages
47 //
48 #define SVCHOST_RPC_INIT_COMPLETE   1
49 #define SVCHOST_NBT_INIT_COMPLETE   2
50 #define SVCHOST_SID_INIT_COMPLETE   4
51 
52 //
53 // Domain Alias SID Structure
54 //
55 typedef struct _DOMAIN_SID_DATA
56 {
57     PSID* Sid;
58     DWORD SubAuthority;
59 } DOMAIN_SID_DATA;
60 
61 //
62 // Well-known SID Structure
63 //
64 typedef struct _SID_DATA
65 {
66     PSID* Sid;
67     SID_IDENTIFIER_AUTHORITY Authority;
68     DWORD SubAuthority;
69 } SID_DATA;
70 
71 //
72 // This contains all the settings (from the registry) for a hosted service
73 //
74 typedef struct _SVCHOST_OPTIONS
75 {
76     PWCHAR CmdLineBuffer;
77     PWCHAR CmdLine;
78     BOOL HasServiceGroup;
79     LPWSTR ServiceGroupName;
80     DWORD CoInitializeSecurityParam;
81     DWORD AuthenticationLevel;
82     SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;
83     DWORD AuthenticationCapabilities;
84     DWORD DefaultRpcStackSize;
85     BOOLEAN SystemCritical;
86 } SVCHOST_OPTIONS, *PSVCHOST_OPTIONS;
87 
88 //
89 // This represents the DLL used to hold a hosted service
90 //
91 typedef struct _SVCHOST_DLL
92 {
93     LIST_ENTRY DllList;
94     HINSTANCE hModule;
95     LPCWSTR pszDllPath;
96     LPCWSTR pszManifestPath;
97     HANDLE hActCtx;
98     struct _SVCHOST_SERVICE* pService;
99 } SVCHOST_DLL, *PSVCHOST_DLL;
100 
101 //
102 // This represents an actual hosted service
103 //
104 typedef struct _SVCHOST_SERVICE
105 {
106     LPCWSTR pszServiceName;
107     LPCSTR pszServiceMain;
108     LONG cServiceActiveThreadCount;
109     PSVCHOST_DLL pDll;
110     PSVCHOST_STOP_CALLBACK pfnStopCallback;
111 } SVCHOST_SERVICE, *PSVCHOST_SERVICE;
112 
113 //
114 // This is the context that a hosted service with a stop callback has
115 //
116 typedef struct _SVCHOST_CALLBACK_CONTEXT
117 {
118     PVOID pContext;
119     PSVCHOST_SERVICE pService;
120 } SVCHOST_CALLBACK_CONTEXT, *PSVCHOST_CALLBACK_CONTEXT;
121 
122 NTSTATUS
123 NTAPI
124 RpcpInitRpcServer (
125     VOID
126 );
127 
128 NTSTATUS
129 NTAPI
130 RpcpStopRpcServer (
131     _In_ RPC_IF_HANDLE IfSpec
132 );
133 
134 NTSTATUS
135 NTAPI
136 RpcpStopRpcServerEx (
137     _In_ RPC_IF_HANDLE IfSpec
138 );
139 
140 NTSTATUS
141 NTAPI
142 RpcpStartRpcServer (
143     _In_ PCWSTR IfName,
144     _In_ RPC_IF_HANDLE IfSpec
145 );
146 
147 VOID
148 WINAPI
149 SvchostBuildSharedGlobals (
150     VOID
151 );
152 
153 VOID
154 WINAPI
155 SvchostCharLowerW (
156     _In_ LPCWSTR lpSrcStr
157 );
158 
159 NTSTATUS
160 NTAPI
161 ScCreateWellKnownSids (
162     VOID
163 );
164 
165 VOID
166 WINAPI
167 MemInit (
168     _In_ HANDLE Heap
169 );
170 
171 BOOL
172 WINAPI
173 MemFree (
174     _In_ LPVOID lpMem
175 );
176 
177 PVOID
178 WINAPI
179 MemAlloc (
180     _In_ DWORD dwFlags,
181     _In_ DWORD dwBytes
182 );
183 
184 VOID
185 WINAPI
186 SvcNetBiosInit (
187     VOID
188 );
189 
190 VOID
191 WINAPI
192 SvcNetBiosClose (
193     VOID
194 );
195 
196 VOID
197 WINAPI
198 SvcNetBiosOpen (
199     VOID
200 );
201 
202 DWORD
203 WINAPI
204 SvcNetBiosReset (
205     _In_ UCHAR LanaNum
206 );
207 
208 BOOL
209 WINAPI
210 InitializeSecurity (
211     _In_ DWORD dwParam,
212     _In_ DWORD dwAuthnLevel,
213     _In_ DWORD dwImpLevel,
214     _In_ DWORD dwCapabilities
215 );
216 
217 
218 DWORD
219 WINAPI
220 RegQueryDword (
221     _In_ HKEY hKey,
222     _In_ LPCWSTR pszValueName,
223     _Out_ PDWORD pdwValue
224 );
225 
226 DWORD
227 WINAPI
228 RegQueryString (
229     _In_ HKEY hKey,
230     _In_ LPCWSTR pszValueName,
231     _In_ DWORD dwExpectedType,
232     _Out_ PBYTE* ppbData
233 );
234 
235 DWORD
236 WINAPI
237 RegQueryStringA (
238     _In_ HKEY hKey,
239     _In_ LPCWSTR pszValueName,
240     _In_ DWORD dwExpectedType,
241     _Out_ LPCSTR* ppszData
242 );
243 
244 DWORD
245 WINAPI
246 SvcRegisterStopCallback (
247     _Out_ PHANDLE phNewWaitObject,
248     _In_ PCWSTR ServiceName,
249     _In_ HANDLE hObject,
250     _In_ PSVCHOST_STOP_CALLBACK pfnStopCallback,
251     _In_ PVOID pContext,
252     _In_ ULONG dwFlags
253 );
254 
255 extern PSVCHOST_GLOBAL_DATA g_pSvchostSharedGlobals;
256 
257 #endif /* _SVCHOST_PCH_ */
258