xref: /titanic_52/usr/src/uts/common/smbsrv/ndl/svcctl.ndl (revision b9bd317cda1afb3a01f4812de73e8cec888cbbd7)
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 2007 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#ifndef _MLSVC_SVCCTL_NDL_
27#define _MLSVC_SVCCTL_NDL_
28
29#pragma ident	"%Z%%M%	%I%	%E% SMI"
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 "ndrtypes.ndl"
38
39#define SVCCTL_OPNUM_Close			0x00
40#define SVCCTL_OPNUM_QueryServiceStatus		0x06
41#define SVCCTL_OPNUM_EnumServicesStatus		0x0E
42#define SVCCTL_OPNUM_OpenManager		0x0F
43#define SVCCTL_OPNUM_OpenService		0x10
44#define SVCCTL_OPNUM_QueryServiceConfig		0x11
45
46/*
47 * Standard opaque 20 byte RPC handle.
48 */
49
50
51struct svcctl_handle {
52	DWORD hand1;
53	DWORD hand2;
54	WORD  hand3[2];
55	BYTE  hand4[8];
56};
57
58typedef struct svcctl_handle svcctl_handle_t;
59
60/*
61 * The svc_status (SERVICE_STATUS) structure contains information about a
62 * service. The ControlService, EnumDependentServices, EnumServicesStatus,
63 * and QueryServiceStatus functions use this structure to return information
64 * about a service. A service uses this structure in the SetServiceStatus
65 * function to report its current status to the service control manager.
66 *
67 * service_type
68 *	The type of service. This member can be one of the following values.
69 *
70 *      SERVICE_FILE_SYSTEM_DRIVER
71 *      SERVICE_KERNEL_DRIVER
72 *      SERVICE_WIN32_OWN_PROCESS
73 *      SERVICE_WIN32_SHARE_PROCESS
74 *
75 * If the service type is either SERVICE_WIN32_OWN_PROCESS or
76 * SERVICE_WIN32_SHARE_PROCESS, and the service is running in
77 * the context of the LocalSystem account, the following type
78 * may also be specified to indicate that the service can
79 * interact with the desktop.
80 *
81 *      SERVICE_INTERACTIVE_PROCESS
82 *
83 * cur_state
84 *	The current state of the service. This member can be one of the
85 *	following values.
86 *
87 *      SERVICE_CONTINUE_PENDING
88 *      SERVICE_PAUSE_PENDING
89 *      SERVICE_PAUSED
90 *      SERVICE_RUNNING
91 *      SERVICE_START_PENDING
92 *      SERVICE_STOP_PENDING
93 *      SERVICE_STOPPED
94 *
95 * ctrl_accepted
96 *	The control codes that the service will accept and process in its
97 *	handler function (see Handler and HandlerEx). A user interface
98 *	process can control a service by specifying a control command in
99 *	the ControlService function. By default, all services accept the
100 *	SERVICE_CONTROL_INTERROGATE value. The following are the control
101 *	codes.
102 *
103 *      SERVICE_ACCEPT_STOP
104 *      SERVICE_ACCEPT_PAUSE_CONTINUE
105 *      SERVICE_ACCEPT_SHUTDOWN
106 *      SERVICE_ACCEPT_PARAMCHANGE
107 *      SERVICE_ACCEPT_NETBINDCHANGE
108 *
109 * w32_exitcode
110 *  An error code that the service uses to report an error that occurs when
111 *  it is starting or stopping. To return an error code specific to the
112 *  service, the service must set this value to ERROR_SERVICE_SPECIFIC_ERROR
113 *  to indicate that the dwServiceSpecificExitCode member contains the error
114 *  code. The service should set this value to NO_ERROR when it is running
115 *  and on normal termination.
116 *
117 * svc_specified_exitcode
118 *  A service-specific error code that the service returns when an error
119 *  occurs while the service is starting or stopping. This value is ignored
120 *  unless the w32_exitcode member is set to ERROR_SERVICE_SPECIFIC_ERROR.
121 *
122 * check_point
123 *  A value that the service increments periodically to report its progress
124 *  during a lengthy start, stop, pause, or continue operation. For example,
125 *  the service should increment this value as it completes each step of its
126 *  initialization when it is starting up. The user interface program that
127 *  invoked the operation on the service uses this value to track the progress
128 *  of the service during a lengthy operation. This value is not valid and
129 *  should be zero when the service does not have a start, stop, pause, or
130 *  continue operation pending.
131 *
132 * wait_hint
133 *  An estimate of the amount of time, in milliseconds, that the service
134 *  expects a pending start, stop, pause, or continue operation to take
135 *  before the service makes its next call to the SetServiceStatus
136 *  function with either an incremented check_point value or a change in
137 *  dwCurrentState. If the amount of time specified by wait_hint passes,
138 *  and check_point has not been incremented, or cur_state has not changed,
139 *  the service control manager or service control program can assume that
140 *  an error has occurred and the service should be stopped.
141 */
142struct svc_status {
143	DWORD service_type;
144	DWORD cur_state;
145	DWORD ctrl_accepted;
146	DWORD w32_exitcode;
147	DWORD svc_specified_exitcode;
148	DWORD check_point;
149	DWORD wait_hint;
150};
151typedef struct svc_status svc_status_t;
152
153struct svc_enum_status {
154	DWORD svc_name;		/* offset within response buffer */
155	DWORD display_name;	/* offset within response buffer */
156	svc_status_t svc_status;
157};
158typedef struct svc_enum_status svc_enum_status_t;
159
160struct svc_config {
161	DWORD  service_type;
162	DWORD  start_type;
163	DWORD  error_control;
164	LPTSTR binary_pathname;
165	LPTSTR loadorder_group;
166	DWORD  tag_id;
167	LPTSTR dependencies;
168	LPTSTR service_startname;
169	LPTSTR display_name;
170};
171typedef struct svc_config svc_config_t;
172
173
174/*
175 ***********************************************************************
176 * Close
177 ***********************************************************************
178 */
179OPERATION(SVCCTL_OPNUM_Close)
180struct svcctl_Close {
181	IN		svcctl_handle_t handle;
182	OUT		svcctl_handle_t result_handle;
183	OUT		DWORD status;
184};
185
186
187/*
188 ***********************************************************************
189 * OpenManager
190 ***********************************************************************
191 */
192OPERATION(SVCCTL_OPNUM_OpenManager)
193struct svcctl_OpenManager {
194	IN		LPTSTR machine_name;
195	IN		LPTSTR database_name;
196	IN		DWORD desired_access;
197	OUT		svcctl_handle_t handle;
198	OUT		DWORD status;
199};
200
201
202/*
203 ***********************************************************************
204 * OpenService
205 ***********************************************************************
206 */
207OPERATION(SVCCTL_OPNUM_OpenService)
208struct svcctl_OpenService {
209	IN		svcctl_handle_t manager_handle;
210	IN REFERENCE	LPTSTR service_name;
211	IN		DWORD desired_access;
212	OUT		svcctl_handle_t service_handle;
213	OUT		DWORD status;
214};
215
216
217/*
218 ***********************************************************************
219 * QueryServiceStatus
220 ***********************************************************************
221 */
222OPERATION(SVCCTL_OPNUM_QueryServiceStatus)
223struct svcctl_QueryServiceStatus {
224	IN		svcctl_handle_t service_handle;
225	OUT		svc_status_t service_status;
226	OUT		DWORD status;
227};
228
229/*
230 ***********************************************************************
231 * EnumServicesStatus
232 ***********************************************************************
233 */
234OPERATION(SVCCTL_OPNUM_EnumServicesStatus)
235struct svcctl_EnumServicesStatus {
236	IN		svcctl_handle_t manager_handle;
237	IN		DWORD svc_type;
238	IN		DWORD svc_state;
239	INOUT		DWORD buf_size;
240	IN		DWORD unknown;
241	OUT		BYTE services[1024];
242	OUT		DWORD bytes_needed;
243	OUT		DWORD svc_num;
244	OUT		DWORD resume_handle;
245	OUT		DWORD status;
246};
247
248/*
249 ***********************************************************************
250 * QueryServiceConfig
251 ***********************************************************************
252 */
253OPERATION(SVCCTL_OPNUM_QueryServiceConfig)
254struct svcctl_QueryServiceConfig {
255	IN		svcctl_handle_t service_handle;
256	IN		DWORD buf_size;
257	OUT		svc_config_t service_cfg;
258	OUT		DWORD cfg_bytes;
259	OUT		DWORD status;
260};
261
262/*
263 ***********************************************************************
264 * The SVCCTL interface definition.
265 ***********************************************************************
266 */
267INTERFACE(0)
268union svcctl_interface {
269	CASE(SVCCTL_OPNUM_Close)
270		struct svcctl_Close			SvcClose;
271	CASE(SVCCTL_OPNUM_OpenManager)
272		struct svcctl_OpenManager		SvcOpenManager;
273	CASE(SVCCTL_OPNUM_OpenService)
274		struct svcctl_OpenService		SvcOpenService;
275	CASE(SVCCTL_OPNUM_QueryServiceStatus)
276		struct svcctl_QueryServiceStatus	SvcQueryServiceStatus;
277	CASE(SVCCTL_OPNUM_EnumServicesStatus)
278		struct svcctl_EnumServicesStatus	SvcEnumServicesStatus;
279	CASE(SVCCTL_OPNUM_QueryServiceConfig)
280		struct svcctl_QueryServiceConfig	SvcQueryServiceConfig;
281};
282
283typedef union svcctl_interface	svcctl_interface_t;
284EXTERNTYPEINFO(svcctl_interface)
285
286
287#endif /* _MLSVC_SVCCTL_NDL_ */
288