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