4 #pragma GCC system_header
10 #define SERVICES_ACTIVE_DATABASEA "ServicesActive"
11 #define SERVICES_ACTIVE_DATABASEW L"ServicesActive"
12 #define SERVICES_FAILED_DATABASEA "ServicesFailed"
13 #define SERVICES_FAILED_DATABASEW L"ServicesFailed"
14 #define SC_GROUP_IDENTIFIERA '+'
15 #define SC_GROUP_IDENTIFIERW L'+'
16 #define SC_MANAGER_ALL_ACCESS 0xf003f
17 #define SC_MANAGER_CONNECT 1
18 #define SC_MANAGER_CREATE_SERVICE 2
19 #define SC_MANAGER_ENUMERATE_SERVICE 4
20 #define SC_MANAGER_LOCK 8
21 #define SC_MANAGER_QUERY_LOCK_STATUS 16
22 #define SC_MANAGER_MODIFY_BOOT_CONFIG 32
23 #define SERVICE_NO_CHANGE (-1)
24 #define SERVICE_STOPPED 1
25 #define SERVICE_START_PENDING 2
26 #define SERVICE_STOP_PENDING 3
27 #define SERVICE_RUNNING 4
28 #define SERVICE_CONTINUE_PENDING 5
29 #define SERVICE_PAUSE_PENDING 6
30 #define SERVICE_PAUSED 7
31 #define SERVICE_ACCEPT_STOP 1
32 #define SERVICE_ACCEPT_PAUSE_CONTINUE 2
33 #define SERVICE_ACCEPT_SHUTDOWN 4
34 #define SERVICE_ACCEPT_PARAMCHANGE 8
35 #define SERVICE_ACCEPT_NETBINDCHANGE 16
36 #define SERVICE_ACCEPT_HARDWAREPROFILECHANGE 32
37 #define SERVICE_ACCEPT_POWEREVENT 64
38 #define SERVICE_ACCEPT_SESSIONCHANGE 128
39 #define SERVICE_CONTROL_STOP 1
40 #define SERVICE_CONTROL_PAUSE 2
41 #define SERVICE_CONTROL_CONTINUE 3
42 #define SERVICE_CONTROL_INTERROGATE 4
43 #define SERVICE_CONTROL_SHUTDOWN 5
44 #define SERVICE_CONTROL_PARAMCHANGE 6
45 #define SERVICE_CONTROL_NETBINDADD 7
46 #define SERVICE_CONTROL_NETBINDREMOVE 8
47 #define SERVICE_CONTROL_NETBINDENABLE 9
48 #define SERVICE_CONTROL_NETBINDDISABLE 10
49 #define SERVICE_CONTROL_DEVICEEVENT 11
50 #define SERVICE_CONTROL_HARDWAREPROFILECHANGE 12
51 #define SERVICE_CONTROL_POWEREVENT 13
52 #define SERVICE_CONTROL_SESSIONCHANGE 14
53 #define SERVICE_ACTIVE 1
54 #define SERVICE_INACTIVE 2
55 #define SERVICE_STATE_ALL 3
56 #define SERVICE_QUERY_CONFIG 1
57 #define SERVICE_CHANGE_CONFIG 2
58 #define SERVICE_QUERY_STATUS 4
59 #define SERVICE_ENUMERATE_DEPENDENTS 8
60 #define SERVICE_START 16
61 #define SERVICE_STOP 32
62 #define SERVICE_PAUSE_CONTINUE 64
63 #define SERVICE_INTERROGATE 128
64 #define SERVICE_USER_DEFINED_CONTROL 256
65 #define SERVICE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SERVICE_QUERY_CONFIG|SERVICE_CHANGE_CONFIG|SERVICE_QUERY_STATUS|SERVICE_ENUMERATE_DEPENDENTS|SERVICE_START|SERVICE_STOP|SERVICE_PAUSE_CONTINUE|SERVICE_INTERROGATE|SERVICE_USER_DEFINED_CONTROL)
66 #define SERVICE_RUNS_IN_SYSTEM_PROCESS 1
67 #define SERVICE_CONFIG_DESCRIPTION 1
68 #define SERVICE_CONFIG_FAILURE_ACTIONS 2
70 typedef struct _SERVICE_STATUS
{
73 DWORD dwControlsAccepted
;
74 DWORD dwWin32ExitCode
;
75 DWORD dwServiceSpecificExitCode
;
78 } SERVICE_STATUS
,*LPSERVICE_STATUS
;
79 typedef struct _SERVICE_STATUS_PROCESS
{
82 DWORD dwControlsAccepted
;
83 DWORD dwWin32ExitCode
;
84 DWORD dwServiceSpecificExitCode
;
89 } SERVICE_STATUS_PROCESS
, *LPSERVICE_STATUS_PROCESS
;
90 typedef enum _SC_STATUS_TYPE
{
91 SC_STATUS_PROCESS_INFO
= 0
93 typedef enum _SC_ENUM_TYPE
{
94 SC_ENUM_PROCESS_INFO
= 0
96 typedef struct _ENUM_SERVICE_STATUSA
{
99 SERVICE_STATUS ServiceStatus
;
100 } ENUM_SERVICE_STATUSA
,*LPENUM_SERVICE_STATUSA
;
101 typedef struct _ENUM_SERVICE_STATUSW
{
102 LPWSTR lpServiceName
;
103 LPWSTR lpDisplayName
;
104 SERVICE_STATUS ServiceStatus
;
105 } ENUM_SERVICE_STATUSW
,*LPENUM_SERVICE_STATUSW
;
106 typedef struct _ENUM_SERVICE_STATUS_PROCESSA
{
109 SERVICE_STATUS_PROCESS ServiceStatusProcess
;
110 } ENUM_SERVICE_STATUS_PROCESSA
,*LPENUM_SERVICE_STATUS_PROCESSA
;
111 typedef struct _ENUM_SERVICE_STATUS_PROCESSW
{
112 LPWSTR lpServiceName
;
113 LPWSTR lpDisplayName
;
114 SERVICE_STATUS_PROCESS ServiceStatusProcess
;
115 } ENUM_SERVICE_STATUS_PROCESSW
,*LPENUM_SERVICE_STATUS_PROCESSW
;
116 typedef struct _QUERY_SERVICE_CONFIGA
{
119 DWORD dwErrorControl
;
120 LPSTR lpBinaryPathName
;
121 LPSTR lpLoadOrderGroup
;
123 LPSTR lpDependencies
;
124 LPSTR lpServiceStartName
;
126 } QUERY_SERVICE_CONFIGA
,*LPQUERY_SERVICE_CONFIGA
;
127 typedef struct _QUERY_SERVICE_CONFIGW
{
130 DWORD dwErrorControl
;
131 LPWSTR lpBinaryPathName
;
132 LPWSTR lpLoadOrderGroup
;
134 LPWSTR lpDependencies
;
135 LPWSTR lpServiceStartName
;
136 LPWSTR lpDisplayName
;
137 } QUERY_SERVICE_CONFIGW
,*LPQUERY_SERVICE_CONFIGW
;
138 typedef struct _QUERY_SERVICE_LOCK_STATUSA
{
141 DWORD dwLockDuration
;
142 } QUERY_SERVICE_LOCK_STATUSA
,*LPQUERY_SERVICE_LOCK_STATUSA
;
143 typedef struct _QUERY_SERVICE_LOCK_STATUSW
{
146 DWORD dwLockDuration
;
147 } QUERY_SERVICE_LOCK_STATUSW
,*LPQUERY_SERVICE_LOCK_STATUSW
;
148 typedef void (WINAPI
*LPSERVICE_MAIN_FUNCTIONA
)(DWORD
,LPSTR
*);
149 typedef void (WINAPI
*LPSERVICE_MAIN_FUNCTIONW
)(DWORD
,LPWSTR
*);
150 typedef struct _SERVICE_TABLE_ENTRYA
{
152 LPSERVICE_MAIN_FUNCTIONA lpServiceProc
;
153 } SERVICE_TABLE_ENTRYA
,*LPSERVICE_TABLE_ENTRYA
;
154 typedef struct _SERVICE_TABLE_ENTRYW
{
155 LPWSTR lpServiceName
;
156 LPSERVICE_MAIN_FUNCTIONW lpServiceProc
;
157 } SERVICE_TABLE_ENTRYW
,*LPSERVICE_TABLE_ENTRYW
;
158 DECLARE_HANDLE(SC_HANDLE
);
159 typedef SC_HANDLE
*LPSC_HANDLE
;
160 typedef PVOID SC_LOCK
;
161 typedef DWORD SERVICE_STATUS_HANDLE
;
162 typedef VOID(WINAPI
*LPHANDLER_FUNCTION
)(DWORD
);
163 typedef DWORD (WINAPI
*LPHANDLER_FUNCTION_EX
)(DWORD
,DWORD
,LPVOID
,LPVOID
);
164 typedef struct _SERVICE_DESCRIPTIONA
{
166 } SERVICE_DESCRIPTIONA
,*LPSERVICE_DESCRIPTIONA
;
167 typedef struct _SERVICE_DESCRIPTIONW
{
168 LPWSTR lpDescription
;
169 } SERVICE_DESCRIPTIONW
,*LPSERVICE_DESCRIPTIONW
;
170 typedef enum _SC_ACTION_TYPE
{
172 SC_ACTION_RESTART
= 1,
173 SC_ACTION_REBOOT
= 2,
174 SC_ACTION_RUN_COMMAND
= 3
176 typedef struct _SC_ACTION
{
179 } SC_ACTION
,*LPSC_ACTION
;
180 typedef struct _SERVICE_FAILURE_ACTIONSA
{
185 SC_ACTION
* lpsaActions
;
186 } SERVICE_FAILURE_ACTIONSA
,*LPSERVICE_FAILURE_ACTIONSA
;
187 typedef struct _SERVICE_FAILURE_ACTIONSW
{
192 SC_ACTION
* lpsaActions
;
193 } SERVICE_FAILURE_ACTIONSW
,*LPSERVICE_FAILURE_ACTIONSW
;
195 BOOL WINAPI
ChangeServiceConfigA(SC_HANDLE
,DWORD
,DWORD
,DWORD
,LPCSTR
,LPCSTR
,LPDWORD
,LPCSTR
,LPCSTR
,LPCSTR
,LPCSTR
);
196 BOOL WINAPI
ChangeServiceConfigW(SC_HANDLE
,DWORD
,DWORD
,DWORD
,LPCWSTR
,LPCWSTR
,LPDWORD
,LPCWSTR
,LPCWSTR
,LPCWSTR
,LPCWSTR
);
197 BOOL WINAPI
ChangeServiceConfig2A(SC_HANDLE
,DWORD
,LPVOID
);
198 BOOL WINAPI
ChangeServiceConfig2W(SC_HANDLE
,DWORD
,LPVOID
);
199 BOOL WINAPI
CloseServiceHandle(SC_HANDLE
);
200 BOOL WINAPI
ControlService(SC_HANDLE
,DWORD
,LPSERVICE_STATUS
);
201 SC_HANDLE WINAPI
CreateServiceA(SC_HANDLE
,LPCSTR
,LPCSTR
,DWORD
,DWORD
,DWORD
,DWORD
,LPCSTR
,LPCSTR
,PDWORD
,LPCSTR
,LPCSTR
,LPCSTR
);
202 SC_HANDLE WINAPI
CreateServiceW(SC_HANDLE
,LPCWSTR
,LPCWSTR
,DWORD
,DWORD
,DWORD
,DWORD
,LPCWSTR
,LPCWSTR
,PDWORD
,LPCWSTR
,LPCWSTR
,LPCWSTR
);
203 BOOL WINAPI
DeleteService(SC_HANDLE
);
204 BOOL WINAPI
EnumDependentServicesA(SC_HANDLE
,DWORD
,LPENUM_SERVICE_STATUSA
,DWORD
,PDWORD
,PDWORD
);
205 BOOL WINAPI
EnumDependentServicesW(SC_HANDLE
,DWORD
,LPENUM_SERVICE_STATUSW
,DWORD
,PDWORD
,PDWORD
);
206 BOOL WINAPI
EnumServicesStatusA(SC_HANDLE
,DWORD
,DWORD
,LPENUM_SERVICE_STATUSA
,DWORD
,PDWORD
,PDWORD
,PDWORD
);
207 BOOL WINAPI
EnumServicesStatusW(SC_HANDLE
,DWORD
,DWORD
,LPENUM_SERVICE_STATUSW
,DWORD
,PDWORD
,PDWORD
,PDWORD
);
208 BOOL WINAPI
EnumServicesStatusExA(SC_HANDLE
,SC_ENUM_TYPE
,DWORD
,DWORD
,LPBYTE
,DWORD
,LPDWORD
,LPDWORD
,LPDWORD
,LPCSTR
);
209 BOOL WINAPI
EnumServicesStatusExW(SC_HANDLE
,SC_ENUM_TYPE
,DWORD
,DWORD
,LPBYTE
,DWORD
,LPDWORD
,LPDWORD
,LPDWORD
,LPCWSTR
);
210 BOOL WINAPI
GetServiceDisplayNameA(SC_HANDLE
,LPCSTR
,LPSTR
,PDWORD
);
211 BOOL WINAPI
GetServiceDisplayNameW(SC_HANDLE
,LPCWSTR
,LPWSTR
,PDWORD
);
212 BOOL WINAPI
GetServiceKeyNameA(SC_HANDLE
,LPCSTR
,LPSTR
,PDWORD
);
213 BOOL WINAPI
GetServiceKeyNameW(SC_HANDLE
,LPCWSTR
,LPWSTR
,PDWORD
);
214 SC_LOCK WINAPI
LockServiceDatabase(SC_HANDLE
);
215 BOOL WINAPI
NotifyBootConfigStatus(BOOL
);
216 SC_HANDLE WINAPI
OpenSCManagerA(LPCSTR
,LPCSTR
,DWORD
);
217 SC_HANDLE WINAPI
OpenSCManagerW(LPCWSTR
,LPCWSTR
,DWORD
);
218 SC_HANDLE WINAPI
OpenServiceA(SC_HANDLE
,LPCSTR
,DWORD
);
219 SC_HANDLE WINAPI
OpenServiceW(SC_HANDLE
,LPCWSTR
,DWORD
);
220 BOOL WINAPI
QueryServiceConfigA(SC_HANDLE
,LPQUERY_SERVICE_CONFIGA
,DWORD
,PDWORD
);
221 BOOL WINAPI
QueryServiceConfigW(SC_HANDLE
,LPQUERY_SERVICE_CONFIGW
,DWORD
,PDWORD
);
222 BOOL WINAPI
QueryServiceConfig2A(SC_HANDLE
,DWORD
,LPBYTE
,DWORD
,LPDWORD
);
223 BOOL WINAPI
QueryServiceConfig2W(SC_HANDLE
,DWORD
,LPBYTE
,DWORD
,LPDWORD
);
224 BOOL WINAPI
QueryServiceLockStatusA(SC_HANDLE
,LPQUERY_SERVICE_LOCK_STATUSA
,DWORD
,PDWORD
);
225 BOOL WINAPI
QueryServiceLockStatusW(SC_HANDLE
,LPQUERY_SERVICE_LOCK_STATUSW
,DWORD
,PDWORD
);
226 BOOL WINAPI
QueryServiceObjectSecurity(SC_HANDLE
,SECURITY_INFORMATION
,PSECURITY_DESCRIPTOR
,DWORD
,LPDWORD
);
227 BOOL WINAPI
QueryServiceStatus(SC_HANDLE
,LPSERVICE_STATUS
);
228 BOOL WINAPI
QueryServiceStatusEx(SC_HANDLE
,SC_STATUS_TYPE
,LPBYTE
,DWORD
,LPDWORD
);
229 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerA(LPCSTR
,LPHANDLER_FUNCTION
);
230 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerW(LPCWSTR
,LPHANDLER_FUNCTION
);
231 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerExA(LPCSTR
,LPHANDLER_FUNCTION_EX
,LPVOID
);
232 SERVICE_STATUS_HANDLE WINAPI
RegisterServiceCtrlHandlerExW(LPCWSTR
,LPHANDLER_FUNCTION_EX
,LPVOID
);
233 BOOL WINAPI
SetServiceObjectSecurity(SC_HANDLE
,SECURITY_INFORMATION
,PSECURITY_DESCRIPTOR
);
234 BOOL WINAPI
SetServiceStatus(SERVICE_STATUS_HANDLE
,LPSERVICE_STATUS
);
235 BOOL WINAPI
StartServiceA(SC_HANDLE
,DWORD
,LPCSTR
*);
236 BOOL WINAPI
StartServiceCtrlDispatcherA(LPSERVICE_TABLE_ENTRYA
);
237 BOOL WINAPI
StartServiceCtrlDispatcherW(LPSERVICE_TABLE_ENTRYW
);
238 BOOL WINAPI
StartServiceW(SC_HANDLE
,DWORD
,LPCWSTR
);
239 BOOL WINAPI
UnlockServiceDatabase(SC_LOCK
);
242 typedef ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUS
,*LPENUM_SERVICE_STATUS
;
243 typedef ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESS
;
244 typedef LPENUM_SERVICE_STATUS_PROCESSW LPENUM_SERVICE_STATUS_PROCESS
;
245 typedef QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIG
,*LPQUERY_SERVICE_CONFIG
;
246 typedef QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUS
,*LPQUERY_SERVICE_LOCK_STATUS
;
247 typedef SERVICE_TABLE_ENTRYW SERVICE_TABLE_ENTRY
,*LPSERVICE_TABLE_ENTRY
;
248 typedef LPSERVICE_MAIN_FUNCTIONW LPSERVICE_MAIN_FUNCTION
;
249 typedef SERVICE_DESCRIPTIONW SERVICE_DESCRIPTION
;
250 typedef LPSERVICE_DESCRIPTIONW LPSERVICE_DESCRIPTION
;
251 typedef SERVICE_FAILURE_ACTIONSW SERVICE_FAILURE_ACTIONS
;
252 typedef LPSERVICE_FAILURE_ACTIONSW LPSERVICE_FAILURE_ACTIONS
;
253 #define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEW
254 #define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEW
255 #define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERW
256 #define ChangeServiceConfig ChangeServiceConfigW
257 #define ChangeServiceConfig2 ChangeServiceConfig2W
258 #define CreateService CreateServiceW
259 #define EnumDependentServices EnumDependentServicesW
260 #define EnumServicesStatus EnumServicesStatusW
261 #define EnumServicesStatusEx EnumServicesStatusExW
262 #define GetServiceDisplayName GetServiceDisplayNameW
263 #define GetServiceKeyName GetServiceKeyNameW
264 #define OpenSCManager OpenSCManagerW
265 #define OpenService OpenServiceW
266 #define QueryServiceConfig QueryServiceConfigW
267 #define QueryServiceConfig2 QueryServiceConfig2W
268 #define QueryServiceLockStatus QueryServiceLockStatusW
269 #define RegisterServiceCtrlHandler RegisterServiceCtrlHandlerW
270 #define RegisterServiceCtrlHandlerEx RegisterServiceCtrlHandlerExW
271 #define StartService StartServiceW
272 #define StartServiceCtrlDispatcher StartServiceCtrlDispatcherW
274 typedef ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUS
,*LPENUM_SERVICE_STATUS
;
275 typedef ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESS
;
276 typedef LPENUM_SERVICE_STATUS_PROCESSA LPENUM_SERVICE_STATUS_PROCESS
;
277 typedef QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIG
,*LPQUERY_SERVICE_CONFIG
;
278 typedef QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUS
,*LPQUERY_SERVICE_LOCK_STATUS
;
279 typedef SERVICE_TABLE_ENTRYA SERVICE_TABLE_ENTRY
,*LPSERVICE_TABLE_ENTRY
;
280 typedef LPSERVICE_MAIN_FUNCTIONA LPSERVICE_MAIN_FUNCTION
;
281 typedef SERVICE_DESCRIPTIONA SERVICE_DESCRIPTION
;
282 typedef LPSERVICE_DESCRIPTIONA LPSERVICE_DESCRIPTION
;
283 typedef SERVICE_FAILURE_ACTIONSA SERVICE_FAILURE_ACTIONS
;
284 typedef LPSERVICE_FAILURE_ACTIONSA LPSERVICE_FAILURE_ACTIONS
;
285 #define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEA
286 #define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEA
287 #define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERA
288 #define ChangeServiceConfig ChangeServiceConfigA
289 #define ChangeServiceConfig2 ChangeServiceConfig2A
290 #define CreateService CreateServiceA
291 #define EnumDependentServices EnumDependentServicesA
292 #define EnumServicesStatus EnumServicesStatusA
293 #define EnumServicesStatusEx EnumServicesStatusExA
294 #define GetServiceDisplayName GetServiceDisplayNameA
295 #define GetServiceKeyName GetServiceKeyNameA
296 #define OpenSCManager OpenSCManagerA
297 #define OpenService OpenServiceA
298 #define QueryServiceConfig QueryServiceConfigA
299 #define QueryServiceConfig2 QueryServiceConfig2A
300 #define QueryServiceLockStatus QueryServiceLockStatusA
301 #define RegisterServiceCtrlHandler RegisterServiceCtrlHandlerA
302 #define RegisterServiceCtrlHandlerEx RegisterServiceCtrlHandlerExA
303 #define StartService StartServiceA
304 #define StartServiceCtrlDispatcher StartServiceCtrlDispatcherA
309 #endif /* _WINSVC_H */