xref: /reactos/sdk/include/psdk/winsvc.h (revision c2c66aff)
1 #ifndef _WINSVC_
2 #define _WINSVC_
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 #define SERVICES_ACTIVE_DATABASEA "ServicesActive"
8 #define SERVICES_ACTIVE_DATABASEW L"ServicesActive"
9 #define SERVICES_FAILED_DATABASEA "ServicesFailed"
10 #define SERVICES_FAILED_DATABASEW L"ServicesFailed"
11 #define SC_GROUP_IDENTIFIERA '+'
12 #define SC_GROUP_IDENTIFIERW L'+'
13 #define SC_MANAGER_ALL_ACCESS	0xf003f
14 #define SC_MANAGER_CONNECT	1
15 #define SC_MANAGER_CREATE_SERVICE	2
16 #define SC_MANAGER_ENUMERATE_SERVICE	4
17 #define SC_MANAGER_LOCK	8
18 #define SC_MANAGER_QUERY_LOCK_STATUS	16
19 #define SC_MANAGER_MODIFY_BOOT_CONFIG	32
20 #define SERVICE_NO_CHANGE 0xffffffff
21 #define SERVICE_STOPPED	1
22 #define SERVICE_START_PENDING	2
23 #define SERVICE_STOP_PENDING	3
24 #define SERVICE_RUNNING	4
25 #define SERVICE_CONTINUE_PENDING	5
26 #define SERVICE_PAUSE_PENDING	6
27 #define SERVICE_PAUSED	7
28 #define SERVICE_ACCEPT_STOP	1
29 #define SERVICE_ACCEPT_PAUSE_CONTINUE	2
30 #define SERVICE_ACCEPT_SHUTDOWN 4
31 #define SERVICE_ACCEPT_PARAMCHANGE    8
32 #define SERVICE_ACCEPT_NETBINDCHANGE  16
33 #define SERVICE_ACCEPT_HARDWAREPROFILECHANGE   32
34 #define SERVICE_ACCEPT_POWEREVENT              64
35 #define SERVICE_ACCEPT_SESSIONCHANGE           128
36 #define SERVICE_CONTROL_STOP	1
37 #define SERVICE_CONTROL_PAUSE	2
38 #define SERVICE_CONTROL_CONTINUE	3
39 #define SERVICE_CONTROL_INTERROGATE	4
40 #define SERVICE_CONTROL_SHUTDOWN	5
41 #define SERVICE_CONTROL_PARAMCHANGE     6
42 #define SERVICE_CONTROL_NETBINDADD      7
43 #define SERVICE_CONTROL_NETBINDREMOVE   8
44 #define SERVICE_CONTROL_NETBINDENABLE   9
45 #define SERVICE_CONTROL_NETBINDDISABLE  10
46 #define SERVICE_CONTROL_DEVICEEVENT     11
47 #define SERVICE_CONTROL_HARDWAREPROFILECHANGE 12
48 #define SERVICE_CONTROL_POWEREVENT            13
49 #define SERVICE_CONTROL_SESSIONCHANGE         14
50 #define SERVICE_ACTIVE 1
51 #define SERVICE_INACTIVE 2
52 #define SERVICE_STATE_ALL 3
53 #define SERVICE_QUERY_CONFIG 1
54 #define SERVICE_CHANGE_CONFIG 2
55 #define SERVICE_QUERY_STATUS 4
56 #define SERVICE_ENUMERATE_DEPENDENTS 8
57 #define SERVICE_START 16
58 #define SERVICE_STOP 32
59 #define SERVICE_PAUSE_CONTINUE 64
60 #define SERVICE_INTERROGATE 128
61 #define SERVICE_USER_DEFINED_CONTROL 256
62 #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)
63 #define SERVICE_RUNS_IN_SYSTEM_PROCESS 1
64 
65 #define SERVICE_CONFIG_DESCRIPTION              1
66 #define SERVICE_CONFIG_FAILURE_ACTIONS          2
67 #define SERVICE_CONFIG_DELAYED_AUTO_START_INFO  3
68 #define SERVICE_CONFIG_FAILURE_ACTIONS_FLAG     4
69 #define SERVICE_CONFIG_SERVICE_SID_INFO         5
70 #define SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO 6
71 #define SERVICE_CONFIG_PRESHUTDOWN_INFO         7
72 #define SERVICE_CONFIG_TRIGGER_INFO             8
73 #define SERVICE_CONFIG_PREFERRED_NODE           9
74 #define SERVICE_CONFIG_RUNLEVEL_INFO            10
75 
76 #define SERVICE_NOTIFY_STATUS_CHANGE_1 1
77 #define SERVICE_NOTIFY_STATUS_CHANGE_2 2
78 #define SERVICE_NOTIFY_STATUS_CHANGE   SERVICE_NOTIFY_STATUS_CHANGE_2
79 
80 #define SERVICE_NOTIFY_STOPPED          1
81 #define SERVICE_NOTIFY_START_PENDING    2
82 #define SERVICE_NOTIFY_STOP_PENDING     4
83 #define SERVICE_NOTIFY_RUNNING          8
84 #define SERVICE_NOTIFY_CONTINUE_PENDING 16
85 #define SERVICE_NOTIFY_PAUSE_PENDING    32
86 #define SERVICE_NOTIFY_PAUSED           64
87 #define SERVICE_NOTIFY_CREATED          128
88 #define SERVICE_NOTIFY_DELETED          256
89 #define SERVICE_NOTIFY_DELETE_PENDING   512
90 
91 #ifndef _SERVICE_PRESHUTDOWN_INFO_DEFINED_
92 #define _SERVICE_PRESHUTDOWN_INFO_DEFINED_
93 typedef struct _SERVICE_PRESHUTDOWN_INFO {
94     DWORD dwPreshutdownTimeout;
95 } SERVICE_PRESHUTDOWN_INFO, *LPSERVICE_PRESHUTDOWN_INFO;
96 #endif
97 
98 typedef struct _SERVICE_STATUS {
99 	DWORD dwServiceType;
100 	DWORD dwCurrentState;
101 	DWORD dwControlsAccepted;
102 	DWORD dwWin32ExitCode;
103 	DWORD dwServiceSpecificExitCode;
104 	DWORD dwCheckPoint;
105 	DWORD dwWaitHint;
106 } SERVICE_STATUS,*LPSERVICE_STATUS;
107 typedef struct _SERVICE_STATUS_PROCESS {
108 	DWORD dwServiceType;
109 	DWORD dwCurrentState;
110 	DWORD dwControlsAccepted;
111 	DWORD dwWin32ExitCode;
112 	DWORD dwServiceSpecificExitCode;
113 	DWORD dwCheckPoint;
114 	DWORD dwWaitHint;
115 	DWORD dwProcessId;
116 	DWORD dwServiceFlags;
117 } SERVICE_STATUS_PROCESS, *LPSERVICE_STATUS_PROCESS;
118 typedef enum _SC_STATUS_TYPE {
119 	SC_STATUS_PROCESS_INFO = 0
120 } SC_STATUS_TYPE;
121 typedef enum _SC_ENUM_TYPE {
122         SC_ENUM_PROCESS_INFO = 0
123 } SC_ENUM_TYPE;
124 typedef struct _ENUM_SERVICE_STATUSA {
125 	LPSTR lpServiceName;
126 	LPSTR lpDisplayName;
127 	SERVICE_STATUS ServiceStatus;
128 } ENUM_SERVICE_STATUSA,*LPENUM_SERVICE_STATUSA;
129 typedef struct _ENUM_SERVICE_STATUSW {
130 	LPWSTR lpServiceName;
131 	LPWSTR lpDisplayName;
132 	SERVICE_STATUS ServiceStatus;
133 } ENUM_SERVICE_STATUSW,*LPENUM_SERVICE_STATUSW;
134 typedef struct _ENUM_SERVICE_STATUS_PROCESSA {
135 	LPSTR lpServiceName;
136 	LPSTR lpDisplayName;
137 	SERVICE_STATUS_PROCESS ServiceStatusProcess;
138 } ENUM_SERVICE_STATUS_PROCESSA,*LPENUM_SERVICE_STATUS_PROCESSA;
139 typedef struct _ENUM_SERVICE_STATUS_PROCESSW {
140 	LPWSTR lpServiceName;
141 	LPWSTR lpDisplayName;
142 	SERVICE_STATUS_PROCESS ServiceStatusProcess;
143 } ENUM_SERVICE_STATUS_PROCESSW,*LPENUM_SERVICE_STATUS_PROCESSW;
144 typedef struct _QUERY_SERVICE_CONFIGA {
145 	DWORD dwServiceType;
146 	DWORD dwStartType;
147 	DWORD dwErrorControl;
148 	LPSTR lpBinaryPathName;
149 	LPSTR lpLoadOrderGroup;
150 	DWORD dwTagId;
151 	LPSTR lpDependencies;
152 	LPSTR lpServiceStartName;
153 	LPSTR lpDisplayName;
154 } QUERY_SERVICE_CONFIGA,*LPQUERY_SERVICE_CONFIGA;
155 typedef struct _QUERY_SERVICE_CONFIGW {
156 	DWORD dwServiceType;
157 	DWORD dwStartType;
158 	DWORD dwErrorControl;
159 	LPWSTR lpBinaryPathName;
160 	LPWSTR lpLoadOrderGroup;
161 	DWORD dwTagId;
162 	LPWSTR lpDependencies;
163 	LPWSTR lpServiceStartName;
164 	LPWSTR lpDisplayName;
165 } QUERY_SERVICE_CONFIGW,*LPQUERY_SERVICE_CONFIGW;
166 typedef struct _QUERY_SERVICE_LOCK_STATUSA {
167 	DWORD fIsLocked;
168 	LPSTR lpLockOwner;
169 	DWORD dwLockDuration;
170 } QUERY_SERVICE_LOCK_STATUSA,*LPQUERY_SERVICE_LOCK_STATUSA;
171 typedef struct _QUERY_SERVICE_LOCK_STATUSW {
172 	DWORD fIsLocked;
173 	LPWSTR lpLockOwner;
174 	DWORD dwLockDuration;
175 } QUERY_SERVICE_LOCK_STATUSW,*LPQUERY_SERVICE_LOCK_STATUSW;
176 typedef void (WINAPI *LPSERVICE_MAIN_FUNCTIONA)(DWORD,LPSTR*);
177 typedef void (WINAPI *LPSERVICE_MAIN_FUNCTIONW)(DWORD,LPWSTR*);
178 typedef struct _SERVICE_TABLE_ENTRYA {
179 	LPSTR lpServiceName;
180 	LPSERVICE_MAIN_FUNCTIONA lpServiceProc;
181 } SERVICE_TABLE_ENTRYA,*LPSERVICE_TABLE_ENTRYA;
182 typedef struct _SERVICE_TABLE_ENTRYW {
183 	LPWSTR lpServiceName;
184 	LPSERVICE_MAIN_FUNCTIONW lpServiceProc;
185 } SERVICE_TABLE_ENTRYW,*LPSERVICE_TABLE_ENTRYW;
186 DECLARE_HANDLE(SC_HANDLE);
187 typedef SC_HANDLE *LPSC_HANDLE;
188 typedef PVOID SC_LOCK;
189 DECLARE_HANDLE(SERVICE_STATUS_HANDLE);
190 typedef VOID(WINAPI *LPHANDLER_FUNCTION)(DWORD);
191 typedef DWORD (WINAPI *LPHANDLER_FUNCTION_EX)(DWORD,DWORD,LPVOID,LPVOID);
192 typedef struct _SERVICE_DESCRIPTIONA {
193 	LPSTR lpDescription;
194 } SERVICE_DESCRIPTIONA,*LPSERVICE_DESCRIPTIONA;
195 typedef struct _SERVICE_DESCRIPTIONW {
196 	LPWSTR lpDescription;
197 } SERVICE_DESCRIPTIONW,*LPSERVICE_DESCRIPTIONW;
198 typedef enum _SC_ACTION_TYPE {
199         SC_ACTION_NONE          = 0,
200         SC_ACTION_RESTART       = 1,
201         SC_ACTION_REBOOT        = 2,
202         SC_ACTION_RUN_COMMAND   = 3
203 } SC_ACTION_TYPE;
204 typedef struct _SC_ACTION {
205 	SC_ACTION_TYPE	Type;
206 	DWORD		Delay;
207 } SC_ACTION,*LPSC_ACTION;
208 typedef struct _SERVICE_FAILURE_ACTIONSA {
209 	DWORD	dwResetPeriod;
210 	LPSTR	lpRebootMsg;
211 	LPSTR	lpCommand;
212 	DWORD	cActions;
213 	SC_ACTION * lpsaActions;
214 } SERVICE_FAILURE_ACTIONSA,*LPSERVICE_FAILURE_ACTIONSA;
215 typedef struct _SERVICE_FAILURE_ACTIONSW {
216 	DWORD	dwResetPeriod;
217 	LPWSTR	lpRebootMsg;
218 	LPWSTR	lpCommand;
219 	DWORD	cActions;
220 	SC_ACTION * lpsaActions;
221 } SERVICE_FAILURE_ACTIONSW,*LPSERVICE_FAILURE_ACTIONSW;
222 
223 typedef struct _SERVICE_REQUIRED_PRIVILEGES_INFOA {
224   LPSTR pmszRequiredPrivileges;
225 } SERVICE_REQUIRED_PRIVILEGES_INFOA, *LPSERVICE_REQUIRED_PRIVILEGES_INFOA;
226 
227 typedef struct _SERVICE_REQUIRED_PRIVILEGES_INFOW {
228   LPWSTR pmszRequiredPrivileges;
229 } SERVICE_REQUIRED_PRIVILEGES_INFOW, *LPSERVICE_REQUIRED_PRIVILEGES_INFOW;
230 
231 typedef VOID (CALLBACK *PFN_SC_NOTIFY_CALLBACK)(_In_ PVOID);
232 typedef struct _SERVICE_NOTIFY_1 {
233   DWORD dwVersion;
234   PFN_SC_NOTIFY_CALLBACK pfnNotifyCallback;
235   PVOID pContext;
236   DWORD dwNotificationStatus;
237   SERVICE_STATUS_PROCESS ServiceStatus;
238 } SERVICE_NOTIFY_1, *PSERVICE_NOTIFY_1;
239 typedef struct _SERVICE_NOTIFY_2A {
240   DWORD dwVersion;
241   PFN_SC_NOTIFY_CALLBACK pfnNotifyCallback;
242   PVOID pContext;
243   DWORD dwNotificationStatus;
244   SERVICE_STATUS_PROCESS ServiceStatus;
245   DWORD dwNotificationTriggered;
246   LPSTR pszServiceNames;
247 } SERVICE_NOTIFY_2A, *PSERVICE_NOTIFY_2A;
248 typedef struct _SERVICE_NOTIFY_2W {
249   DWORD dwVersion;
250   PFN_SC_NOTIFY_CALLBACK pfnNotifyCallback;
251   PVOID pContext;
252   DWORD dwNotificationStatus;
253   SERVICE_STATUS_PROCESS ServiceStatus;
254   DWORD dwNotificationTriggered;
255   LPWSTR pszServiceNames;
256 } SERVICE_NOTIFY_2W, *PSERVICE_NOTIFY_2W;
257 typedef SERVICE_NOTIFY_2A SERVICE_NOTIFYA, *PSERVICE_NOTIFYA;
258 typedef SERVICE_NOTIFY_2W SERVICE_NOTIFYW, *PSERVICE_NOTIFYW;
259 
260 BOOL WINAPI ChangeServiceConfigA(_In_ SC_HANDLE, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _Out_opt_ LPDWORD, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR);
261 BOOL WINAPI ChangeServiceConfigW(_In_ SC_HANDLE, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _Out_opt_ LPDWORD, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR);
262 BOOL WINAPI ChangeServiceConfig2A(_In_ SC_HANDLE, _In_ DWORD, _In_opt_ LPVOID);
263 BOOL WINAPI ChangeServiceConfig2W(_In_ SC_HANDLE, _In_ DWORD, _In_opt_ LPVOID);
264 BOOL WINAPI CloseServiceHandle(_In_ SC_HANDLE);
265 BOOL WINAPI ControlService(_In_ SC_HANDLE, _In_ DWORD, _Out_ LPSERVICE_STATUS);
266 _Must_inspect_result_ SC_HANDLE WINAPI CreateServiceA(_In_ SC_HANDLE, _In_ LPCSTR, _In_opt_ LPCSTR, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _Out_opt_ PDWORD, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR);
267 _Must_inspect_result_ SC_HANDLE WINAPI CreateServiceW(_In_ SC_HANDLE, _In_ LPCWSTR, _In_opt_ LPCWSTR, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_ DWORD, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _Out_opt_ PDWORD, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR);
268 BOOL WINAPI DeleteService(_In_ SC_HANDLE);
269 
270 _Must_inspect_result_
271 BOOL
272 WINAPI
273 EnumDependentServicesA(
274   _In_ SC_HANDLE hService,
275   _In_ DWORD dwServiceState,
276   _Out_writes_bytes_opt_(cbBufSize) LPENUM_SERVICE_STATUSA lpServices,
277   _In_ DWORD cbBufSize,
278   _Out_ LPDWORD pcbBytesNeeded,
279   _Out_ LPDWORD lpServicesReturned);
280 
281 _Must_inspect_result_
282 BOOL
283 WINAPI
284 EnumDependentServicesW(
285   _In_ SC_HANDLE hService,
286   _In_ DWORD dwServiceState,
287   _Out_writes_bytes_opt_(cbBufSize) LPENUM_SERVICE_STATUSW lpServices,
288   _In_ DWORD cbBufSize,
289   _Out_ LPDWORD pcbBytesNeeded,
290   _Out_ LPDWORD lpServicesReturned);
291 
292 _Must_inspect_result_
293 BOOL
294 WINAPI
295 EnumServicesStatusA(
296   _In_ SC_HANDLE hSCManager,
297   _In_ DWORD dwServiceType,
298   _In_ DWORD dwServiceState,
299   _Out_writes_bytes_opt_(cbBufSize) LPENUM_SERVICE_STATUSA lpServices,
300   _In_ DWORD cbBufSize,
301   _Out_ LPDWORD pcbBytesNeeded,
302   _Out_ LPDWORD lpServicesReturned,
303   _Inout_opt_ LPDWORD lpResumeHandle);
304 
305 _Must_inspect_result_
306 BOOL
307 WINAPI
308 EnumServicesStatusW(
309   _In_ SC_HANDLE hSCManager,
310   _In_ DWORD dwServiceType,
311   _In_ DWORD dwServiceState,
312   _Out_writes_bytes_opt_(cbBufSize) LPENUM_SERVICE_STATUSW lpServices,
313   _In_ DWORD cbBufSize,
314   _Out_ LPDWORD pcbBytesNeeded,
315   _Out_ LPDWORD lpServicesReturned,
316   _Inout_opt_ LPDWORD lpResumeHandle);
317 
318 _Must_inspect_result_
319 BOOL
320 WINAPI
321 EnumServicesStatusExA(
322   _In_ SC_HANDLE hSCManager,
323   _In_ SC_ENUM_TYPE InfoLevel,
324   _In_ DWORD dwServiceType,
325   _In_ DWORD dwServiceState,
326   _Out_writes_bytes_opt_(cbBufSize) LPBYTE lpServices,
327   _In_ DWORD cbBufSize,
328   _Out_ LPDWORD pcbBytesNeeded,
329   _Out_ LPDWORD lpServicesReturned,
330   _Inout_opt_ LPDWORD lpResumeHandle,
331   _In_opt_ LPCSTR pszGroupName);
332 
333 _Must_inspect_result_
334 BOOL
335 WINAPI
336 EnumServicesStatusExW(
337   _In_ SC_HANDLE hSCManager,
338   _In_ SC_ENUM_TYPE InfoLevel,
339   _In_ DWORD dwServiceType,
340   _In_ DWORD dwServiceState,
341   _Out_writes_bytes_opt_(cbBufSize) LPBYTE lpServices,
342   _In_ DWORD cbBufSize,
343   _Out_ LPDWORD pcbBytesNeeded,
344   _Out_ LPDWORD lpServicesReturned,
345   _Inout_opt_ LPDWORD lpResumeHandle,
346   _In_opt_ LPCWSTR pszGroupName);
347 
348 _Must_inspect_result_
349 BOOL
350 WINAPI
351 GetServiceDisplayNameA(
352   _In_ SC_HANDLE hSCManager,
353   _In_ LPCSTR lpServiceName,
354   _Out_writes_opt_(*lpcchBuffer) LPSTR lpDisplayName,
355   _Inout_ LPDWORD lpcchBuffer);
356 
357 _Must_inspect_result_
358 BOOL
359 WINAPI
360 GetServiceDisplayNameW(
361   _In_ SC_HANDLE hSCManager,
362   _In_ LPCWSTR lpServiceName,
363   _Out_writes_opt_(*lpcchBuffer) LPWSTR lpDisplayName,
364   _Inout_ LPDWORD lpcchBuffer);
365 
366 _Must_inspect_result_
367 BOOL
368 WINAPI
369 GetServiceKeyNameA(
370   _In_ SC_HANDLE hSCManager,
371   _In_ LPCSTR lpDisplayName,
372   _Out_writes_opt_(*lpcchBuffer) LPSTR lpServiceName,
373   _Inout_ LPDWORD lpcchBuffer);
374 
375 _Must_inspect_result_
376 BOOL
377 WINAPI
378 GetServiceKeyNameW(
379   _In_ SC_HANDLE hSCManager,
380   _In_ LPCWSTR lpDisplayName,
381   _Out_writes_opt_(*lpcchBuffer) LPWSTR lpServiceName,
382   _Inout_ LPDWORD lpcchBuffer);
383 
384 SC_LOCK WINAPI LockServiceDatabase(_In_ SC_HANDLE);
385 BOOL WINAPI NotifyBootConfigStatus(_In_ BOOL);
386 _Must_inspect_result_ SC_HANDLE WINAPI OpenSCManagerA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_ DWORD);
387 _Must_inspect_result_ SC_HANDLE WINAPI OpenSCManagerW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ DWORD);
388 _Must_inspect_result_ SC_HANDLE WINAPI OpenServiceA(_In_ SC_HANDLE, _In_ LPCSTR, _In_ DWORD);
389 _Must_inspect_result_ SC_HANDLE WINAPI OpenServiceW(_In_ SC_HANDLE, _In_ LPCWSTR, _In_ DWORD);
390 
391 #if (NTDDI_VERSION >= NTDDI_VISTA)
392 DWORD WINAPI NotifyServiceStatusChangeA(_In_ SC_HANDLE, _In_ DWORD, _In_ PSERVICE_NOTIFYA);
393 DWORD WINAPI NotifyServiceStatusChangeW(_In_ SC_HANDLE, _In_ DWORD, _In_ PSERVICE_NOTIFYW);
394 #endif
395 
396 _Must_inspect_result_
397 BOOL
398 WINAPI
399 QueryServiceConfigA(
400   _In_ SC_HANDLE hService,
401   _Out_writes_bytes_opt_(cbBufSize) LPQUERY_SERVICE_CONFIGA lpServiceConfig,
402   _In_ DWORD cbBufSize,
403   _Out_ LPDWORD pcbBytesNeeded);
404 
405 _Must_inspect_result_
406 BOOL
407 WINAPI
408 QueryServiceConfigW(
409   _In_ SC_HANDLE hService,
410   _Out_writes_bytes_opt_(cbBufSize) LPQUERY_SERVICE_CONFIGW lpServiceConfig,
411   _In_ DWORD cbBufSize,
412   _Out_ LPDWORD pcbBytesNeeded);
413 
414 _When_(dwInfoLevel == SERVICE_CONFIG_DESCRIPTION, _At_(cbBufSize, _In_range_(>=, sizeof(LPSERVICE_DESCRIPTIONA))))
415 _When_(dwInfoLevel == SERVICE_CONFIG_FAILURE_ACTIONS, _At_(cbBufSize, _In_range_(>=, sizeof(LPSERVICE_FAILURE_ACTIONSA))))
416 _When_(dwInfoLevel == SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO, _At_(cbBufSize, _In_range_(>=, sizeof(LPSERVICE_REQUIRED_PRIVILEGES_INFOA))))
417 _Must_inspect_result_
418 BOOL
419 WINAPI
420 QueryServiceConfig2A(
421   _In_ SC_HANDLE hService,
422   _In_ DWORD dwInfoLevel,
423   _Out_writes_bytes_opt_(cbBufSize) LPBYTE lpBuffer,
424   _In_ DWORD cbBufSize,
425   _Out_ LPDWORD pcbBytesNeeded);
426 
427 _When_(dwInfoLevel == SERVICE_CONFIG_DESCRIPTION, _At_(cbBufSize, _In_range_(>=, sizeof(LPSERVICE_DESCRIPTIONW))))
428 _When_(dwInfoLevel == SERVICE_CONFIG_FAILURE_ACTIONS, _At_(cbBufSize, _In_range_(>=, sizeof(LPSERVICE_FAILURE_ACTIONSW))))
429 _When_(dwInfoLevel == SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO, _At_(cbBufSize, _In_range_(>=, sizeof(LPSERVICE_REQUIRED_PRIVILEGES_INFOW))))
430 _Must_inspect_result_
431 BOOL
432 WINAPI
433 QueryServiceConfig2W(
434   _In_ SC_HANDLE hService,
435   _In_ DWORD dwInfoLevel,
436   _Out_writes_bytes_opt_(cbBufSize) LPBYTE lpBuffer,
437   _In_ DWORD cbBufSize,
438   _Out_ LPDWORD pcbBytesNeeded);
439 
440 _Must_inspect_result_
441 BOOL
442 WINAPI
443 QueryServiceLockStatusA(
444   _In_ SC_HANDLE hSCManager,
445   _Out_writes_bytes_opt_(cbBufSize) LPQUERY_SERVICE_LOCK_STATUSA lpLockStatus,
446   _In_ DWORD cbBufSize,
447   _Out_ LPDWORD pcbBytesNeeded);
448 
449 _Must_inspect_result_
450 BOOL
451 WINAPI
452 QueryServiceLockStatusW(
453   _In_ SC_HANDLE hSCManager,
454   _Out_writes_bytes_opt_(cbBufSize) LPQUERY_SERVICE_LOCK_STATUSW lpLockStatus,
455   _In_ DWORD cbBufSize,
456   _Out_ LPDWORD pcbBytesNeeded);
457 
458 _Must_inspect_result_
459 BOOL
460 WINAPI
461 QueryServiceObjectSecurity(
462   _In_ SC_HANDLE hService,
463   _In_ SECURITY_INFORMATION dwSecurityInformation,
464   _Out_writes_bytes_opt_(cbBufSize) PSECURITY_DESCRIPTOR lpSecurityDescriptor,
465   _In_ DWORD cbBufSize,
466   _Out_ LPDWORD pcbBytesNeeded);
467 
468 _Must_inspect_result_ BOOL WINAPI QueryServiceStatus(_In_ SC_HANDLE, _Out_ LPSERVICE_STATUS);
469 
470 _Must_inspect_result_
471 BOOL
472 WINAPI
473 QueryServiceStatusEx(
474   _In_ SC_HANDLE hService,
475   _In_ SC_STATUS_TYPE InfoLevel,
476   _Out_writes_bytes_opt_(cbBufSize) LPBYTE lpBuffer,
477   _In_ DWORD cbBufSize,
478   _Out_ LPDWORD pcbBytesNeeded);
479 
480 _Must_inspect_result_ SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerA(_In_ LPCSTR, _In_ LPHANDLER_FUNCTION);
481 _Must_inspect_result_ SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerW(_In_ LPCWSTR, _In_ LPHANDLER_FUNCTION);
482 _Must_inspect_result_ SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExA(_In_ LPCSTR, _In_ LPHANDLER_FUNCTION_EX, _In_opt_ LPVOID);
483 _Must_inspect_result_ SERVICE_STATUS_HANDLE WINAPI RegisterServiceCtrlHandlerExW(_In_ LPCWSTR, _In_ LPHANDLER_FUNCTION_EX, _In_opt_ LPVOID);
484 BOOL WINAPI SetServiceObjectSecurity(_In_ SC_HANDLE, _In_ SECURITY_INFORMATION, _In_ PSECURITY_DESCRIPTOR);
485 BOOL WINAPI SetServiceStatus(_In_ SERVICE_STATUS_HANDLE, _In_ LPSERVICE_STATUS);
486 
487 BOOL
488 WINAPI
489 StartServiceA(
490   _In_ SC_HANDLE hService,
491   _In_ DWORD dwNumServiceArgs,
492   _In_reads_opt_(dwNumServiceArgs) LPCSTR *lpServiceArgVectors);
493 
494 BOOL
495 WINAPI
496 StartServiceW(
497   _In_ SC_HANDLE hService,
498   _In_ DWORD dwNumServiceArgs,
499   _In_reads_opt_(dwNumServiceArgs) LPCWSTR *lpServiceArgVectors);
500 
501 BOOL WINAPI StartServiceCtrlDispatcherA(_In_ const SERVICE_TABLE_ENTRYA*);
502 BOOL WINAPI StartServiceCtrlDispatcherW(_In_ const SERVICE_TABLE_ENTRYW*);
503 BOOL WINAPI UnlockServiceDatabase(_In_ SC_LOCK);
504 
505 #ifdef UNICODE
506 typedef ENUM_SERVICE_STATUSW ENUM_SERVICE_STATUS,*LPENUM_SERVICE_STATUS;
507 typedef ENUM_SERVICE_STATUS_PROCESSW ENUM_SERVICE_STATUS_PROCESS;
508 typedef LPENUM_SERVICE_STATUS_PROCESSW LPENUM_SERVICE_STATUS_PROCESS;
509 typedef QUERY_SERVICE_CONFIGW QUERY_SERVICE_CONFIG,*LPQUERY_SERVICE_CONFIG;
510 typedef QUERY_SERVICE_LOCK_STATUSW QUERY_SERVICE_LOCK_STATUS,*LPQUERY_SERVICE_LOCK_STATUS;
511 typedef SERVICE_TABLE_ENTRYW SERVICE_TABLE_ENTRY,*LPSERVICE_TABLE_ENTRY;
512 typedef LPSERVICE_MAIN_FUNCTIONW LPSERVICE_MAIN_FUNCTION;
513 typedef SERVICE_DESCRIPTIONW SERVICE_DESCRIPTION;
514 typedef LPSERVICE_DESCRIPTIONW LPSERVICE_DESCRIPTION;
515 typedef SERVICE_FAILURE_ACTIONSW SERVICE_FAILURE_ACTIONS;
516 typedef LPSERVICE_FAILURE_ACTIONSW LPSERVICE_FAILURE_ACTIONS;
517 typedef SERVICE_REQUIRED_PRIVILEGES_INFOW SERVICE_REQUIRED_PRIVILEGES_INFO;
518 typedef LPSERVICE_REQUIRED_PRIVILEGES_INFOW LPSERVICE_REQUIRED_PRIVILEGES_INFO;
519 typedef SERVICE_NOTIFY_2W SERVICE_NOTIFY_2;
520 typedef PSERVICE_NOTIFY_2W PSERVICE_NOTIFY_2;
521 typedef SERVICE_NOTIFYW SERVICE_NOTIFY;
522 typedef PSERVICE_NOTIFYW PSERVICE_NOTIFY;
523 #define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEW
524 #define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEW
525 #define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERW
526 #define ChangeServiceConfig ChangeServiceConfigW
527 #define ChangeServiceConfig2 ChangeServiceConfig2W
528 #define CreateService CreateServiceW
529 #define EnumDependentServices EnumDependentServicesW
530 #define EnumServicesStatus EnumServicesStatusW
531 #define EnumServicesStatusEx  EnumServicesStatusExW
532 #define GetServiceDisplayName GetServiceDisplayNameW
533 #define GetServiceKeyName GetServiceKeyNameW
534 #if (NTDDI_VERSION >= NTDDI_VISTA)
535 #define NotifyServiceStatusChange NotifyServiceStatusChangeW
536 #endif
537 #define OpenSCManager OpenSCManagerW
538 #define OpenService OpenServiceW
539 #define QueryServiceConfig QueryServiceConfigW
540 #define QueryServiceConfig2 QueryServiceConfig2W
541 #define QueryServiceLockStatus QueryServiceLockStatusW
542 #define RegisterServiceCtrlHandler RegisterServiceCtrlHandlerW
543 #define RegisterServiceCtrlHandlerEx RegisterServiceCtrlHandlerExW
544 #define StartService StartServiceW
545 #define StartServiceCtrlDispatcher StartServiceCtrlDispatcherW
546 #else
547 typedef ENUM_SERVICE_STATUSA ENUM_SERVICE_STATUS,*LPENUM_SERVICE_STATUS;
548 typedef ENUM_SERVICE_STATUS_PROCESSA ENUM_SERVICE_STATUS_PROCESS;
549 typedef LPENUM_SERVICE_STATUS_PROCESSA LPENUM_SERVICE_STATUS_PROCESS;
550 typedef QUERY_SERVICE_CONFIGA QUERY_SERVICE_CONFIG,*LPQUERY_SERVICE_CONFIG;
551 typedef QUERY_SERVICE_LOCK_STATUSA QUERY_SERVICE_LOCK_STATUS,*LPQUERY_SERVICE_LOCK_STATUS;
552 typedef SERVICE_TABLE_ENTRYA SERVICE_TABLE_ENTRY,*LPSERVICE_TABLE_ENTRY;
553 typedef LPSERVICE_MAIN_FUNCTIONA LPSERVICE_MAIN_FUNCTION;
554 typedef SERVICE_DESCRIPTIONA SERVICE_DESCRIPTION;
555 typedef LPSERVICE_DESCRIPTIONA LPSERVICE_DESCRIPTION;
556 typedef SERVICE_FAILURE_ACTIONSA SERVICE_FAILURE_ACTIONS;
557 typedef LPSERVICE_FAILURE_ACTIONSA LPSERVICE_FAILURE_ACTIONS;
558 typedef SERVICE_REQUIRED_PRIVILEGES_INFOA SERVICE_REQUIRED_PRIVILEGES_INFO;
559 typedef LPSERVICE_REQUIRED_PRIVILEGES_INFOA LPSERVICE_REQUIRED_PRIVILEGES_INFO;
560 typedef SERVICE_NOTIFY_2A SERVICE_NOTIFY_2;
561 typedef PSERVICE_NOTIFY_2A PSERVICE_NOTIFY_2;
562 typedef SERVICE_NOTIFYA SERVICE_NOTIFY;
563 typedef PSERVICE_NOTIFYA PSERVICE_NOTIFY;
564 #define SERVICES_ACTIVE_DATABASE SERVICES_ACTIVE_DATABASEA
565 #define SERVICES_FAILED_DATABASE SERVICES_FAILED_DATABASEA
566 #define SC_GROUP_IDENTIFIER SC_GROUP_IDENTIFIERA
567 #define ChangeServiceConfig ChangeServiceConfigA
568 #define ChangeServiceConfig2 ChangeServiceConfig2A
569 #define CreateService CreateServiceA
570 #define EnumDependentServices EnumDependentServicesA
571 #define EnumServicesStatus EnumServicesStatusA
572 #define EnumServicesStatusEx  EnumServicesStatusExA
573 #define GetServiceDisplayName GetServiceDisplayNameA
574 #define GetServiceKeyName GetServiceKeyNameA
575 #define OpenSCManager OpenSCManagerA
576 #define OpenService OpenServiceA
577 #if (NTDDI_VERSION >= NTDDI_VISTA)
578 #define NotifyServiceStatusChange NotifyServiceStatusChangeA
579 #endif
580 #define QueryServiceConfig QueryServiceConfigA
581 #define QueryServiceConfig2 QueryServiceConfig2A
582 #define QueryServiceLockStatus QueryServiceLockStatusA
583 #define RegisterServiceCtrlHandler RegisterServiceCtrlHandlerA
584 #define RegisterServiceCtrlHandlerEx RegisterServiceCtrlHandlerExA
585 #define StartService StartServiceA
586 #define StartServiceCtrlDispatcher StartServiceCtrlDispatcherA
587 #endif
588 #ifdef __cplusplus
589 }
590 #endif
591 #endif /* _WINSVC_H */
592