xref: /illumos-gate/usr/src/uts/common/smbsrv/ndl/svcctl.ndl (revision 069e6b7e31ba5dcbc5441b98af272714d9a5455c)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 *
25 * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
26 */
27
28#ifndef _MLSVC_SVCCTL_NDL_
29#define _MLSVC_SVCCTL_NDL_
30
31/*
32 * NT Service Control Services (SVCCTL) RPC interface definition.
33 * This interface provides remote access to add, remove, start and
34 * stop services.
35 */
36
37#include <libmlrpc/ndrtypes.ndl>
38
39/* Windows NT */
40#define SVCCTL_OPNUM_Close			0x00
41#define	SVCCTL_OPNUM_ControlService		0x01
42#define	SVCCTL_OPNUM_DeleteService		0x02
43#define	SVCCTL_OPNUM_LockServiceDatabase	0x03
44#define	SVCCTL_OPNUM_QueryServiceSecurity	0x04
45#define	SVCCTL_OPNUM_SetServiceSecurity		0x05
46#define SVCCTL_OPNUM_QueryServiceStatus		0x06
47#define	SVCCTL_OPNUM_SetServiceStatus		0x07
48#define	SVCCTL_OPNUM_UnlockServiceDatabase	0x08
49#define	SVCCTL_OPNUM_NotifyBootConfigStatus	0x09
50#define	SVCCTL_OPNUM_SetServiceBits		0x0a
51#define	SVCCTL_OPNUM_ChangeServiceConfig	0x0b
52#define	SVCCTL_OPNUM_CreateService		0x0c
53#define	SVCCTL_OPNUM_EnumDependentServices	0x0d
54#define SVCCTL_OPNUM_EnumServicesStatus		0x0E
55#define SVCCTL_OPNUM_OpenManager		0x0F
56#define SVCCTL_OPNUM_OpenService		0x10
57#define SVCCTL_OPNUM_QueryServiceConfig		0x11
58#define	SVCCTL_OPNUM_QueryServiceLockStatus	0x12
59#define	SVCCTL_OPNUM_StartService		0x13
60#define	SVCCTL_OPNUM_GetServiceDisplayNameW	0x14
61#define	SVCCTL_OPNUM_GetServiceKeyNameW		0x15
62#define	SVCCTL_OPNUM_SetServiceBitsA		0x16
63#define	SVCCTL_OPNUM_ChangeServiceConfigA	0x17
64#define	SVCCTL_OPNUM_CreateServiceA		0x18
65#define	SVCCTL_OPNUM_EnumDependentServicesA	0x19
66#define	SVCCTL_OPNUM_EnumServicesStatusA	0x1a
67#define	SVCCTL_OPNUM_OpenSCManagerA		0x1b
68#define	SVCCTL_OPNUM_OpenServiceA		0x1c
69#define	SVCCTL_OPNUM_QueryServiceConfigA	0x1d
70#define	SVCCTL_OPNUM_QueryServiceLockStatusA	0x1e
71#define	SVCCTL_OPNUM_StartServiceA		0x1f
72#define	SVCCTL_OPNUM_GetServiceDisplayNameA	0x20
73#define	SVCCTL_OPNUM_GetServiceKeyNameA		0x21
74#define	SVCCTL_OPNUM_GetCurrentGroupStateW	0x22
75#define	SVCCTL_OPNUM_EnumServiceGroupW		0x23
76#define	SVCCTL_OPNUM_ChangeServiceConfig2A	0x24
77#define	SVCCTL_OPNUM_ChangeServiceConfig2W	0x25
78#define	SVCCTL_OPNUM_QueryServiceConfig2A	0x26
79
80/* Windows 2000 */
81#define	SVCCTL_OPNUM_QueryServiceConfig2W	0x27
82#define	SVCCTL_OPNUM_QueryServiceStatusEx	0x28
83#define	SVCCTL_OPNUM_EnumServicesStatusExA	0x29
84#define	SVCCTL_OPNUM_EnumServicesStatusExW	0x2a
85
86/* Windows XP and Windows Server 2003 */
87#define	SVCCTL_OPNUM_SendTSMessage		0x2b
88
89/* Windows Vista */
90#define	SVCCTL_OPNUM_CreateServiceWOW64A	0x2c
91#define	SVCCTL_OPNUM_CreateServiceWOW64W	0x2d
92#define	SVCCTL_OPNUM_QueryServiceTagInfo	0x2e
93#define	SVCCTL_OPNUM_NotifyServiceStatusChange	0x2f
94#define	SVCCTL_OPNUM_GetNotifyResult		0x30
95#define	SVCCTL_OPNUM_CloseNotifyHandle		0x31
96#define	SVCCTL_OPNUM_ControlServiceExA		0x32
97#define	SVCCTL_OPNUM_ControlServiceExW		0x33
98#define	SVCCTL_OPNUM_SendPnPMessage		0x34
99#define	SVCCTL_OPNUM_ValidatePnPService		0x35
100#define	SVCCTL_OPNUM_OpenServiceStatusHandle	0x36
101
102CONTEXT_HANDLE(svcctl_handle) svcctl_handle_t;
103
104/*
105 * String definition for the ASCII interface.
106 */
107struct svcctl_value {
108	DWORD	vc_first_is;	/* 0 */
109	DWORD	vc_length_is;
110    SIZE_IS(vc_length_is)
111	BYTE	value[ANY_SIZE_ARRAY];
112};
113
114/*
115 * The svc_status (SERVICE_STATUS) structure contains information about a
116 * service. The ControlService, EnumDependentServices, EnumServicesStatus,
117 * and QueryServiceStatus functions use this structure to return information
118 * about a service. A service uses this structure in the SetServiceStatus
119 * function to report its current status to the service control manager.
120 *
121 * service_type
122 *	The type of service. This member can be one of the following values.
123 *
124 *      SERVICE_FILE_SYSTEM_DRIVER
125 *      SERVICE_KERNEL_DRIVER
126 *      SERVICE_WIN32_OWN_PROCESS
127 *      SERVICE_WIN32_SHARE_PROCESS
128 *
129 * If the service type is either SERVICE_WIN32_OWN_PROCESS or
130 * SERVICE_WIN32_SHARE_PROCESS, and the service is running in
131 * the context of the LocalSystem account, the following type
132 * may also be specified to indicate that the service can
133 * interact with the desktop.
134 *
135 *      SERVICE_INTERACTIVE_PROCESS
136 *
137 * cur_state
138 *	The current state of the service. This member can be one of the
139 *	following values.
140 *
141 *      SERVICE_CONTINUE_PENDING
142 *      SERVICE_PAUSE_PENDING
143 *      SERVICE_PAUSED
144 *      SERVICE_RUNNING
145 *      SERVICE_START_PENDING
146 *      SERVICE_STOP_PENDING
147 *      SERVICE_STOPPED
148 *
149 * ctrl_accepted
150 *	The control codes that the service will accept and process in its
151 *	handler function (see Handler and HandlerEx). A user interface
152 *	process can control a service by specifying a control command in
153 *	the ControlService function. By default, all services accept the
154 *	SERVICE_CONTROL_INTERROGATE value. The following are the control
155 *	codes.
156 *
157 *      SERVICE_ACCEPT_STOP
158 *      SERVICE_ACCEPT_PAUSE_CONTINUE
159 *      SERVICE_ACCEPT_SHUTDOWN
160 *      SERVICE_ACCEPT_PARAMCHANGE
161 *      SERVICE_ACCEPT_NETBINDCHANGE
162 *
163 * w32_exitcode
164 *  An error code that the service uses to report an error that occurs when
165 *  it is starting or stopping. To return an error code specific to the
166 *  service, the service must set this value to ERROR_SERVICE_SPECIFIC_ERROR
167 *  to indicate that the dwServiceSpecificExitCode member contains the error
168 *  code. The service should set this value to NO_ERROR when it is running
169 *  and on normal termination.
170 *
171 * svc_specified_exitcode
172 *  A service-specific error code that the service returns when an error
173 *  occurs while the service is starting or stopping. This value is ignored
174 *  unless the w32_exitcode member is set to ERROR_SERVICE_SPECIFIC_ERROR.
175 *
176 * check_point
177 *  A value that the service increments periodically to report its progress
178 *  during a lengthy start, stop, pause, or continue operation. For example,
179 *  the service should increment this value as it completes each step of its
180 *  initialization when it is starting up. The user interface program that
181 *  invoked the operation on the service uses this value to track the progress
182 *  of the service during a lengthy operation. This value is not valid and
183 *  should be zero when the service does not have a start, stop, pause, or
184 *  continue operation pending.
185 *
186 * wait_hint
187 *  An estimate of the amount of time, in milliseconds, that the service
188 *  expects a pending start, stop, pause, or continue operation to take
189 *  before the service makes its next call to the SetServiceStatus
190 *  function with either an incremented check_point value or a change in
191 *  dwCurrentState. If the amount of time specified by wait_hint passes,
192 *  and check_point has not been incremented, or cur_state has not changed,
193 *  the service control manager or service control program can assume that
194 *  an error has occurred and the service should be stopped.
195 */
196struct svc_status {
197	DWORD service_type;
198	DWORD cur_state;
199	DWORD ctrl_accepted;
200	DWORD w32_exitcode;
201	DWORD svc_specified_exitcode;
202	DWORD check_point;
203	DWORD wait_hint;
204};
205typedef struct svc_status svc_status_t;
206
207struct svc_enum_status {
208	DWORD svc_name;		/* offset within response buffer */
209	DWORD display_name;	/* offset within response buffer */
210	svc_status_t svc_status;
211};
212typedef struct svc_enum_status svc_enum_status_t;
213
214struct svc_config {
215	DWORD  service_type;
216	DWORD  start_type;
217	DWORD  error_control;
218	LPTSTR binary_pathname;
219	LPTSTR loadorder_group;
220	DWORD  tag_id;
221	LPTSTR dependencies;
222	LPTSTR service_startname;
223	LPTSTR display_name;
224};
225typedef struct svc_config svc_config_t;
226
227struct svc_failure_actions {
228	DWORD reset_period;
229	DWORD rebootmsg_offset;
230	DWORD command_offset;
231	DWORD actions;
232	DWORD actions_offset;
233};
234typedef struct svc_failure_actions svc_failure_actions_t;
235
236struct svc_description {
237	DWORD desc;		/* offset of description string */
238};
239typedef struct svc_description svc_description_t;
240
241/* Boolean flag to control delayed start of service. Set 1=true, 0=false */
242struct svc_delayed_auto_start {
243	DWORD dstart;
244};
245typedef struct svc_delayed_auto_start svc_delayed_auto_start_t;
246
247/* Boolean flag to control configured failure action. Set 1=true, 0=false */
248struct svc_config_failure_action {
249	DWORD cfa;
250};
251typedef struct svc_config_failure_action svc_config_failure_action_t;
252
253/*
254 ***********************************************************************
255 * Close
256 ***********************************************************************
257 */
258OPERATION(SVCCTL_OPNUM_Close)
259struct svcctl_Close {
260	IN		svcctl_handle_t handle;
261	OUT		svcctl_handle_t result_handle;
262	OUT		DWORD status;
263};
264
265/*
266 ***********************************************************************
267 * ControlService
268 ***********************************************************************
269 */
270OPERATION(SVCCTL_OPNUM_ControlService)
271struct svcctl_ControlService {
272	IN		svcctl_handle_t service_handle;
273	IN		DWORD control;
274	OUT		svc_status_t service_status;
275	OUT		DWORD status;
276};
277
278/*
279 ***********************************************************************
280 * DeleteService
281 ***********************************************************************
282 */
283OPERATION(SVCCTL_OPNUM_DeleteService)
284struct svcctl_DeleteService {
285	IN		svcctl_handle_t service_handle;
286	OUT		DWORD status;
287};
288
289/*
290 ***********************************************************************
291 * QueryServiceSecurity
292 ***********************************************************************
293 */
294OPERATION(SVCCTL_OPNUM_QueryServiceSecurity)
295struct svcctl_QueryServiceSecurity {
296	IN		svcctl_handle_t service_handle;
297	IN		DWORD security_info;
298	IN		DWORD buf_size;
299    SIZE_IS(buf_size)
300	OUT REFERENCE	LPBYTE buffer;
301	OUT		DWORD bytes_needed;
302	OUT		DWORD status;
303};
304
305/*
306 ***********************************************************************
307 * SetServiceSecurity
308 ***********************************************************************
309 */
310OPERATION(SVCCTL_OPNUM_SetServiceSecurity)
311struct svcctl_SetServiceSecurity {
312	IN		svcctl_handle_t service_handle;
313	IN		DWORD security_info;
314    SIZE_IS(buf_size)
315	IN REFERENCE	LPBYTE buffer;
316	IN		DWORD buf_size;
317	OUT		DWORD status;
318};
319
320/*
321 ***********************************************************************
322 * OpenManager
323 ***********************************************************************
324 */
325OPERATION(SVCCTL_OPNUM_OpenManager)
326struct svcctl_OpenManager {
327	IN		LPTSTR machine_name;
328	IN		LPTSTR database_name;
329	IN		DWORD desired_access;
330	OUT		svcctl_handle_t handle;
331	OUT		DWORD status;
332};
333
334
335/*
336 ***********************************************************************
337 * OpenService
338 ***********************************************************************
339 */
340OPERATION(SVCCTL_OPNUM_OpenService)
341struct svcctl_OpenService {
342	IN		svcctl_handle_t manager_handle;
343	IN REFERENCE	LPTSTR service_name;
344	IN		DWORD desired_access;
345	OUT		svcctl_handle_t service_handle;
346	OUT		DWORD status;
347};
348
349
350/*
351 ***********************************************************************
352 * QueryServiceStatus
353 ***********************************************************************
354 */
355OPERATION(SVCCTL_OPNUM_QueryServiceStatus)
356struct svcctl_QueryServiceStatus {
357	IN		svcctl_handle_t service_handle;
358	OUT		svc_status_t service_status;
359	OUT		DWORD status;
360};
361
362/*
363 ***********************************************************************
364 * EnumDependentServices
365 ***********************************************************************
366 */
367OPERATION(SVCCTL_OPNUM_EnumDependentServices)
368struct svcctl_EnumDependentServices {
369	IN		svcctl_handle_t service_handle;
370	IN		DWORD svc_state;
371	IN		DWORD buf_size;
372    SIZE_IS(buf_size)
373	OUT REFERENCE	LPBYTE services;
374	OUT		DWORD bytes_needed;
375	OUT		DWORD svc_num;
376	OUT		DWORD status;
377};
378
379/*
380 ***********************************************************************
381 * EnumServicesStatus
382 ***********************************************************************
383 */
384OPERATION(SVCCTL_OPNUM_EnumServicesStatus)
385struct svcctl_EnumServicesStatus {
386	IN		svcctl_handle_t manager_handle;
387	IN		DWORD svc_type;
388	IN		DWORD svc_state;
389	IN		DWORD buf_size;
390    SIZE_IS(buf_size)
391	OUT REFERENCE	LPBYTE services;
392	OUT		DWORD bytes_needed;
393	OUT		DWORD svc_num;
394	INOUT		DWORD *resume_handle;
395	OUT		DWORD status;
396};
397
398/*
399 ***********************************************************************
400 * QueryServiceConfig
401 ***********************************************************************
402 */
403OPERATION(SVCCTL_OPNUM_QueryServiceConfig)
404struct svcctl_QueryServiceConfig {
405	IN		svcctl_handle_t service_handle;
406	IN		DWORD buf_size;
407	OUT		svc_config_t service_cfg;
408	OUT		DWORD cfg_bytes;
409	OUT		DWORD status;
410};
411
412/*
413 ***********************************************************************
414 * StartService
415 *
416 * argc:	The number of strings in argv.  If argv is NULL,
417 *		argc may be 0.
418 * argv:	A pointer to a buffer containing an array of
419 *		null-terminated Unicode strings.
420 *
421 * For service management support, this should probably be:
422 *	IN		DWORD argc;
423 *    SIZE_IS(buf_size)
424 *	IN REFERENCE	LPBYTE argv;
425 ***********************************************************************
426 */
427OPERATION(SVCCTL_OPNUM_StartService)
428struct svcctl_StartService {
429	IN		svcctl_handle_t service_handle;
430	IN		DWORD argc;
431	IN		DWORD argv;
432	OUT		DWORD status;
433};
434
435/*
436 ***********************************************************************
437 * GetServiceDisplayNameW
438 ***********************************************************************
439 */
440OPERATION(SVCCTL_OPNUM_GetServiceDisplayNameW)
441struct svcctl_GetServiceDisplayNameW {
442	IN		svcctl_handle_t manager_handle;
443	IN REFERENCE	LPTSTR service_name;
444	OUT REFERENCE	LPTSTR display_name;
445	INOUT		DWORD buf_size;
446	OUT		DWORD status;
447};
448
449/*
450 ***********************************************************************
451 * GetServiceKeyNameW
452 ***********************************************************************
453 */
454OPERATION(SVCCTL_OPNUM_GetServiceKeyNameW)
455struct svcctl_GetServiceKeyNameW {
456	IN		svcctl_handle_t manager_handle;
457	IN REFERENCE	LPTSTR service_name;
458	OUT REFERENCE	LPTSTR key_name;
459	INOUT		DWORD buf_size;
460	OUT		DWORD status;
461};
462
463/*
464 ***********************************************************************
465 * OpenSCManagerA
466 ***********************************************************************
467 */
468OPERATION(SVCCTL_OPNUM_OpenSCManagerA)
469struct svcctl_OpenSCManagerA {
470	IN		struct svcctl_value *machine_name;
471	IN		struct svcctl_value *database_name;
472	IN		DWORD desired_access;
473	OUT		svcctl_handle_t handle;
474	OUT		DWORD status;
475};
476
477/*
478 ***********************************************************************
479 * OpenServiceA
480 ***********************************************************************
481 */
482OPERATION(SVCCTL_OPNUM_OpenServiceA)
483struct svcctl_OpenServiceA {
484	IN		svcctl_handle_t manager_handle;
485	IN REFERENCE	struct svcctl_value *service_name;
486	IN		DWORD desired_access;
487	OUT		svcctl_handle_t service_handle;
488	OUT		DWORD status;
489};
490
491/*
492 ***********************************************************************
493 * EnumServicesStatusA
494 ***********************************************************************
495 */
496OPERATION(SVCCTL_OPNUM_EnumServicesStatusA)
497struct svcctl_EnumServicesStatusA {
498	IN		svcctl_handle_t manager_handle;
499	IN		DWORD svc_type;
500	IN		DWORD svc_state;
501	IN		DWORD buf_size;
502    SIZE_IS(buf_size)
503	OUT REFERENCE	LPBYTE services;
504	OUT		DWORD bytes_needed;
505	OUT		DWORD svc_num;
506	INOUT		DWORD *resume_handle;
507	OUT		DWORD status;
508};
509
510/*
511 ***********************************************************************
512 * QueryServiceConfig2W
513 ***********************************************************************
514 */
515OPERATION(SVCCTL_OPNUM_QueryServiceConfig2W)
516struct svcctl_QueryServiceConfig2W {
517	IN		svcctl_handle_t service_handle;
518	IN		DWORD info_level;
519	IN		DWORD buf_size;
520    SIZE_IS(buf_size)
521	OUT REFERENCE	LPBYTE buffer;
522	OUT		DWORD bytes_needed;
523	OUT		DWORD status;
524};
525
526/*
527 ***********************************************************************
528 * QueryServiceStatusEx
529 ***********************************************************************
530 */
531struct svc_status_ex {
532	DWORD service_type;
533	DWORD cur_state;
534	DWORD ctrl_accepted;
535	DWORD w32_exitcode;
536	DWORD svc_specified_exitcode;
537	DWORD check_point;
538	DWORD wait_hint;
539	DWORD process_id;
540	DWORD service_flags;
541};
542typedef struct svc_status_ex svc_status_ex_t;
543
544OPERATION(SVCCTL_OPNUM_QueryServiceStatusEx)
545struct svcctl_QueryServiceStatusEx {
546	IN		svcctl_handle_t service_handle;
547	IN		DWORD info_level;
548	IN		DWORD buf_size;
549    SIZE_IS(buf_size)
550	OUT REFERENCE	LPBYTE buffer;
551	OUT		DWORD bytes_needed;
552	OUT		DWORD status;
553};
554
555/*
556 ***********************************************************************
557 * The SVCCTL interface definition.
558 ***********************************************************************
559 */
560INTERFACE(0)
561union svcctl_interface {
562	CASE(SVCCTL_OPNUM_Close)
563		struct svcctl_Close			SvcClose;
564	CASE(SVCCTL_OPNUM_ControlService)
565		struct svcctl_ControlService		SvcControlService;
566	CASE(SVCCTL_OPNUM_DeleteService)
567		struct svcctl_DeleteService		SvcDeleteService;
568	CASE(SVCCTL_OPNUM_QueryServiceSecurity)
569		struct svcctl_QueryServiceSecurity	SvcQueryServiceSecurity;
570	CASE(SVCCTL_OPNUM_SetServiceSecurity)
571		struct svcctl_SetServiceSecurity	SvcSetServiceSecurity;
572	CASE(SVCCTL_OPNUM_OpenManager)
573		struct svcctl_OpenManager		SvcOpenManager;
574	CASE(SVCCTL_OPNUM_OpenService)
575		struct svcctl_OpenService		SvcOpenService;
576	CASE(SVCCTL_OPNUM_QueryServiceStatus)
577		struct svcctl_QueryServiceStatus	SvcQueryServiceStatus;
578	CASE(SVCCTL_OPNUM_EnumDependentServices)
579		struct svcctl_EnumDependentServices Svc_EnumDependentServices;
580	CASE(SVCCTL_OPNUM_EnumServicesStatus)
581		struct svcctl_EnumServicesStatus	SvcEnumServicesStatus;
582	CASE(SVCCTL_OPNUM_QueryServiceConfig)
583		struct svcctl_QueryServiceConfig	SvcQueryServiceConfig;
584	CASE(SVCCTL_OPNUM_StartService)
585		struct svcctl_StartService		SvcStartService;
586	CASE(SVCCTL_OPNUM_GetServiceDisplayNameW)
587		struct svcctl_GetServiceDisplayNameW SvcGetServiceDisplayNameW;
588	CASE(SVCCTL_OPNUM_GetServiceKeyNameW)
589		struct svcctl_GetServiceKeyNameW	SvcGetServiceKeyNameW;
590	CASE(SVCCTL_OPNUM_OpenSCManagerA)
591		struct svcctl_OpenSCManagerA		SvcOpenSCManagerA;
592	CASE(SVCCTL_OPNUM_OpenServiceA)
593		struct svcctl_OpenServiceA		SvcOpenServiceA;
594	CASE(SVCCTL_OPNUM_EnumServicesStatusA)
595		struct svcctl_EnumServicesStatusA	SvcEnumServicesStatusA;
596	CASE(SVCCTL_OPNUM_QueryServiceConfig2W)
597		struct svcctl_QueryServiceConfig2W	SvcQueryServiceConfig2W;
598	CASE(SVCCTL_OPNUM_QueryServiceStatusEx)
599		struct svcctl_QueryServiceStatusEx	SvcQueryServiceStatusEx;
600};
601
602typedef union svcctl_interface	svcctl_interface_t;
603EXTERNTYPEINFO(svcctl_interface)
604
605
606#endif /* _MLSVC_SVCCTL_NDL_ */
607