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