本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
8.8KB

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