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 2008 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/* 30 * NT Service Control Services (SVCCTL) RPC interface definition. 31 * This interface provides remote access to add, remove, start and 32 * stop services. 33 */ 34 35#include "ndrtypes.ndl" 36 37/* Windows NT */ 38#define SVCCTL_OPNUM_Close 0x00 39#define SVCCTL_OPNUM_ControlService 0x01 40#define SVCCTL_OPNUM_DeleteService 0x02 41#define SVCCTL_OPNUM_LockServiceDatabase 0x03 42#define SVCCTL_OPNUM_QueryServiceSecurity 0x04 43#define SVCCTL_OPNUM_SetServiceSecurity 0x05 44#define SVCCTL_OPNUM_QueryServiceStatus 0x06 45#define SVCCTL_OPNUM_SetServiceStatus 0x07 46#define SVCCTL_OPNUM_UnlockServiceDatabase 0x08 47#define SVCCTL_OPNUM_NotifyBootConfigStatus 0x09 48#define SVCCTL_OPNUM_SetServiceBits 0x0a 49#define SVCCTL_OPNUM_ChangeServiceConfig 0x0b 50#define SVCCTL_OPNUM_CreateService 0x0c 51#define SVCCTL_OPNUM_EnumDependentServices 0x0d 52#define SVCCTL_OPNUM_EnumServicesStatus 0x0E 53#define SVCCTL_OPNUM_OpenManager 0x0F 54#define SVCCTL_OPNUM_OpenService 0x10 55#define SVCCTL_OPNUM_QueryServiceConfig 0x11 56#define SVCCTL_OPNUM_QueryServiceLockStatus 0x12 57#define SVCCTL_OPNUM_StartService 0x13 58#define SVCCTL_OPNUM_GetServiceDisplayNameW 0x14 59#define SVCCTL_OPNUM_GetServiceKeyNameW 0x15 60#define SVCCTL_OPNUM_SetServiceBitsA 0x16 61#define SVCCTL_OPNUM_ChangeServiceConfigA 0x17 62#define SVCCTL_OPNUM_CreateServiceA 0x18 63#define SVCCTL_OPNUM_EnumDependentServicesA 0x19 64#define SVCCTL_OPNUM_EnumServiceStatusA 0x1a 65#define SVCCTL_OPNUM_OpenSCManagerA 0x1b 66#define SVCCTL_OPNUM_OpenServiceA 0x1c 67#define SVCCTL_OPNUM_QueryServiceConfigA 0x1d 68#define SVCCTL_OPNUM_QueryServiceLockStatusA 0x1e 69#define SVCCTL_OPNUM_StartServiceA 0x1f 70#define SVCCTL_OPNUM_GetServiceDisplayNameA 0x20 71#define SVCCTL_OPNUM_GetServiceKeyNameA 0x21 72#define SVCCTL_OPNUM_GetCurrentGroupStateW 0x22 73#define SVCCTL_OPNUM_EnumServiceGroupW 0x23 74#define SVCCTL_OPNUM_ChangeServiceConfig2A 0x24 75#define SVCCTL_OPNUM_ChangeServiceConfig2W 0x25 76#define SVCCTL_OPNUM_QueryServiceConfig2A 0x26 77 78/* Windows 2000 */ 79#define SVCCTL_OPNUM_QueryServiceConfig2W 0x27 80#define SVCCTL_OPNUM_QueryServiceStatusEx 0x28 81#define SVCCTL_OPNUM_EnumServiceStatusExA 0x29 82#define SVCCTL_OPNUM_EnumServiceStatusExW 0x2a 83 84/* Windows XP and Windows Server 2003 */ 85#define SVCCTL_OPNUM_SendTSMessage 0x2b 86 87/* Windows Vista */ 88#define SVCCTL_OPNUM_CreateServiceWOW64A 0x2c 89#define SVCCTL_OPNUM_CreateServiceWOW64W 0x2d 90#define SVCCTL_OPNUM_QueryServiceTagInfo 0x2e 91#define SVCCTL_OPNUM_NotifyServiceStatusChange 0x2f 92#define SVCCTL_OPNUM_GetNotifyResult 0x30 93#define SVCCTL_OPNUM_CloseNotifyHandle 0x31 94#define SVCCTL_OPNUM_ControlServiceExA 0x32 95#define SVCCTL_OPNUM_ControlServiceExW 0x33 96#define SVCCTL_OPNUM_SendPnPMessage 0x34 97#define SVCCTL_OPNUM_ValidatePnPService 0x35 98#define SVCCTL_OPNUM_OpenServiceStatusHandle 0x36 99 100/* 101 * Standard opaque 20 byte RPC handle. 102 */ 103struct svcctl_handle { 104 DWORD hand1; 105 DWORD hand2; 106 WORD hand3[2]; 107 BYTE hand4[8]; 108}; 109 110typedef struct svcctl_handle svcctl_handle_t; 111 112/* 113 * The svc_status (SERVICE_STATUS) structure contains information about a 114 * service. The ControlService, EnumDependentServices, EnumServicesStatus, 115 * and QueryServiceStatus functions use this structure to return information 116 * about a service. A service uses this structure in the SetServiceStatus 117 * function to report its current status to the service control manager. 118 * 119 * service_type 120 * The type of service. This member can be one of the following values. 121 * 122 * SERVICE_FILE_SYSTEM_DRIVER 123 * SERVICE_KERNEL_DRIVER 124 * SERVICE_WIN32_OWN_PROCESS 125 * SERVICE_WIN32_SHARE_PROCESS 126 * 127 * If the service type is either SERVICE_WIN32_OWN_PROCESS or 128 * SERVICE_WIN32_SHARE_PROCESS, and the service is running in 129 * the context of the LocalSystem account, the following type 130 * may also be specified to indicate that the service can 131 * interact with the desktop. 132 * 133 * SERVICE_INTERACTIVE_PROCESS 134 * 135 * cur_state 136 * The current state of the service. This member can be one of the 137 * following values. 138 * 139 * SERVICE_CONTINUE_PENDING 140 * SERVICE_PAUSE_PENDING 141 * SERVICE_PAUSED 142 * SERVICE_RUNNING 143 * SERVICE_START_PENDING 144 * SERVICE_STOP_PENDING 145 * SERVICE_STOPPED 146 * 147 * ctrl_accepted 148 * The control codes that the service will accept and process in its 149 * handler function (see Handler and HandlerEx). A user interface 150 * process can control a service by specifying a control command in 151 * the ControlService function. By default, all services accept the 152 * SERVICE_CONTROL_INTERROGATE value. The following are the control 153 * codes. 154 * 155 * SERVICE_ACCEPT_STOP 156 * SERVICE_ACCEPT_PAUSE_CONTINUE 157 * SERVICE_ACCEPT_SHUTDOWN 158 * SERVICE_ACCEPT_PARAMCHANGE 159 * SERVICE_ACCEPT_NETBINDCHANGE 160 * 161 * w32_exitcode 162 * An error code that the service uses to report an error that occurs when 163 * it is starting or stopping. To return an error code specific to the 164 * service, the service must set this value to ERROR_SERVICE_SPECIFIC_ERROR 165 * to indicate that the dwServiceSpecificExitCode member contains the error 166 * code. The service should set this value to NO_ERROR when it is running 167 * and on normal termination. 168 * 169 * svc_specified_exitcode 170 * A service-specific error code that the service returns when an error 171 * occurs while the service is starting or stopping. This value is ignored 172 * unless the w32_exitcode member is set to ERROR_SERVICE_SPECIFIC_ERROR. 173 * 174 * check_point 175 * A value that the service increments periodically to report its progress 176 * during a lengthy start, stop, pause, or continue operation. For example, 177 * the service should increment this value as it completes each step of its 178 * initialization when it is starting up. The user interface program that 179 * invoked the operation on the service uses this value to track the progress 180 * of the service during a lengthy operation. This value is not valid and 181 * should be zero when the service does not have a start, stop, pause, or 182 * continue operation pending. 183 * 184 * wait_hint 185 * An estimate of the amount of time, in milliseconds, that the service 186 * expects a pending start, stop, pause, or continue operation to take 187 * before the service makes its next call to the SetServiceStatus 188 * function with either an incremented check_point value or a change in 189 * dwCurrentState. If the amount of time specified by wait_hint passes, 190 * and check_point has not been incremented, or cur_state has not changed, 191 * the service control manager or service control program can assume that 192 * an error has occurred and the service should be stopped. 193 */ 194struct svc_status { 195 DWORD service_type; 196 DWORD cur_state; 197 DWORD ctrl_accepted; 198 DWORD w32_exitcode; 199 DWORD svc_specified_exitcode; 200 DWORD check_point; 201 DWORD wait_hint; 202}; 203typedef struct svc_status svc_status_t; 204 205struct svc_enum_status { 206 DWORD svc_name; /* offset within response buffer */ 207 DWORD display_name; /* offset within response buffer */ 208 svc_status_t svc_status; 209}; 210typedef struct svc_enum_status svc_enum_status_t; 211 212struct svc_config { 213 DWORD service_type; 214 DWORD start_type; 215 DWORD error_control; 216 LPTSTR binary_pathname; 217 LPTSTR loadorder_group; 218 DWORD tag_id; 219 LPTSTR dependencies; 220 LPTSTR service_startname; 221 LPTSTR display_name; 222}; 223typedef struct svc_config svc_config_t; 224 225struct svc_failure_actions { 226 DWORD reset_period; 227 DWORD rebootmsg_offset; 228 DWORD command_offset; 229 DWORD actions; 230 DWORD actions_offset; 231}; 232typedef struct svc_failure_actions svc_failure_actions_t; 233 234struct svc_description { 235 DWORD desc; /* offset of description string */ 236}; 237typedef struct svc_description svc_description_t; 238 239/* 240 *********************************************************************** 241 * Close 242 *********************************************************************** 243 */ 244OPERATION(SVCCTL_OPNUM_Close) 245struct svcctl_Close { 246 IN svcctl_handle_t handle; 247 OUT svcctl_handle_t result_handle; 248 OUT DWORD status; 249}; 250 251 252/* 253 *********************************************************************** 254 * OpenManager 255 *********************************************************************** 256 */ 257OPERATION(SVCCTL_OPNUM_OpenManager) 258struct svcctl_OpenManager { 259 IN LPTSTR machine_name; 260 IN LPTSTR database_name; 261 IN DWORD desired_access; 262 OUT svcctl_handle_t handle; 263 OUT DWORD status; 264}; 265 266 267/* 268 *********************************************************************** 269 * OpenService 270 *********************************************************************** 271 */ 272OPERATION(SVCCTL_OPNUM_OpenService) 273struct svcctl_OpenService { 274 IN svcctl_handle_t manager_handle; 275 IN REFERENCE LPTSTR service_name; 276 IN DWORD desired_access; 277 OUT svcctl_handle_t service_handle; 278 OUT DWORD status; 279}; 280 281 282/* 283 *********************************************************************** 284 * QueryServiceStatus 285 *********************************************************************** 286 */ 287OPERATION(SVCCTL_OPNUM_QueryServiceStatus) 288struct svcctl_QueryServiceStatus { 289 IN svcctl_handle_t service_handle; 290 OUT svc_status_t service_status; 291 OUT DWORD status; 292}; 293 294/* 295 *********************************************************************** 296 * EnumServicesStatus 297 *********************************************************************** 298 */ 299OPERATION(SVCCTL_OPNUM_EnumServicesStatus) 300struct svcctl_EnumServicesStatus { 301 IN svcctl_handle_t manager_handle; 302 IN DWORD svc_type; 303 IN DWORD svc_state; 304 IN DWORD buf_size; 305 SIZE_IS(buf_size) 306 OUT REFERENCE LPBYTE services; 307 OUT DWORD bytes_needed; 308 OUT DWORD svc_num; 309 INOUT DWORD *resume_handle; 310 OUT DWORD status; 311}; 312 313/* 314 *********************************************************************** 315 * QueryServiceConfig 316 *********************************************************************** 317 */ 318OPERATION(SVCCTL_OPNUM_QueryServiceConfig) 319struct svcctl_QueryServiceConfig { 320 IN svcctl_handle_t service_handle; 321 IN DWORD buf_size; 322 OUT svc_config_t service_cfg; 323 OUT DWORD cfg_bytes; 324 OUT DWORD status; 325}; 326 327/* 328 *********************************************************************** 329 * GetServiceDisplayNameW 330 *********************************************************************** 331 */ 332OPERATION(SVCCTL_OPNUM_GetServiceDisplayNameW) 333struct svcctl_GetServiceDisplayNameW { 334 IN svcctl_handle_t manager_handle; 335 IN REFERENCE LPTSTR service_name; 336 OUT REFERENCE LPTSTR display_name; 337 INOUT DWORD buf_size; 338 OUT DWORD status; 339}; 340 341/* 342 *********************************************************************** 343 * GetServiceKeyNameW 344 *********************************************************************** 345 */ 346OPERATION(SVCCTL_OPNUM_GetServiceKeyNameW) 347struct svcctl_GetServiceKeyNameW { 348 IN svcctl_handle_t manager_handle; 349 IN REFERENCE LPTSTR service_name; 350 OUT REFERENCE LPTSTR key_name; 351 INOUT DWORD buf_size; 352 OUT DWORD status; 353}; 354 355/* 356 *********************************************************************** 357 * QueryServiceConfig2W 358 *********************************************************************** 359 */ 360OPERATION(SVCCTL_OPNUM_QueryServiceConfig2W) 361struct svcctl_QueryServiceConfig2W { 362 IN svcctl_handle_t service_handle; 363 IN DWORD info_level; 364 IN DWORD buf_size; 365 SIZE_IS(buf_size) 366 OUT REFERENCE LPBYTE buffer; 367 OUT DWORD bytes_needed; 368 OUT DWORD status; 369}; 370 371/* 372 *********************************************************************** 373 * The SVCCTL interface definition. 374 *********************************************************************** 375 */ 376INTERFACE(0) 377union svcctl_interface { 378 CASE(SVCCTL_OPNUM_Close) 379 struct svcctl_Close SvcClose; 380 CASE(SVCCTL_OPNUM_OpenManager) 381 struct svcctl_OpenManager SvcOpenManager; 382 CASE(SVCCTL_OPNUM_OpenService) 383 struct svcctl_OpenService SvcOpenService; 384 CASE(SVCCTL_OPNUM_QueryServiceStatus) 385 struct svcctl_QueryServiceStatus SvcQueryServiceStatus; 386 CASE(SVCCTL_OPNUM_EnumServicesStatus) 387 struct svcctl_EnumServicesStatus SvcEnumServicesStatus; 388 CASE(SVCCTL_OPNUM_QueryServiceConfig) 389 struct svcctl_QueryServiceConfig SvcQueryServiceConfig; 390 CASE(SVCCTL_OPNUM_GetServiceDisplayNameW) 391 struct svcctl_GetServiceDisplayNameW SvcGetServiceDisplayNameW; 392 CASE(SVCCTL_OPNUM_GetServiceKeyNameW) 393 struct svcctl_GetServiceKeyNameW SvcGetServiceKeyNameW; 394 CASE(SVCCTL_OPNUM_QueryServiceConfig2W) 395 struct svcctl_QueryServiceConfig2W SvcQueryServiceConfig2W; 396}; 397 398typedef union svcctl_interface svcctl_interface_t; 399EXTERNTYPEINFO(svcctl_interface) 400 401 402#endif /* _MLSVC_SVCCTL_NDL_ */ 403