xref: /reactos/sdk/include/reactos/svc.h (revision 3d3a5aa0)
1 /*
2  * PROJECT:     ReactOS Service Host
3  * LICENSE:     BSD - See COPYING.ARM in the top level directory
4  * PURPOSE:     Global Header for Service Host
5  * PROGRAMMERS: ReactOS Portable Systems Group
6  *
7  * REFERENCES:
8  * https://www.geoffchappell.com/studies/windows/win32/services/svchost/process/globaldata.htm
9  */
10 
11 #ifndef __SVC_H
12 #define __SVC_H
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 #ifndef __RPC_H__ // For RPC_IF_HANDLE
19 /* Don't include windows.h if we just need rpc.h */
20 #ifndef RPC_NO_WINDOWS_H
21 #define RPC_NO_WINDOWS_H
22 #endif
23 #include <rpc.h>
24 #endif // __RPC_H__
25 
26 #ifndef WINAPI
27 #define WINAPI __stdcall
28 #endif
29 
30 /* Ensure NTSTATUS is defined */
31 #ifndef _NTDEF_
32 typedef _Return_type_success_(return >= 0) LONG NTSTATUS, *PNTSTATUS;
33 #endif
34 
35 
36 /*
37  * Entrypoints for starting and stopping an RPC server.
38  */
39 typedef NTSTATUS
40 (WINAPI *PSTART_RPC_SERVER)(
41     _In_ PCWSTR IfName,
42     _In_ RPC_IF_HANDLE IfSpec);
43 
44 typedef NTSTATUS
45 (WINAPI *PSTOP_RPC_SERVER)(
46     _In_ RPC_IF_HANDLE IfSpec);
47 
48 typedef NTSTATUS
49 (WINAPI *PSTOP_RPC_SERVER_EX)(
50     _In_ RPC_IF_HANDLE IfSpec);
51 
52 /*
53  * Entrypoints for NetBIOS service support.
54  */
55 typedef VOID
56 (WINAPI *PNET_BIOS_OPEN)(VOID);
57 
58 typedef VOID
59 (WINAPI *PNET_BIOS_CLOSE)(VOID);
60 
61 typedef DWORD
62 (WINAPI *PNET_BIOS_RESET)(
63     _In_ UCHAR LanaNum);
64 
65 /*
66  * Callback that a hosted service can register for stop notification.
67  * Alias to (RTL_)WAITORTIMERCALLBACK(FUNC).
68  */
69 /*
70 typedef VOID
71 (CALLBACK *PSVCHOST_STOP_CALLBACK)(
72     _In_ PVOID lpParameter,
73     _In_ BOOLEAN TimerOrWaitFired);
74 */
75 typedef WAITORTIMERCALLBACK PSVCHOST_STOP_CALLBACK;
76 
77 #if (_WIN32_WINNT == _WIN32_WINNT_WINXP && NTDDI_VERSION >= NTDDI_WINXPSP2) || \
78     (NTDDI_VERSION >= NTDDI_WS03SP1)
79 typedef DWORD
80 (WINAPI *PREGISTER_STOP_CALLBACK)(
81     _Out_ PHANDLE phNewWaitObject,
82     _In_ PCWSTR pszServiceName,
83     _In_ HANDLE hObject,
84     _In_ PSVCHOST_STOP_CALLBACK Callback,
85     _In_ PVOID Context,
86     _In_ ULONG dwFlags);
87 #endif
88 
89 /*
90  * Hosted Services and SvcHost use this shared global data structure.
91  */
92 typedef struct _SVCHOST_GLOBAL_DATA
93 {
94     PSID NullSid;
95     PSID WorldSid;
96     PSID LocalSid;
97     PSID NetworkSid;
98     PSID LocalSystemSid;
99     PSID LocalServiceSid;
100     PSID NetworkServiceSid;
101     PSID BuiltinDomainSid;
102     PSID AuthenticatedUserSid;
103     PSID AnonymousLogonSid;
104     PSID AliasAdminsSid;
105     PSID AliasUsersSid;
106     PSID AliasGuestsSid;
107     PSID AliasPowerUsersSid;
108     PSID AliasAccountOpsSid;
109     PSID AliasSystemOpsSid;
110     PSID AliasPrintOpsSid;
111     PSID AliasBackupOpsSid;
112 
113     /* SvcHost callbacks for RPC server and NetBIOS service support */
114     PSTART_RPC_SERVER   StartRpcServer;
115     PSTOP_RPC_SERVER    StopRpcServer;
116     PSTOP_RPC_SERVER_EX StopRpcServerEx;
117     PNET_BIOS_OPEN      NetBiosOpen;
118     PNET_BIOS_CLOSE     NetBiosClose;
119     PNET_BIOS_RESET     NetBiosReset;
120 
121 #if (_WIN32_WINNT == _WIN32_WINNT_WINXP && NTDDI_VERSION >= NTDDI_WINXPSP2) || \
122     (NTDDI_VERSION >= NTDDI_WS03SP1)
123     PREGISTER_STOP_CALLBACK RegisterStopCallback;
124 #endif
125 } SVCHOST_GLOBAL_DATA, *PSVCHOST_GLOBAL_DATA;
126 
127 #ifdef __cplusplus
128 }
129 #endif
130 
131 #endif /* __SVC_H */
132