Path: blob/main/vendor/golang.org/x/sys/windows/service.go
2880 views
// Copyright 2012 The Go Authors. All rights reserved.1// Use of this source code is governed by a BSD-style2// license that can be found in the LICENSE file.34//go:build windows56package windows78const (9SC_MANAGER_CONNECT = 110SC_MANAGER_CREATE_SERVICE = 211SC_MANAGER_ENUMERATE_SERVICE = 412SC_MANAGER_LOCK = 813SC_MANAGER_QUERY_LOCK_STATUS = 1614SC_MANAGER_MODIFY_BOOT_CONFIG = 3215SC_MANAGER_ALL_ACCESS = 0xf003f16)1718const (19SERVICE_KERNEL_DRIVER = 120SERVICE_FILE_SYSTEM_DRIVER = 221SERVICE_ADAPTER = 422SERVICE_RECOGNIZER_DRIVER = 823SERVICE_WIN32_OWN_PROCESS = 1624SERVICE_WIN32_SHARE_PROCESS = 3225SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS26SERVICE_INTERACTIVE_PROCESS = 25627SERVICE_DRIVER = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER28SERVICE_TYPE_ALL = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS2930SERVICE_BOOT_START = 031SERVICE_SYSTEM_START = 132SERVICE_AUTO_START = 233SERVICE_DEMAND_START = 334SERVICE_DISABLED = 43536SERVICE_ERROR_IGNORE = 037SERVICE_ERROR_NORMAL = 138SERVICE_ERROR_SEVERE = 239SERVICE_ERROR_CRITICAL = 34041SC_STATUS_PROCESS_INFO = 04243SC_ACTION_NONE = 044SC_ACTION_RESTART = 145SC_ACTION_REBOOT = 246SC_ACTION_RUN_COMMAND = 34748SERVICE_STOPPED = 149SERVICE_START_PENDING = 250SERVICE_STOP_PENDING = 351SERVICE_RUNNING = 452SERVICE_CONTINUE_PENDING = 553SERVICE_PAUSE_PENDING = 654SERVICE_PAUSED = 755SERVICE_NO_CHANGE = 0xffffffff5657SERVICE_ACCEPT_STOP = 158SERVICE_ACCEPT_PAUSE_CONTINUE = 259SERVICE_ACCEPT_SHUTDOWN = 460SERVICE_ACCEPT_PARAMCHANGE = 861SERVICE_ACCEPT_NETBINDCHANGE = 1662SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 3263SERVICE_ACCEPT_POWEREVENT = 6464SERVICE_ACCEPT_SESSIONCHANGE = 12865SERVICE_ACCEPT_PRESHUTDOWN = 2566667SERVICE_CONTROL_STOP = 168SERVICE_CONTROL_PAUSE = 269SERVICE_CONTROL_CONTINUE = 370SERVICE_CONTROL_INTERROGATE = 471SERVICE_CONTROL_SHUTDOWN = 572SERVICE_CONTROL_PARAMCHANGE = 673SERVICE_CONTROL_NETBINDADD = 774SERVICE_CONTROL_NETBINDREMOVE = 875SERVICE_CONTROL_NETBINDENABLE = 976SERVICE_CONTROL_NETBINDDISABLE = 1077SERVICE_CONTROL_DEVICEEVENT = 1178SERVICE_CONTROL_HARDWAREPROFILECHANGE = 1279SERVICE_CONTROL_POWEREVENT = 1380SERVICE_CONTROL_SESSIONCHANGE = 1481SERVICE_CONTROL_PRESHUTDOWN = 158283SERVICE_ACTIVE = 184SERVICE_INACTIVE = 285SERVICE_STATE_ALL = 38687SERVICE_QUERY_CONFIG = 188SERVICE_CHANGE_CONFIG = 289SERVICE_QUERY_STATUS = 490SERVICE_ENUMERATE_DEPENDENTS = 891SERVICE_START = 1692SERVICE_STOP = 3293SERVICE_PAUSE_CONTINUE = 6494SERVICE_INTERROGATE = 12895SERVICE_USER_DEFINED_CONTROL = 25696SERVICE_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_CONTROL9798SERVICE_RUNS_IN_SYSTEM_PROCESS = 199100SERVICE_CONFIG_DESCRIPTION = 1101SERVICE_CONFIG_FAILURE_ACTIONS = 2102SERVICE_CONFIG_DELAYED_AUTO_START_INFO = 3103SERVICE_CONFIG_FAILURE_ACTIONS_FLAG = 4104SERVICE_CONFIG_SERVICE_SID_INFO = 5105SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6106SERVICE_CONFIG_PRESHUTDOWN_INFO = 7107SERVICE_CONFIG_TRIGGER_INFO = 8108SERVICE_CONFIG_PREFERRED_NODE = 9109SERVICE_CONFIG_LAUNCH_PROTECTED = 12110111SERVICE_SID_TYPE_NONE = 0112SERVICE_SID_TYPE_UNRESTRICTED = 1113SERVICE_SID_TYPE_RESTRICTED = 2 | SERVICE_SID_TYPE_UNRESTRICTED114115SC_ENUM_PROCESS_INFO = 0116117SERVICE_NOTIFY_STATUS_CHANGE = 2118SERVICE_NOTIFY_STOPPED = 0x00000001119SERVICE_NOTIFY_START_PENDING = 0x00000002120SERVICE_NOTIFY_STOP_PENDING = 0x00000004121SERVICE_NOTIFY_RUNNING = 0x00000008122SERVICE_NOTIFY_CONTINUE_PENDING = 0x00000010123SERVICE_NOTIFY_PAUSE_PENDING = 0x00000020124SERVICE_NOTIFY_PAUSED = 0x00000040125SERVICE_NOTIFY_CREATED = 0x00000080126SERVICE_NOTIFY_DELETED = 0x00000100127SERVICE_NOTIFY_DELETE_PENDING = 0x00000200128129SC_EVENT_DATABASE_CHANGE = 0130SC_EVENT_PROPERTY_CHANGE = 1131SC_EVENT_STATUS_CHANGE = 2132133SERVICE_START_REASON_DEMAND = 0x00000001134SERVICE_START_REASON_AUTO = 0x00000002135SERVICE_START_REASON_TRIGGER = 0x00000004136SERVICE_START_REASON_RESTART_ON_FAILURE = 0x00000008137SERVICE_START_REASON_DELAYEDAUTO = 0x00000010138139SERVICE_DYNAMIC_INFORMATION_LEVEL_START_REASON = 1140)141142type ENUM_SERVICE_STATUS struct {143ServiceName *uint16144DisplayName *uint16145ServiceStatus SERVICE_STATUS146}147148type SERVICE_STATUS struct {149ServiceType uint32150CurrentState uint32151ControlsAccepted uint32152Win32ExitCode uint32153ServiceSpecificExitCode uint32154CheckPoint uint32155WaitHint uint32156}157158type SERVICE_TABLE_ENTRY struct {159ServiceName *uint16160ServiceProc uintptr161}162163type QUERY_SERVICE_CONFIG struct {164ServiceType uint32165StartType uint32166ErrorControl uint32167BinaryPathName *uint16168LoadOrderGroup *uint16169TagId uint32170Dependencies *uint16171ServiceStartName *uint16172DisplayName *uint16173}174175type SERVICE_DESCRIPTION struct {176Description *uint16177}178179type SERVICE_DELAYED_AUTO_START_INFO struct {180IsDelayedAutoStartUp uint32181}182183type SERVICE_STATUS_PROCESS struct {184ServiceType uint32185CurrentState uint32186ControlsAccepted uint32187Win32ExitCode uint32188ServiceSpecificExitCode uint32189CheckPoint uint32190WaitHint uint32191ProcessId uint32192ServiceFlags uint32193}194195type ENUM_SERVICE_STATUS_PROCESS struct {196ServiceName *uint16197DisplayName *uint16198ServiceStatusProcess SERVICE_STATUS_PROCESS199}200201type SERVICE_NOTIFY struct {202Version uint32203NotifyCallback uintptr204Context uintptr205NotificationStatus uint32206ServiceStatus SERVICE_STATUS_PROCESS207NotificationTriggered uint32208ServiceNames *uint16209}210211type SERVICE_FAILURE_ACTIONS struct {212ResetPeriod uint32213RebootMsg *uint16214Command *uint16215ActionsCount uint32216Actions *SC_ACTION217}218219type SERVICE_FAILURE_ACTIONS_FLAG struct {220FailureActionsOnNonCrashFailures int32221}222223type SC_ACTION struct {224Type uint32225Delay uint32226}227228type QUERY_SERVICE_LOCK_STATUS struct {229IsLocked uint32230LockOwner *uint16231LockDuration uint32232}233234//sys OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenSCManagerW235//sys CloseServiceHandle(handle Handle) (err error) = advapi32.CloseServiceHandle236//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.CreateServiceW237//sys OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenServiceW238//sys DeleteService(service Handle) (err error) = advapi32.DeleteService239//sys StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) = advapi32.StartServiceW240//sys QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) = advapi32.QueryServiceStatus241//sys QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceLockStatusW242//sys ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) = advapi32.ControlService243//sys StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) = advapi32.StartServiceCtrlDispatcherW244//sys SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) = advapi32.SetServiceStatus245//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.ChangeServiceConfigW246//sys QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfigW247//sys ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) = advapi32.ChangeServiceConfig2W248//sys QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfig2W249//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.EnumServicesStatusExW250//sys QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceStatusEx251//sys NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) = advapi32.NotifyServiceStatusChangeW252//sys SubscribeServiceChangeNotifications(service Handle, eventType uint32, callback uintptr, callbackCtx uintptr, subscription *uintptr) (ret error) = sechost.SubscribeServiceChangeNotifications?253//sys UnsubscribeServiceChangeNotifications(subscription uintptr) = sechost.UnsubscribeServiceChangeNotifications?254//sys RegisterServiceCtrlHandlerEx(serviceName *uint16, handlerProc uintptr, context uintptr) (handle Handle, err error) = advapi32.RegisterServiceCtrlHandlerExW255//sys QueryServiceDynamicInformation(service Handle, infoLevel uint32, dynamicInfo unsafe.Pointer) (err error) = advapi32.QueryServiceDynamicInformation?256//sys EnumDependentServices(service Handle, activityState uint32, services *ENUM_SERVICE_STATUS, buffSize uint32, bytesNeeded *uint32, servicesReturned *uint32) (err error) = advapi32.EnumDependentServicesW257258259