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_PRESHUTDOWN_INFO
{
118 DWORD dwPreshutdownTimeout
;
119 } SERVICE_PRESHUTDOWN_INFO
,*LPSERVICE_PRESHUTDOWN_INFO
;
121 #define SERVICE_CONFIG_DESCRIPTION
1
122 #define SERVICE_CONFIG_FAILURE_ACTIONS
2
123 #define SERVICE_CONFIG_DELAYED_AUTO_START_INFO
3
124 #define SERVICE_CONFIG_FAILURE_ACTIONS_FLAG
4
125 #define SERVICE_CONFIG_SERVICE_SID_INFO
5
126 #define SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO
6
127 #define SERVICE_CONFIG_PRESHUTDOWN_INFO
7
129 typedef struct _ENUM_SERVICE_STATUSW
{
130 LPWSTR lpServiceName
;
131 LPWSTR lpDisplayName
;
132 SERVICE_STATUS ServiceStatus
;
133 } ENUM_SERVICE_STATUSW
, *LPENUM_SERVICE_STATUSW
;
137 typedef [switch_type(DWORD
)] union
139 [case (SERVICE_CONFIG_DESCRIPTION
)] SERVICE_DESCRIPTIONW descr
;
140 [case (SERVICE_CONFIG_FAILURE_ACTIONS
)] SERVICE_FAILURE_ACTIONSW actions
;
141 [case (SERVICE_CONFIG_PRESHUTDOWN_INFO
)] SERVICE_PRESHUTDOWN_INFO preshutdown
;
144 /* Compatible with Windows function 0x00 */
145 DWORD svcctl_CloseServiceHandle
(
146 [in,out] SC_RPC_HANDLE
*handle
149 /* Compatible with Windows function 0x01 */
150 DWORD svcctl_ControlService
(
151 [in] SC_RPC_HANDLE hService
,
152 [in] DWORD dwControl
,
153 [out] SERVICE_STATUS
*lpServiceStatus
156 /* Compatible with Windows function 0x02 */
157 DWORD svcctl_DeleteService
(
158 [in] SC_RPC_HANDLE hService
161 /* Compatible with Windows function 0x03 */
162 DWORD svcctl_LockServiceDatabase
(
163 [in] SC_RPC_HANDLE hSCManager
,
164 [out] SC_RPC_LOCK
*phLock
167 /* Not compatible with Windows function 0x04 */
168 DWORD svcctl_QueryServiceObjectSecurity
(/* FIXME */);
170 /* Not compatible with Windows function 0x05 */
171 DWORD svcctl_SetServiceObjectSecurity
(/* FIXME */);
173 /* Not compatible with Windows function 0x06 */
174 DWORD svcctl_QueryServiceStatus
(/* FIXME */);
176 /* Compatible with Windows function 0x07 */
177 DWORD svcctl_SetServiceStatus
(
178 [in] SC_RPC_HANDLE hServiceStatus
,
179 [in] LPSERVICE_STATUS lpServiceStatus
182 /* Compatible with Windows function 0x08 */
183 DWORD svcctl_UnlockServiceDatabase
(
184 [in,out] SC_RPC_LOCK
*phLock
187 /* Not compatible with Windows function 0x09 */
188 DWORD svcctl_NotifyBootConfigStatus
(/* FIXME */);
190 /* Not compatible with Windows function 0x0a */
191 DWORD svcctl_SCSetServiceBitsW
(/* FIXME */);
193 /* Compatible with Windows function 0x0b */
194 DWORD svcctl_ChangeServiceConfigW
(
195 [in] SC_RPC_HANDLE hService
,
196 [in] DWORD dwServiceType
,
197 [in] DWORD dwStartType
,
198 [in] DWORD dwErrorControl
,
199 [in,unique] LPCWSTR lpBinaryPathName
,
200 [in,unique] LPCWSTR lpLoadOrderGroupKey
,
201 [in,out,unique] DWORD
*lpdwTagId
,
202 [in,unique,size_is(dwDependenciesSize
)] const BYTE *lpDependencies
,
203 [in] DWORD dwDependenciesSize
,
204 [in,unique] LPCWSTR lpServiceStartName
,
205 [in,unique,size_is(dwPasswordSize
)] const BYTE *lpPassword
,
206 [in] DWORD dwPasswordSize
,
207 [in,unique] LPCWSTR lpDisplayName
210 /* Compatible with Windows function 0x0c */
211 DWORD svcctl_CreateServiceW
(
212 [in] SC_RPC_HANDLE hSCManager
,
213 [in] LPCWSTR lpServiceName
,
214 [in,unique] LPCWSTR lpDisplayName
,
215 [in] DWORD dwDesiredAccess
,
216 [in] DWORD dwServiceType
,
217 [in] DWORD dwStartType
,
218 [in] DWORD dwErrorControl
,
219 [in] LPCWSTR lpBinaryPathName
,
220 [in,unique] LPCWSTR lpLoadOrderGroup
,
221 [in,out,unique] DWORD
*lpdwTagId
,
222 [in,unique,size_is(dwDependenciesSize
)] const BYTE *lpDependencies
,
223 [in] DWORD dwDependenciesSize
,
224 [in,unique] LPCWSTR lpServiceStartName
,
225 [in,unique,size_is(dwPasswordSize
)] const BYTE *lpPassword
,
226 [in] DWORD dwPasswordSize
,
227 [out] SC_RPC_HANDLE
*phService
230 /* Not compatible with Windows function 0x0d */
231 DWORD svcctl_EnumDependentServicesW
(/* FIXME */);
233 /* Not compatible with Windows function 0x0e */
234 DWORD svcctl_EnumServicesStatusW
(
235 [in] SC_RPC_HANDLE hmngr
,
238 [out,size_is(size
)] BYTE *buffer
,
240 [out] LPDWORD needed
,
241 [out] LPDWORD returned
244 /* Compatible with Windows function 0x0f */
245 DWORD svcctl_OpenSCManagerW
(
246 [in,unique] MACHINE_HANDLEW MachineName
,
247 [in,unique] LPCWSTR DatabaseName
,
248 [in] DWORD dwAccessMask
,
249 [out] SC_RPC_HANDLE
*handle
252 /* Compatible with Windows function 0x10 */
253 DWORD svcctl_OpenServiceW
(
254 [in] SC_RPC_HANDLE hSCManager
,
255 [in] LPCWSTR lpServiceName
,
256 [in] DWORD dwDesiredAccess
,
257 [out] SC_RPC_HANDLE
*phService
260 /* Windows function 0x11 must be using a different prototype - not compatible */
261 DWORD svcctl_QueryServiceConfigW
(
262 [in] SC_RPC_HANDLE hService
,
263 [out] QUERY_SERVICE_CONFIGW
*config
);
265 /* Not compatible with Windows function 0x12 */
266 DWORD svcctl_QueryServiceLockStatusW
(/* FIXME */);
268 /* Untested with Windows function 0x13 */
269 DWORD svcctl_StartServiceW
(
270 [in] SC_RPC_HANDLE hService
,
271 [in] DWORD dwNumServiceArgs
,
272 [in,unique,size_is(dwNumServiceArgs
)] LPCWSTR
*lpServiceArgVectors
275 /* Compatible with Windows function 0x14 */
276 DWORD svcctl_GetServiceDisplayNameW
(
277 [in] SC_RPC_HANDLE hSCManager
,
278 [in] LPCWSTR lpServiceName
,
279 [out,string,size_is(*cchBufSize
+1)] WCHAR lpBuffer
[],
280 [in,out] DWORD
*cchBufSize
);
282 /* Compatible with Windows function 0x15 */
283 DWORD svcctl_GetServiceKeyNameW
(
284 [in] SC_RPC_HANDLE hSCManager
,
285 [in] LPCWSTR lpServiceDisplayName
,
286 [out,string,size_is(*cchBufSize
+1)] WCHAR lpBuffer
[],
287 [in,out] DWORD
*cchBufSize
);
289 /* Not compatible with Windows function 0x16 */
290 DWORD svcctl_SCSetServiceBitsA
(/* FIXME */);
292 /* Not compatible with Windows function 0x17 */
293 DWORD svcctl_ChangeServiceConfigA
(/* FIXME */);
295 /* Not compatible with Windows function 0x18 */
296 DWORD svcctl_CreateServiceA
(/* FIXME */);
298 /* Not compatible with Windows function 0x19 */
299 DWORD svcctl_EnumDependentServicesA
(/* FIXME */);
301 /* Not compatible with Windows function 0x1a */
302 DWORD svcctl_EnumServicesStatusA
(/* FIXME */);
304 /* Not compatible with Windows function 0x1b */
305 DWORD svcctl_OpenSCManagerA
(/* FIXME */);
307 /* Not compatible with Windows function 0x1c */
308 DWORD svcctl_OpenServiceA
(/* FIXME */);
310 /* Not compatible with Windows function 0x1d */
311 DWORD svcctl_QueryServiceConfigA
(/* FIXME */);
313 /* Not compatible with Windows function 0x1e */
314 DWORD svcctl_QueryServiceLockStatusA
(/* FIXME */);
316 /* Not compatible with Windows function 0x1f */
317 DWORD svcctl_StartServiceA
(/* FIXME */);
319 /* Not compatible with Windows function 0x20 */
320 DWORD svcctl_GetServiceDisplayNameA
(/* FIXME */);
322 /* Not compatible with Windows function 0x21 */
323 DWORD svcctl_GetServiceKeyNameA
(/* FIXME */);
325 /* Not compatible with Windows function 0x22 */
326 DWORD svcctl_GetCurrentGroupStateW
(/* FIXME */);
328 /* Not compatible with Windows function 0x23 */
329 DWORD svcctl_EnumServiceGroupW
(/* FIXME */);
331 /* Not compatible with Windows function 0x24 */
332 DWORD svcctl_ChangeServiceConfig2A
(/* FIXME */);
334 /* Untested with Windows function 0x25 */
335 DWORD svcctl_ChangeServiceConfig2W
(
336 [in] SC_RPC_HANDLE hService
,
337 [in] DWORD InfoLevel
,
338 [in,switch_is(InfoLevel
)] SERVICE_CONFIG2W
*config
);
340 /* Not compatible with Windows function 0x26 */
341 DWORD svcctl_QueryServiceConfig2A
(/* FIXME */);
343 /* Untested with Windows function 0x27 */
344 DWORD svcctl_QueryServiceConfig2W
(
345 [in] SC_RPC_HANDLE hService
,
346 [in] DWORD InfoLevel
,
347 [out,size_is(cbBufSize
)] BYTE lpBuffer
[],
348 [in] DWORD cbBufSize
,
349 [out] LPDWORD pcbBytesNeeded
352 /* Untested with Windows function 0x28 */
353 DWORD svcctl_QueryServiceStatusEx
(
354 [in] SC_RPC_HANDLE hService
,
355 [in] SC_STATUS_TYPE InfoLevel
,
356 [out,size_is(cbBufSize
)] BYTE *lpBuffer
,
357 [in] DWORD cbBufSize
,
358 [out] LPDWORD pcbBytesNeeded
361 DWORD svcctl_EnumServicesStatusExW
(
362 [in] SC_RPC_HANDLE hmngr
,
365 [out,size_is(size
)] BYTE *buffer
,
367 [out] LPDWORD needed
,
368 [out] LPDWORD returned
,
369 [in,unique] LPCWSTR group