2 * svcctl interface definitions - exported by services.exe to access the
5 * Copyright 2007 Google (Mikolaj Zalewski)
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 * some defined for the C code
27 cpp_quote
("#include \"winsvc.h\"")
28 cpp_quote
("#define SVCCTL_TRANSPORT {'n','c','a','c','n','_','n','p',0}")
29 cpp_quote
("#define SVCCTL_ENDPOINT {'\\\\','p','i','p','e','\\\\','s','v','c','c','t','l',0}")
31 /* Not the Windows event name - if needed the true one can be found in Inside Windows */
32 cpp_quote
("#define SVCCTL_STARTED_EVENT {'_','_','w','i','n','e','_','S','v','c','c','t','l','S','t','a','r','t','e','d',0}")
34 /* Service startup protocol over control pipe - not compatible with Windows */
35 enum service_pipe_command
37 WINESERV_STARTINFO
= 1,
38 WINESERV_SENDCONTROL
= 2
41 typedef struct service_start_info_t
43 enum service_pipe_command cmd
; /* request code */
44 DWORD total_size
; /* total request size */
45 DWORD name_size
; /* size of name in data buffer */
46 DWORD
control; /* control code */
51 uuid(367abb81
-9844-35f1
-ad32
-98f038001003
),
53 pointer_default(unique),
54 endpoint("ncacn_np:[\\pipe\\svcctl]")
59 typedef [handle] LPCWSTR MACHINE_HANDLEW
;
60 typedef [context_handle] void *SC_RPC_HANDLE
;
61 typedef [context_handle] void *SC_RPC_LOCK
;
63 /* undocumented access rights */
64 cpp_quote
("#define SERVICE_SET_STATUS 0x8000")
66 cpp_quote
("#if 0 /* already defined in winsvc.h */")
67 typedef struct _QUERY_SERVICE_CONFIGW
{
71 [unique] LPWSTR lpBinaryPathName
;
72 [unique] LPWSTR lpLoadOrderGroup
;
74 [unique] LPWSTR lpDependencies
;
75 [unique] LPWSTR lpServiceStartName
;
76 [unique] LPWSTR lpDisplayName
;
77 } QUERY_SERVICE_CONFIGW
, *LPQUERY_SERVICE_CONFIGW
;
79 typedef struct _SERVICE_STATUS
{
82 DWORD dwControlsAccepted
;
83 DWORD dwWin32ExitCode
;
84 DWORD dwServiceSpecificExitCode
;
87 } SERVICE_STATUS
, *LPSERVICE_STATUS
;
89 typedef enum _SC_STATUS_TYPE
{
90 SC_STATUS_PROCESS_INFO
= 0
93 typedef struct _SERVICE_DESCRIPTIONW
{
95 } SERVICE_DESCRIPTIONW
,*LPSERVICE_DESCRIPTIONW
;
97 typedef enum _SC_ACTION_TYPE
{
99 SC_ACTION_RESTART
= 1,
100 SC_ACTION_REBOOT
= 2,
101 SC_ACTION_RUN_COMMAND
= 3
104 typedef struct _SC_ACTION
{
107 } SC_ACTION
,*LPSC_ACTION
;
109 typedef struct _SERVICE_FAILURE_ACTIONSW
{
111 [unique] LPWSTR lpRebootMsg
;
112 [unique] LPWSTR lpCommand
;
114 [size_is(cActions
)] SC_ACTION
*lpsaActions
;
115 } SERVICE_FAILURE_ACTIONSW
,*LPSERVICE_FAILURE_ACTIONSW
;
117 typedef struct _SERVICE_DELAYED_AUTO_START_INFO
{
118 BOOL fDelayedAutostart
;
119 } SERVICE_DELAYED_AUTO_START_INFO
;
121 typedef struct _SERVICE_FAILURE_ACTIONS_FLAG
{
122 BOOL fFailureActionsOnNonCrashFailures
;
123 } SERVICE_FAILURE_ACTIONS_FLAG
;
125 typedef struct _SERVICE_SID_INFO
{
126 DWORD dwServiceSidType
;
129 typedef struct _SERVICE_PRESHUTDOWN_INFO
{
130 DWORD dwPreshutdownTimeout
;
131 } SERVICE_PRESHUTDOWN_INFO
,*LPSERVICE_PRESHUTDOWN_INFO
;
133 #define SERVICE_CONFIG_DESCRIPTION
1
134 #define SERVICE_CONFIG_FAILURE_ACTIONS
2
135 #define SERVICE_CONFIG_DELAYED_AUTO_START_INFO
3
136 #define SERVICE_CONFIG_FAILURE_ACTIONS_FLAG
4
137 #define SERVICE_CONFIG_SERVICE_SID_INFO
5
138 #define SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO
6
139 #define SERVICE_CONFIG_PRESHUTDOWN_INFO
7
141 typedef struct _ENUM_SERVICE_STATUSW
{
142 LPWSTR lpServiceName
;
143 LPWSTR lpDisplayName
;
144 SERVICE_STATUS ServiceStatus
;
145 } ENUM_SERVICE_STATUSW
, *LPENUM_SERVICE_STATUSW
;
149 typedef struct _SERVICE_RPC_REQUIRED_PRIVILEGES_INFO
{
150 DWORD cbRequiredPrivileges
;
151 [size_is(cbRequiredPrivileges
)] BYTE *pRequiredPrivileges
;
152 } SERVICE_RPC_REQUIRED_PRIVILEGES_INFO
;
154 typedef struct _SC_RPC_CONFIG_INFOW
{
156 [switch_is(dwInfoLevel
)] union {
157 [case(SERVICE_CONFIG_DESCRIPTION
)] SERVICE_DESCRIPTIONW
*descr
;
158 [case(SERVICE_CONFIG_FAILURE_ACTIONS
)] SERVICE_FAILURE_ACTIONSW
*actions
;
159 [case(SERVICE_CONFIG_DELAYED_AUTO_START_INFO
)] SERVICE_DELAYED_AUTO_START_INFO
*delayedstart
;
160 [case(SERVICE_CONFIG_FAILURE_ACTIONS_FLAG
)] SERVICE_FAILURE_ACTIONS_FLAG
*actionsflag
;
161 [case(SERVICE_CONFIG_SERVICE_SID_INFO
)] SERVICE_SID_INFO
*sid
;
162 [case(SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO
)] SERVICE_RPC_REQUIRED_PRIVILEGES_INFO
*privinfo
;
163 [case(SERVICE_CONFIG_PRESHUTDOWN_INFO
)] SERVICE_PRESHUTDOWN_INFO
*preshutdown
;
165 } SC_RPC_CONFIG_INFOW
;
167 /* Compatible with Windows function 0x00 */
168 DWORD svcctl_CloseServiceHandle
(
169 [in,out] SC_RPC_HANDLE
*handle
172 /* Compatible with Windows function 0x01 */
173 DWORD svcctl_ControlService
(
174 [in] SC_RPC_HANDLE hService
,
175 [in] DWORD dwControl
,
176 [out] SERVICE_STATUS
*lpServiceStatus
179 /* Compatible with Windows function 0x02 */
180 DWORD svcctl_DeleteService
(
181 [in] SC_RPC_HANDLE hService
184 /* Compatible with Windows function 0x03 */
185 DWORD svcctl_LockServiceDatabase
(
186 [in] SC_RPC_HANDLE hSCManager
,
187 [out] SC_RPC_LOCK
*phLock
190 /* Not compatible with Windows function 0x04 */
191 DWORD svcctl_QueryServiceObjectSecurity
(/* FIXME */);
193 /* Not compatible with Windows function 0x05 */
194 DWORD svcctl_SetServiceObjectSecurity
(/* FIXME */);
196 /* Not compatible with Windows function 0x06 */
197 DWORD svcctl_QueryServiceStatus
(/* FIXME */);
199 /* Compatible with Windows function 0x07 */
200 DWORD svcctl_SetServiceStatus
(
201 [in] SC_RPC_HANDLE hServiceStatus
,
202 [in] LPSERVICE_STATUS lpServiceStatus
205 /* Compatible with Windows function 0x08 */
206 DWORD svcctl_UnlockServiceDatabase
(
207 [in,out] SC_RPC_LOCK
*phLock
210 /* Not compatible with Windows function 0x09 */
211 DWORD svcctl_NotifyBootConfigStatus
(/* FIXME */);
213 /* Not compatible with Windows function 0x0a */
214 DWORD svcctl_SCSetServiceBitsW
(/* FIXME */);
216 /* Compatible with Windows function 0x0b */
217 DWORD svcctl_ChangeServiceConfigW
(
218 [in] SC_RPC_HANDLE hService
,
219 [in] DWORD dwServiceType
,
220 [in] DWORD dwStartType
,
221 [in] DWORD dwErrorControl
,
222 [in,unique] LPCWSTR lpBinaryPathName
,
223 [in,unique] LPCWSTR lpLoadOrderGroupKey
,
224 [in,out,unique] DWORD
*lpdwTagId
,
225 [in,unique,size_is(dwDependenciesSize
)] const BYTE *lpDependencies
,
226 [in] DWORD dwDependenciesSize
,
227 [in,unique] LPCWSTR lpServiceStartName
,
228 [in,unique,size_is(dwPasswordSize
)] const BYTE *lpPassword
,
229 [in] DWORD dwPasswordSize
,
230 [in,unique] LPCWSTR lpDisplayName
233 /* Compatible with Windows function 0x0c */
234 DWORD svcctl_CreateServiceW
(
235 [in] SC_RPC_HANDLE hSCManager
,
236 [in] LPCWSTR lpServiceName
,
237 [in,unique] LPCWSTR lpDisplayName
,
238 [in] DWORD dwDesiredAccess
,
239 [in] DWORD dwServiceType
,
240 [in] DWORD dwStartType
,
241 [in] DWORD dwErrorControl
,
242 [in] LPCWSTR lpBinaryPathName
,
243 [in,unique] LPCWSTR lpLoadOrderGroup
,
244 [in,out,unique] DWORD
*lpdwTagId
,
245 [in,unique,size_is(dwDependenciesSize
)] const BYTE *lpDependencies
,
246 [in] DWORD dwDependenciesSize
,
247 [in,unique] LPCWSTR lpServiceStartName
,
248 [in,unique,size_is(dwPasswordSize
)] const BYTE *lpPassword
,
249 [in] DWORD dwPasswordSize
,
250 [out] SC_RPC_HANDLE
*phService
253 /* Not compatible with Windows function 0x0d */
254 DWORD svcctl_EnumDependentServicesW
(/* FIXME */);
256 /* Not compatible with Windows function 0x0e */
257 DWORD svcctl_EnumServicesStatusW
(
258 [in] SC_RPC_HANDLE hmngr
,
261 [out,size_is(size
)] BYTE *buffer
,
263 [out] LPDWORD needed
,
264 [out] LPDWORD returned
267 /* Compatible with Windows function 0x0f */
268 DWORD svcctl_OpenSCManagerW
(
269 [in,unique] MACHINE_HANDLEW MachineName
,
270 [in,unique] LPCWSTR DatabaseName
,
271 [in] DWORD dwAccessMask
,
272 [out] SC_RPC_HANDLE
*handle
275 /* Compatible with Windows function 0x10 */
276 DWORD svcctl_OpenServiceW
(
277 [in] SC_RPC_HANDLE hSCManager
,
278 [in] LPCWSTR lpServiceName
,
279 [in] DWORD dwDesiredAccess
,
280 [out] SC_RPC_HANDLE
*phService
283 /* Windows function 0x11 must be using a different prototype - not compatible */
284 DWORD svcctl_QueryServiceConfigW
(
285 [in] SC_RPC_HANDLE hService
,
286 [out] QUERY_SERVICE_CONFIGW
*config
);
288 /* Not compatible with Windows function 0x12 */
289 DWORD svcctl_QueryServiceLockStatusW
(/* FIXME */);
291 /* Untested with Windows function 0x13 */
292 DWORD svcctl_StartServiceW
(
293 [in] SC_RPC_HANDLE hService
,
294 [in] DWORD dwNumServiceArgs
,
295 [in,unique,size_is(dwNumServiceArgs
)] LPCWSTR
*lpServiceArgVectors
298 /* Compatible with Windows function 0x14 */
299 DWORD svcctl_GetServiceDisplayNameW
(
300 [in] SC_RPC_HANDLE hSCManager
,
301 [in] LPCWSTR lpServiceName
,
302 [out,string,size_is(*cchBufSize
+1)] WCHAR lpBuffer
[],
303 [in,out] DWORD
*cchBufSize
);
305 /* Compatible with Windows function 0x15 */
306 DWORD svcctl_GetServiceKeyNameW
(
307 [in] SC_RPC_HANDLE hSCManager
,
308 [in] LPCWSTR lpServiceDisplayName
,
309 [out,string,size_is(*cchBufSize
+1)] WCHAR lpBuffer
[],
310 [in,out] DWORD
*cchBufSize
);
312 /* Not compatible with Windows function 0x16 */
313 DWORD svcctl_SCSetServiceBitsA
(/* FIXME */);
315 /* Not compatible with Windows function 0x17 */
316 DWORD svcctl_ChangeServiceConfigA
(/* FIXME */);
318 /* Not compatible with Windows function 0x18 */
319 DWORD svcctl_CreateServiceA
(/* FIXME */);
321 /* Not compatible with Windows function 0x19 */
322 DWORD svcctl_EnumDependentServicesA
(/* FIXME */);
324 /* Not compatible with Windows function 0x1a */
325 DWORD svcctl_EnumServicesStatusA
(/* FIXME */);
327 /* Not compatible with Windows function 0x1b */
328 DWORD svcctl_OpenSCManagerA
(/* FIXME */);
330 /* Not compatible with Windows function 0x1c */
331 DWORD svcctl_OpenServiceA
(/* FIXME */);
333 /* Not compatible with Windows function 0x1d */
334 DWORD svcctl_QueryServiceConfigA
(/* FIXME */);
336 /* Not compatible with Windows function 0x1e */
337 DWORD svcctl_QueryServiceLockStatusA
(/* FIXME */);
339 /* Not compatible with Windows function 0x1f */
340 DWORD svcctl_StartServiceA
(/* FIXME */);
342 /* Not compatible with Windows function 0x20 */
343 DWORD svcctl_GetServiceDisplayNameA
(/* FIXME */);
345 /* Not compatible with Windows function 0x21 */
346 DWORD svcctl_GetServiceKeyNameA
(/* FIXME */);
348 /* Not compatible with Windows function 0x22 */
349 DWORD svcctl_GetCurrentGroupStateW
(/* FIXME */);
351 /* Not compatible with Windows function 0x23 */
352 DWORD svcctl_EnumServiceGroupW
(/* FIXME */);
354 /* Not compatible with Windows function 0x24 */
355 DWORD svcctl_ChangeServiceConfig2A
(/* FIXME */);
357 /* Compatible with Windows function 0x25 */
358 DWORD svcctl_ChangeServiceConfig2W
(
359 [in] SC_RPC_HANDLE hService
,
360 [in] SC_RPC_CONFIG_INFOW config
);
362 /* Not compatible with Windows function 0x26 */
363 DWORD svcctl_QueryServiceConfig2A
(/* FIXME */);
365 /* Untested with Windows function 0x27 */
366 DWORD svcctl_QueryServiceConfig2W
(
367 [in] SC_RPC_HANDLE hService
,
368 [in] DWORD InfoLevel
,
369 [out,size_is(cbBufSize
)] BYTE lpBuffer
[],
370 [in] DWORD cbBufSize
,
371 [out] LPDWORD pcbBytesNeeded
374 /* Untested with Windows function 0x28 */
375 DWORD svcctl_QueryServiceStatusEx
(
376 [in] SC_RPC_HANDLE hService
,
377 [in] SC_STATUS_TYPE InfoLevel
,
378 [out,size_is(cbBufSize
)] BYTE *lpBuffer
,
379 [in] DWORD cbBufSize
,
380 [out] LPDWORD pcbBytesNeeded
383 DWORD svcctl_EnumServicesStatusExW
(
384 [in] SC_RPC_HANDLE hmngr
,
387 [out,size_is(size
)] BYTE *buffer
,
389 [out] LPDWORD needed
,
390 [out] LPDWORD returned
,
391 [in,unique] LPCWSTR group