Source file src/cmd/vendor/golang.org/x/sys/windows/service.go

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build windows
     6  // +build windows
     7  
     8  package windows
     9  
    10  const (
    11  	SC_MANAGER_CONNECT            = 1
    12  	SC_MANAGER_CREATE_SERVICE     = 2
    13  	SC_MANAGER_ENUMERATE_SERVICE  = 4
    14  	SC_MANAGER_LOCK               = 8
    15  	SC_MANAGER_QUERY_LOCK_STATUS  = 16
    16  	SC_MANAGER_MODIFY_BOOT_CONFIG = 32
    17  	SC_MANAGER_ALL_ACCESS         = 0xf003f
    18  )
    19  
    20  const (
    21  	SERVICE_KERNEL_DRIVER       = 1
    22  	SERVICE_FILE_SYSTEM_DRIVER  = 2
    23  	SERVICE_ADAPTER             = 4
    24  	SERVICE_RECOGNIZER_DRIVER   = 8
    25  	SERVICE_WIN32_OWN_PROCESS   = 16
    26  	SERVICE_WIN32_SHARE_PROCESS = 32
    27  	SERVICE_WIN32               = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS
    28  	SERVICE_INTERACTIVE_PROCESS = 256
    29  	SERVICE_DRIVER              = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER
    30  	SERVICE_TYPE_ALL            = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS
    31  
    32  	SERVICE_BOOT_START   = 0
    33  	SERVICE_SYSTEM_START = 1
    34  	SERVICE_AUTO_START   = 2
    35  	SERVICE_DEMAND_START = 3
    36  	SERVICE_DISABLED     = 4
    37  
    38  	SERVICE_ERROR_IGNORE   = 0
    39  	SERVICE_ERROR_NORMAL   = 1
    40  	SERVICE_ERROR_SEVERE   = 2
    41  	SERVICE_ERROR_CRITICAL = 3
    42  
    43  	SC_STATUS_PROCESS_INFO = 0
    44  
    45  	SC_ACTION_NONE        = 0
    46  	SC_ACTION_RESTART     = 1
    47  	SC_ACTION_REBOOT      = 2
    48  	SC_ACTION_RUN_COMMAND = 3
    49  
    50  	SERVICE_STOPPED          = 1
    51  	SERVICE_START_PENDING    = 2
    52  	SERVICE_STOP_PENDING     = 3
    53  	SERVICE_RUNNING          = 4
    54  	SERVICE_CONTINUE_PENDING = 5
    55  	SERVICE_PAUSE_PENDING    = 6
    56  	SERVICE_PAUSED           = 7
    57  	SERVICE_NO_CHANGE        = 0xffffffff
    58  
    59  	SERVICE_ACCEPT_STOP                  = 1
    60  	SERVICE_ACCEPT_PAUSE_CONTINUE        = 2
    61  	SERVICE_ACCEPT_SHUTDOWN              = 4
    62  	SERVICE_ACCEPT_PARAMCHANGE           = 8
    63  	SERVICE_ACCEPT_NETBINDCHANGE         = 16
    64  	SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 32
    65  	SERVICE_ACCEPT_POWEREVENT            = 64
    66  	SERVICE_ACCEPT_SESSIONCHANGE         = 128
    67  	SERVICE_ACCEPT_PRESHUTDOWN           = 256
    68  
    69  	SERVICE_CONTROL_STOP                  = 1
    70  	SERVICE_CONTROL_PAUSE                 = 2
    71  	SERVICE_CONTROL_CONTINUE              = 3
    72  	SERVICE_CONTROL_INTERROGATE           = 4
    73  	SERVICE_CONTROL_SHUTDOWN              = 5
    74  	SERVICE_CONTROL_PARAMCHANGE           = 6
    75  	SERVICE_CONTROL_NETBINDADD            = 7
    76  	SERVICE_CONTROL_NETBINDREMOVE         = 8
    77  	SERVICE_CONTROL_NETBINDENABLE         = 9
    78  	SERVICE_CONTROL_NETBINDDISABLE        = 10
    79  	SERVICE_CONTROL_DEVICEEVENT           = 11
    80  	SERVICE_CONTROL_HARDWAREPROFILECHANGE = 12
    81  	SERVICE_CONTROL_POWEREVENT            = 13
    82  	SERVICE_CONTROL_SESSIONCHANGE         = 14
    83  	SERVICE_CONTROL_PRESHUTDOWN           = 15
    84  
    85  	SERVICE_ACTIVE    = 1
    86  	SERVICE_INACTIVE  = 2
    87  	SERVICE_STATE_ALL = 3
    88  
    89  	SERVICE_QUERY_CONFIG         = 1
    90  	SERVICE_CHANGE_CONFIG        = 2
    91  	SERVICE_QUERY_STATUS         = 4
    92  	SERVICE_ENUMERATE_DEPENDENTS = 8
    93  	SERVICE_START                = 16
    94  	SERVICE_STOP                 = 32
    95  	SERVICE_PAUSE_CONTINUE       = 64
    96  	SERVICE_INTERROGATE          = 128
    97  	SERVICE_USER_DEFINED_CONTROL = 256
    98  	SERVICE_ALL_ACCESS           = STANDARD_RIGHTS_REQUIRED | SERVICE_QUERY_CONFIG | SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS | SERVICE_ENUMERATE_DEPENDENTS | SERVICE_START | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_INTERROGATE | SERVICE_USER_DEFINED_CONTROL
    99  
   100  	SERVICE_RUNS_IN_SYSTEM_PROCESS = 1
   101  
   102  	SERVICE_CONFIG_DESCRIPTION              = 1
   103  	SERVICE_CONFIG_FAILURE_ACTIONS          = 2
   104  	SERVICE_CONFIG_DELAYED_AUTO_START_INFO  = 3
   105  	SERVICE_CONFIG_FAILURE_ACTIONS_FLAG     = 4
   106  	SERVICE_CONFIG_SERVICE_SID_INFO         = 5
   107  	SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6
   108  	SERVICE_CONFIG_PRESHUTDOWN_INFO         = 7
   109  	SERVICE_CONFIG_TRIGGER_INFO             = 8
   110  	SERVICE_CONFIG_PREFERRED_NODE           = 9
   111  	SERVICE_CONFIG_LAUNCH_PROTECTED         = 12
   112  
   113  	SERVICE_SID_TYPE_NONE         = 0
   114  	SERVICE_SID_TYPE_UNRESTRICTED = 1
   115  	SERVICE_SID_TYPE_RESTRICTED   = 2 | SERVICE_SID_TYPE_UNRESTRICTED
   116  
   117  	SC_ENUM_PROCESS_INFO = 0
   118  
   119  	SERVICE_NOTIFY_STATUS_CHANGE    = 2
   120  	SERVICE_NOTIFY_STOPPED          = 0x00000001
   121  	SERVICE_NOTIFY_START_PENDING    = 0x00000002
   122  	SERVICE_NOTIFY_STOP_PENDING     = 0x00000004
   123  	SERVICE_NOTIFY_RUNNING          = 0x00000008
   124  	SERVICE_NOTIFY_CONTINUE_PENDING = 0x00000010
   125  	SERVICE_NOTIFY_PAUSE_PENDING    = 0x00000020
   126  	SERVICE_NOTIFY_PAUSED           = 0x00000040
   127  	SERVICE_NOTIFY_CREATED          = 0x00000080
   128  	SERVICE_NOTIFY_DELETED          = 0x00000100
   129  	SERVICE_NOTIFY_DELETE_PENDING   = 0x00000200
   130  
   131  	SC_EVENT_DATABASE_CHANGE = 0
   132  	SC_EVENT_PROPERTY_CHANGE = 1
   133  	SC_EVENT_STATUS_CHANGE   = 2
   134  
   135  	SERVICE_START_REASON_DEMAND             = 0x00000001
   136  	SERVICE_START_REASON_AUTO               = 0x00000002
   137  	SERVICE_START_REASON_TRIGGER            = 0x00000004
   138  	SERVICE_START_REASON_RESTART_ON_FAILURE = 0x00000008
   139  	SERVICE_START_REASON_DELAYEDAUTO        = 0x00000010
   140  
   141  	SERVICE_DYNAMIC_INFORMATION_LEVEL_START_REASON = 1
   142  )
   143  
   144  type SERVICE_STATUS struct {
   145  	ServiceType             uint32
   146  	CurrentState            uint32
   147  	ControlsAccepted        uint32
   148  	Win32ExitCode           uint32
   149  	ServiceSpecificExitCode uint32
   150  	CheckPoint              uint32
   151  	WaitHint                uint32
   152  }
   153  
   154  type SERVICE_TABLE_ENTRY struct {
   155  	ServiceName *uint16
   156  	ServiceProc uintptr
   157  }
   158  
   159  type QUERY_SERVICE_CONFIG struct {
   160  	ServiceType      uint32
   161  	StartType        uint32
   162  	ErrorControl     uint32
   163  	BinaryPathName   *uint16
   164  	LoadOrderGroup   *uint16
   165  	TagId            uint32
   166  	Dependencies     *uint16
   167  	ServiceStartName *uint16
   168  	DisplayName      *uint16
   169  }
   170  
   171  type SERVICE_DESCRIPTION struct {
   172  	Description *uint16
   173  }
   174  
   175  type SERVICE_DELAYED_AUTO_START_INFO struct {
   176  	IsDelayedAutoStartUp uint32
   177  }
   178  
   179  type SERVICE_STATUS_PROCESS struct {
   180  	ServiceType             uint32
   181  	CurrentState            uint32
   182  	ControlsAccepted        uint32
   183  	Win32ExitCode           uint32
   184  	ServiceSpecificExitCode uint32
   185  	CheckPoint              uint32
   186  	WaitHint                uint32
   187  	ProcessId               uint32
   188  	ServiceFlags            uint32
   189  }
   190  
   191  type ENUM_SERVICE_STATUS_PROCESS struct {
   192  	ServiceName          *uint16
   193  	DisplayName          *uint16
   194  	ServiceStatusProcess SERVICE_STATUS_PROCESS
   195  }
   196  
   197  type SERVICE_NOTIFY struct {
   198  	Version               uint32
   199  	NotifyCallback        uintptr
   200  	Context               uintptr
   201  	NotificationStatus    uint32
   202  	ServiceStatus         SERVICE_STATUS_PROCESS
   203  	NotificationTriggered uint32
   204  	ServiceNames          *uint16
   205  }
   206  
   207  type SERVICE_FAILURE_ACTIONS struct {
   208  	ResetPeriod  uint32
   209  	RebootMsg    *uint16
   210  	Command      *uint16
   211  	ActionsCount uint32
   212  	Actions      *SC_ACTION
   213  }
   214  
   215  type SC_ACTION struct {
   216  	Type  uint32
   217  	Delay uint32
   218  }
   219  
   220  type QUERY_SERVICE_LOCK_STATUS struct {
   221  	IsLocked     uint32
   222  	LockOwner    *uint16
   223  	LockDuration uint32
   224  }
   225  
   226  //sys	OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenSCManagerW
   227  //sys	CloseServiceHandle(handle Handle) (err error) = advapi32.CloseServiceHandle
   228  //sys	CreateService(mgr Handle, serviceName *uint16, displayName *uint16, access uint32, srvType uint32, startType uint32, errCtl uint32, pathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16) (handle Handle, err error) [failretval==0] = advapi32.CreateServiceW
   229  //sys	OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenServiceW
   230  //sys	DeleteService(service Handle) (err error) = advapi32.DeleteService
   231  //sys	StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) = advapi32.StartServiceW
   232  //sys	QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) = advapi32.QueryServiceStatus
   233  //sys	QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceLockStatusW
   234  //sys	ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) = advapi32.ControlService
   235  //sys	StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) = advapi32.StartServiceCtrlDispatcherW
   236  //sys	SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) = advapi32.SetServiceStatus
   237  //sys	ChangeServiceConfig(service Handle, serviceType uint32, startType uint32, errorControl uint32, binaryPathName *uint16, loadOrderGroup *uint16, tagId *uint32, dependencies *uint16, serviceStartName *uint16, password *uint16, displayName *uint16) (err error) = advapi32.ChangeServiceConfigW
   238  //sys	QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfigW
   239  //sys	ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) = advapi32.ChangeServiceConfig2W
   240  //sys	QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfig2W
   241  //sys	EnumServicesStatusEx(mgr Handle, infoLevel uint32, serviceType uint32, serviceState uint32, services *byte, bufSize uint32, bytesNeeded *uint32, servicesReturned *uint32, resumeHandle *uint32, groupName *uint16) (err error) = advapi32.EnumServicesStatusExW
   242  //sys	QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceStatusEx
   243  //sys	NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) = advapi32.NotifyServiceStatusChangeW
   244  //sys	SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) = sechost.SubscribeServiceChangeNotifications?
   245  //sys	UnsubscribeServiceChangeNotifications(subscription uintptr) = sechost.UnsubscribeServiceChangeNotifications?
   246  //sys	RegisterServiceCtrlHandlerEx(serviceName *uint16, handlerProc uintptr, context uintptr) (handle Handle, err error) = advapi32.RegisterServiceCtrlHandlerExW
   247  //sys	QueryServiceDynamicInformation(service Handle, infoLevel uint32, dynamicInfo unsafe.Pointer) (err error) = advapi32.QueryServiceDynamicInformation?
   248  

View as plain text