xref: /titanic_41/usr/src/uts/common/smbsrv/winsvc.h (revision 34f9b3eef6fdadbda0a846aa4d68691ac40eace5)
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 
26 #ifndef _SMBSRV_WINSVC_H
27 #define	_SMBSRV_WINSVC_H
28 
29 /*
30  * NT Service Control interface definition for the Service Control
31  * Manager (SCM).
32  */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * Service types (Bit Mask).
40  *
41  * SERVICE_WIN32_OWN_PROCESS	The service runs in its own process.
42  * SERVICE_WIN32_SHARE_PROCESS	The service shares a process with other
43  *                              services.
44  */
45 #define	SERVICE_KERNEL_DRIVER		0x00000001
46 #define	SERVICE_FILE_SYSTEM_DRIVER	0x00000002
47 #define	SERVICE_ADAPTER			0x00000004
48 #define	SERVICE_RECOGNIZER_DRIVER	0x00000008
49 #define	SERVICE_WIN32_OWN_PROCESS	0x00000010
50 #define	SERVICE_WIN32_SHARE_PROCESS	0x00000020
51 #define	SERVICE_INTERACTIVE_PROCESS	0x00000100
52 
53 #define	SERVICE_DRIVER (SERVICE_KERNEL_DRIVER				\
54 	    | SERVICE_FILE_SYSTEM_DRIVER				\
55 	    | SERVICE_RECOGNIZER_DRIVER)
56 
57 #define	SERVICE_WIN32 (SERVICE_WIN32_OWN_PROCESS			\
58 	    | SERVICE_WIN32_SHARE_PROCESS)
59 
60 #define	SERVICE_TYPE_ALL (SERVICE_WIN32					\
61 	    | SERVICE_ADAPTER						\
62 	    | SERVICE_DRIVER						\
63 	    | SERVICE_INTERACTIVE_PROCESS)
64 
65 /*
66  * Start type.
67  */
68 #define	SERVICE_BOOT_START		0x00000000
69 #define	SERVICE_SYSTEM_START		0x00000001
70 #define	SERVICE_AUTO_START		0x00000002
71 #define	SERVICE_DEMAND_START		0x00000003
72 #define	SERVICE_DISABLED		0x00000004
73 
74 /*
75  * Error control type.
76  */
77 #define	SERVICE_ERROR_IGNORE		0x00000000
78 #define	SERVICE_ERROR_NORMAL		0x00000001
79 #define	SERVICE_ERROR_SEVERE		0x00000002
80 #define	SERVICE_ERROR_CRITICAL		0x00000003
81 
82 /*
83  * Value to indicate no change to an optional parameter.
84  */
85 #define	SERVICE_NO_CHANGE		0xffffffff
86 
87 /*
88  * Service State - for Enum Requests (Bit Mask).
89  */
90 #define	SERVICE_ACTIVE			0x00000001
91 #define	SERVICE_INACTIVE		0x00000002
92 #define	SERVICE_STATE_ALL		(SERVICE_ACTIVE | SERVICE_INACTIVE)
93 
94 /*
95  * Controls
96  */
97 #define	SERVICE_CONTROL_STOP		0x00000001
98 #define	SERVICE_CONTROL_PAUSE		0x00000002
99 #define	SERVICE_CONTROL_CONTINUE	0x00000003
100 #define	SERVICE_CONTROL_INTERROGATE	0x00000004
101 #define	SERVICE_CONTROL_SHUTDOWN	0x00000005
102 #define	SERVICE_CONTROL_PARAMCHANGE	0x00000006
103 #define	SERVICE_CONTROL_NETBINDADD	0x00000007
104 #define	SERVICE_CONTROL_NETBINDREMOVE	0x00000008
105 #define	SERVICE_CONTROL_NETBINDENABLE	0x00000009
106 #define	SERVICE_CONTROL_NETBINDDISABLE	0x0000000A
107 
108 /*
109  * Service State -- for CurrentState
110  */
111 #define	SERVICE_STOPPED			0x00000001
112 #define	SERVICE_START_PENDING		0x00000002
113 #define	SERVICE_STOP_PENDING		0x00000003
114 #define	SERVICE_RUNNING			0x00000004
115 #define	SERVICE_CONTINUE_PENDING	0x00000005
116 #define	SERVICE_PAUSE_PENDING		0x00000006
117 #define	SERVICE_PAUSED			0x00000007
118 
119 /*
120  * Controls Accepted  (Bit Mask)
121  *
122  * SERVICE_ACCEPT_NETBINDCHANGE
123  * Windows 2000/XP: The service is a network component that
124  * can accept changes in its binding without being stopped and restarted.
125  * This control code allows the service to receive SERVICE_CONTROL_NETBINDADD,
126  * SERVICE_CONTROL_NETBINDREMOVE, SERVICE_CONTROL_NETBINDENABLE, and
127  * SERVICE_CONTROL_NETBINDDISABLE notifications.
128  *
129  * SERVICE_ACCEPT_PARAMCHANGE
130  * Windows 2000/XP: The service can reread its startup parameters without
131  * being stopped and restarted. This control code allows the service to
132  * receive SERVICE_CONTROL_PARAMCHANGE notifications.
133  *
134  * SERVICE_ACCEPT_PAUSE_CONTINUE
135  * The service can be paused and continued. This control code allows the
136  * service to receive SERVICE_CONTROL_PAUSE and SERVICE_CONTROL_CONTINUE
137  * notifications.
138  *
139  * SERVICE_ACCEPT_SHUTDOWN
140  * The service is notified when system shutdown occurs. This control code
141  * allows the service to receive SERVICE_CONTROL_SHUTDOWN notifications.
142  * Note that ControlService cannot send this notification; only the system
143  * can send it.
144  *
145  * SERVICE_ACCEPT_STOP
146  * The service can be stopped. This control code allows the service to
147  * receive SERVICE_CONTROL_STOP notifications.
148  */
149 #define	SERVICE_ACCEPT_STOP		0x00000001
150 #define	SERVICE_ACCEPT_PAUSE_CONTINUE	0x00000002
151 #define	SERVICE_ACCEPT_SHUTDOWN		0x00000004
152 #define	SERVICE_ACCEPT_PARAMCHANGE	0x00000008
153 #define	SERVICE_ACCEPT_NETBINDCHANGE	0x00000010
154 
155 /*
156  * Service Control Manager object specific access types.
157  */
158 #define	SC_MANAGER_CONNECT		0x0001
159 #define	SC_MANAGER_CREATE_SERVICE	0x0002
160 #define	SC_MANAGER_ENUMERATE_SERVICE	0x0004
161 #define	SC_MANAGER_LOCK			0x0008
162 #define	SC_MANAGER_QUERY_LOCK_STATUS	0x0010
163 #define	SC_MANAGER_MODIFY_BOOT_CONFIG	0x0020
164 
165 #define	SC_MANAGER_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED		       \
166 	    | SC_MANAGER_CONNECT				       \
167 	    | SC_MANAGER_CREATE_SERVICE				       \
168 	    | SC_MANAGER_ENUMERATE_SERVICE			       \
169 	    | SC_MANAGER_LOCK					       \
170 	    | SC_MANAGER_QUERY_LOCK_STATUS			       \
171 	    | SC_MANAGER_MODIFY_BOOT_CONFIG)
172 
173 /*
174  * Service object specific access type.
175  */
176 #define	SERVICE_QUERY_CONFIG		0x0001
177 #define	SERVICE_CHANGE_CONFIG		0x0002
178 #define	SERVICE_QUERY_STATUS		0x0004
179 #define	SERVICE_ENUMERATE_DEPENDENTS	0x0008
180 #define	SERVICE_START			0x0010
181 #define	SERVICE_STOP			0x0020
182 #define	SERVICE_PAUSE_CONTINUE		0x0040
183 #define	SERVICE_INTERROGATE		0x0080
184 #define	SERVICE_USER_DEFINED_CONTROL	0x0100
185 
186 #define	SERVICE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED		       \
187 	    | SERVICE_QUERY_CONFIG				       \
188 	    | SERVICE_CHANGE_CONFIG				       \
189 	    | SERVICE_QUERY_STATUS				       \
190 	    | SERVICE_ENUMERATE_DEPENDENTS			       \
191 	    | SERVICE_START					       \
192 	    | SERVICE_STOP					       \
193 	    | SERVICE_PAUSE_CONTINUE				       \
194 	    | SERVICE_INTERROGATE				       \
195 	    | SERVICE_USER_DEFINED_CONTROL)
196 
197 /*
198  * Info levels for ChangeServiceConfig2 and QueryServiceConfig2.
199  */
200 #define	SERVICE_CONFIG_DESCRIPTION		1
201 #define	SERVICE_CONFIG_FAILURE_ACTIONS		2
202 #define	SERVICE_CONFIG_DELAYED_AUTO_START_INFO	3
203 #define	SERVICE_CONFIG_FAILURE_ACTIONS_FLAG	4
204 #define	SERVICE_CONFIG_SERVICE_SID_INFO		5
205 #define	SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO	6
206 #define	SERVICE_CONFIG_PRESHUTDOWN_INFO		7
207 #define	SERVICE_CONFIG_TRIGGER_INFO		8
208 #define	SERVICE_CONFIG_PREFERRED_NODE		9
209 
210 /*
211  * Actions to take on service failure (SC_ACTION_TYPE).
212  */
213 #define	SC_ACTION_NONE			0
214 #define	SC_ACTION_RESTART		1
215 #define	SC_ACTION_REBOOT		2
216 #define	SC_ACTION_RUN_COMMAND		3
217 
218 /*
219  * Information level for QueryServiceStatusEx
220  */
221 #define	SC_STATUS_PROCESS_INFO		0
222 
223 #ifdef __cplusplus
224 }
225 #endif
226 
227 #endif /* _SMBSRV_WINSVC_H */
228