blob: 847e00bc9903ac5bcd1f69db7bbb860e0dfe182b [file] [log] [blame]
khenaidooab1f7bd2019-11-14 14:00:27 -05001// 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// +build windows
6
7package windows
8
9const (
10 SC_MANAGER_CONNECT = 1
11 SC_MANAGER_CREATE_SERVICE = 2
12 SC_MANAGER_ENUMERATE_SERVICE = 4
13 SC_MANAGER_LOCK = 8
14 SC_MANAGER_QUERY_LOCK_STATUS = 16
15 SC_MANAGER_MODIFY_BOOT_CONFIG = 32
16 SC_MANAGER_ALL_ACCESS = 0xf003f
17)
18
19//sys OpenSCManager(machineName *uint16, databaseName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenSCManagerW
20
21const (
22 SERVICE_KERNEL_DRIVER = 1
23 SERVICE_FILE_SYSTEM_DRIVER = 2
24 SERVICE_ADAPTER = 4
25 SERVICE_RECOGNIZER_DRIVER = 8
26 SERVICE_WIN32_OWN_PROCESS = 16
27 SERVICE_WIN32_SHARE_PROCESS = 32
28 SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS | SERVICE_WIN32_SHARE_PROCESS
29 SERVICE_INTERACTIVE_PROCESS = 256
30 SERVICE_DRIVER = SERVICE_KERNEL_DRIVER | SERVICE_FILE_SYSTEM_DRIVER | SERVICE_RECOGNIZER_DRIVER
31 SERVICE_TYPE_ALL = SERVICE_WIN32 | SERVICE_ADAPTER | SERVICE_DRIVER | SERVICE_INTERACTIVE_PROCESS
32
33 SERVICE_BOOT_START = 0
34 SERVICE_SYSTEM_START = 1
35 SERVICE_AUTO_START = 2
36 SERVICE_DEMAND_START = 3
37 SERVICE_DISABLED = 4
38
39 SERVICE_ERROR_IGNORE = 0
40 SERVICE_ERROR_NORMAL = 1
41 SERVICE_ERROR_SEVERE = 2
42 SERVICE_ERROR_CRITICAL = 3
43
44 SC_STATUS_PROCESS_INFO = 0
45
46 SC_ACTION_NONE = 0
47 SC_ACTION_RESTART = 1
48 SC_ACTION_REBOOT = 2
49 SC_ACTION_RUN_COMMAND = 3
50
51 SERVICE_STOPPED = 1
52 SERVICE_START_PENDING = 2
53 SERVICE_STOP_PENDING = 3
54 SERVICE_RUNNING = 4
55 SERVICE_CONTINUE_PENDING = 5
56 SERVICE_PAUSE_PENDING = 6
57 SERVICE_PAUSED = 7
58 SERVICE_NO_CHANGE = 0xffffffff
59
60 SERVICE_ACCEPT_STOP = 1
61 SERVICE_ACCEPT_PAUSE_CONTINUE = 2
62 SERVICE_ACCEPT_SHUTDOWN = 4
63 SERVICE_ACCEPT_PARAMCHANGE = 8
64 SERVICE_ACCEPT_NETBINDCHANGE = 16
65 SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 32
66 SERVICE_ACCEPT_POWEREVENT = 64
67 SERVICE_ACCEPT_SESSIONCHANGE = 128
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
84 SERVICE_ACTIVE = 1
85 SERVICE_INACTIVE = 2
86 SERVICE_STATE_ALL = 3
87
88 SERVICE_QUERY_CONFIG = 1
89 SERVICE_CHANGE_CONFIG = 2
90 SERVICE_QUERY_STATUS = 4
91 SERVICE_ENUMERATE_DEPENDENTS = 8
92 SERVICE_START = 16
93 SERVICE_STOP = 32
94 SERVICE_PAUSE_CONTINUE = 64
95 SERVICE_INTERROGATE = 128
96 SERVICE_USER_DEFINED_CONTROL = 256
97 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
98
99 SERVICE_RUNS_IN_SYSTEM_PROCESS = 1
100
101 SERVICE_CONFIG_DESCRIPTION = 1
102 SERVICE_CONFIG_FAILURE_ACTIONS = 2
103 SERVICE_CONFIG_DELAYED_AUTO_START_INFO = 3
104 SERVICE_CONFIG_FAILURE_ACTIONS_FLAG = 4
105 SERVICE_CONFIG_SERVICE_SID_INFO = 5
106 SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6
107 SERVICE_CONFIG_PRESHUTDOWN_INFO = 7
108 SERVICE_CONFIG_TRIGGER_INFO = 8
109 SERVICE_CONFIG_PREFERRED_NODE = 9
110 SERVICE_CONFIG_LAUNCH_PROTECTED = 12
111
112 SERVICE_SID_TYPE_NONE = 0
113 SERVICE_SID_TYPE_UNRESTRICTED = 1
114 SERVICE_SID_TYPE_RESTRICTED = 2 | SERVICE_SID_TYPE_UNRESTRICTED
115
116 SC_ENUM_PROCESS_INFO = 0
117
118 SERVICE_NOTIFY_STATUS_CHANGE = 2
119 SERVICE_NOTIFY_STOPPED = 0x00000001
120 SERVICE_NOTIFY_START_PENDING = 0x00000002
121 SERVICE_NOTIFY_STOP_PENDING = 0x00000004
122 SERVICE_NOTIFY_RUNNING = 0x00000008
123 SERVICE_NOTIFY_CONTINUE_PENDING = 0x00000010
124 SERVICE_NOTIFY_PAUSE_PENDING = 0x00000020
125 SERVICE_NOTIFY_PAUSED = 0x00000040
126 SERVICE_NOTIFY_CREATED = 0x00000080
127 SERVICE_NOTIFY_DELETED = 0x00000100
128 SERVICE_NOTIFY_DELETE_PENDING = 0x00000200
129)
130
131type SERVICE_STATUS struct {
132 ServiceType uint32
133 CurrentState uint32
134 ControlsAccepted uint32
135 Win32ExitCode uint32
136 ServiceSpecificExitCode uint32
137 CheckPoint uint32
138 WaitHint uint32
139}
140
141type SERVICE_TABLE_ENTRY struct {
142 ServiceName *uint16
143 ServiceProc uintptr
144}
145
146type QUERY_SERVICE_CONFIG struct {
147 ServiceType uint32
148 StartType uint32
149 ErrorControl uint32
150 BinaryPathName *uint16
151 LoadOrderGroup *uint16
152 TagId uint32
153 Dependencies *uint16
154 ServiceStartName *uint16
155 DisplayName *uint16
156}
157
158type SERVICE_DESCRIPTION struct {
159 Description *uint16
160}
161
162type SERVICE_DELAYED_AUTO_START_INFO struct {
163 IsDelayedAutoStartUp uint32
164}
165
166type SERVICE_STATUS_PROCESS struct {
167 ServiceType uint32
168 CurrentState uint32
169 ControlsAccepted uint32
170 Win32ExitCode uint32
171 ServiceSpecificExitCode uint32
172 CheckPoint uint32
173 WaitHint uint32
174 ProcessId uint32
175 ServiceFlags uint32
176}
177
178type ENUM_SERVICE_STATUS_PROCESS struct {
179 ServiceName *uint16
180 DisplayName *uint16
181 ServiceStatusProcess SERVICE_STATUS_PROCESS
182}
183
184type SERVICE_NOTIFY struct {
185 Version uint32
186 NotifyCallback uintptr
187 Context uintptr
188 NotificationStatus uint32
189 ServiceStatus SERVICE_STATUS_PROCESS
190 NotificationTriggered uint32
191 ServiceNames *uint16
192}
193
194type SERVICE_FAILURE_ACTIONS struct {
195 ResetPeriod uint32
196 RebootMsg *uint16
197 Command *uint16
198 ActionsCount uint32
199 Actions *SC_ACTION
200}
201
202type SC_ACTION struct {
203 Type uint32
204 Delay uint32
205}
206
207type QUERY_SERVICE_LOCK_STATUS struct {
208 IsLocked uint32
209 LockOwner *uint16
210 LockDuration uint32
211}
212
213//sys CloseServiceHandle(handle Handle) (err error) = advapi32.CloseServiceHandle
214//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
215//sys OpenService(mgr Handle, serviceName *uint16, access uint32) (handle Handle, err error) [failretval==0] = advapi32.OpenServiceW
216//sys DeleteService(service Handle) (err error) = advapi32.DeleteService
217//sys StartService(service Handle, numArgs uint32, argVectors **uint16) (err error) = advapi32.StartServiceW
218//sys QueryServiceStatus(service Handle, status *SERVICE_STATUS) (err error) = advapi32.QueryServiceStatus
219//sys QueryServiceLockStatus(mgr Handle, lockStatus *QUERY_SERVICE_LOCK_STATUS, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceLockStatusW
220//sys ControlService(service Handle, control uint32, status *SERVICE_STATUS) (err error) = advapi32.ControlService
221//sys StartServiceCtrlDispatcher(serviceTable *SERVICE_TABLE_ENTRY) (err error) = advapi32.StartServiceCtrlDispatcherW
222//sys SetServiceStatus(service Handle, serviceStatus *SERVICE_STATUS) (err error) = advapi32.SetServiceStatus
223//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
224//sys QueryServiceConfig(service Handle, serviceConfig *QUERY_SERVICE_CONFIG, bufSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfigW
225//sys ChangeServiceConfig2(service Handle, infoLevel uint32, info *byte) (err error) = advapi32.ChangeServiceConfig2W
226//sys QueryServiceConfig2(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceConfig2W
227//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
228//sys QueryServiceStatusEx(service Handle, infoLevel uint32, buff *byte, buffSize uint32, bytesNeeded *uint32) (err error) = advapi32.QueryServiceStatusEx
229//sys NotifyServiceStatusChange(service Handle, notifyMask uint32, notifier *SERVICE_NOTIFY) (ret error) = advapi32.NotifyServiceStatusChangeW