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.
 
 

3350 lines
103 KiB

  1. // Copyright 2011 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. package windows
  5. import (
  6. "net"
  7. "syscall"
  8. "unsafe"
  9. )
  10. // NTStatus corresponds with NTSTATUS, error values returned by ntdll.dll and
  11. // other native functions.
  12. type NTStatus uint32
  13. const (
  14. // Invented values to support what package os expects.
  15. O_RDONLY = 0x00000
  16. O_WRONLY = 0x00001
  17. O_RDWR = 0x00002
  18. O_CREAT = 0x00040
  19. O_EXCL = 0x00080
  20. O_NOCTTY = 0x00100
  21. O_TRUNC = 0x00200
  22. O_NONBLOCK = 0x00800
  23. O_APPEND = 0x00400
  24. O_SYNC = 0x01000
  25. O_ASYNC = 0x02000
  26. O_CLOEXEC = 0x80000
  27. )
  28. const (
  29. // More invented values for signals
  30. SIGHUP = Signal(0x1)
  31. SIGINT = Signal(0x2)
  32. SIGQUIT = Signal(0x3)
  33. SIGILL = Signal(0x4)
  34. SIGTRAP = Signal(0x5)
  35. SIGABRT = Signal(0x6)
  36. SIGBUS = Signal(0x7)
  37. SIGFPE = Signal(0x8)
  38. SIGKILL = Signal(0x9)
  39. SIGSEGV = Signal(0xb)
  40. SIGPIPE = Signal(0xd)
  41. SIGALRM = Signal(0xe)
  42. SIGTERM = Signal(0xf)
  43. )
  44. var signals = [...]string{
  45. 1: "hangup",
  46. 2: "interrupt",
  47. 3: "quit",
  48. 4: "illegal instruction",
  49. 5: "trace/breakpoint trap",
  50. 6: "aborted",
  51. 7: "bus error",
  52. 8: "floating point exception",
  53. 9: "killed",
  54. 10: "user defined signal 1",
  55. 11: "segmentation fault",
  56. 12: "user defined signal 2",
  57. 13: "broken pipe",
  58. 14: "alarm clock",
  59. 15: "terminated",
  60. }
  61. const (
  62. FILE_READ_DATA = 0x00000001
  63. FILE_READ_ATTRIBUTES = 0x00000080
  64. FILE_READ_EA = 0x00000008
  65. FILE_WRITE_DATA = 0x00000002
  66. FILE_WRITE_ATTRIBUTES = 0x00000100
  67. FILE_WRITE_EA = 0x00000010
  68. FILE_APPEND_DATA = 0x00000004
  69. FILE_EXECUTE = 0x00000020
  70. FILE_GENERIC_READ = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE
  71. FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE
  72. FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE
  73. FILE_LIST_DIRECTORY = 0x00000001
  74. FILE_TRAVERSE = 0x00000020
  75. FILE_SHARE_READ = 0x00000001
  76. FILE_SHARE_WRITE = 0x00000002
  77. FILE_SHARE_DELETE = 0x00000004
  78. FILE_ATTRIBUTE_READONLY = 0x00000001
  79. FILE_ATTRIBUTE_HIDDEN = 0x00000002
  80. FILE_ATTRIBUTE_SYSTEM = 0x00000004
  81. FILE_ATTRIBUTE_DIRECTORY = 0x00000010
  82. FILE_ATTRIBUTE_ARCHIVE = 0x00000020
  83. FILE_ATTRIBUTE_DEVICE = 0x00000040
  84. FILE_ATTRIBUTE_NORMAL = 0x00000080
  85. FILE_ATTRIBUTE_TEMPORARY = 0x00000100
  86. FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200
  87. FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
  88. FILE_ATTRIBUTE_COMPRESSED = 0x00000800
  89. FILE_ATTRIBUTE_OFFLINE = 0x00001000
  90. FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
  91. FILE_ATTRIBUTE_ENCRYPTED = 0x00004000
  92. FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000
  93. FILE_ATTRIBUTE_VIRTUAL = 0x00010000
  94. FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000
  95. FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000
  96. FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000
  97. INVALID_FILE_ATTRIBUTES = 0xffffffff
  98. CREATE_NEW = 1
  99. CREATE_ALWAYS = 2
  100. OPEN_EXISTING = 3
  101. OPEN_ALWAYS = 4
  102. TRUNCATE_EXISTING = 5
  103. FILE_FLAG_OPEN_REQUIRING_OPLOCK = 0x00040000
  104. FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000
  105. FILE_FLAG_OPEN_NO_RECALL = 0x00100000
  106. FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
  107. FILE_FLAG_SESSION_AWARE = 0x00800000
  108. FILE_FLAG_POSIX_SEMANTICS = 0x01000000
  109. FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
  110. FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
  111. FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000
  112. FILE_FLAG_RANDOM_ACCESS = 0x10000000
  113. FILE_FLAG_NO_BUFFERING = 0x20000000
  114. FILE_FLAG_OVERLAPPED = 0x40000000
  115. FILE_FLAG_WRITE_THROUGH = 0x80000000
  116. HANDLE_FLAG_INHERIT = 0x00000001
  117. STARTF_USESTDHANDLES = 0x00000100
  118. STARTF_USESHOWWINDOW = 0x00000001
  119. DUPLICATE_CLOSE_SOURCE = 0x00000001
  120. DUPLICATE_SAME_ACCESS = 0x00000002
  121. STD_INPUT_HANDLE = -10 & (1<<32 - 1)
  122. STD_OUTPUT_HANDLE = -11 & (1<<32 - 1)
  123. STD_ERROR_HANDLE = -12 & (1<<32 - 1)
  124. FILE_BEGIN = 0
  125. FILE_CURRENT = 1
  126. FILE_END = 2
  127. LANG_ENGLISH = 0x09
  128. SUBLANG_ENGLISH_US = 0x01
  129. FORMAT_MESSAGE_ALLOCATE_BUFFER = 256
  130. FORMAT_MESSAGE_IGNORE_INSERTS = 512
  131. FORMAT_MESSAGE_FROM_STRING = 1024
  132. FORMAT_MESSAGE_FROM_HMODULE = 2048
  133. FORMAT_MESSAGE_FROM_SYSTEM = 4096
  134. FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192
  135. FORMAT_MESSAGE_MAX_WIDTH_MASK = 255
  136. MAX_PATH = 260
  137. MAX_LONG_PATH = 32768
  138. MAX_MODULE_NAME32 = 255
  139. MAX_COMPUTERNAME_LENGTH = 15
  140. MAX_DHCPV6_DUID_LENGTH = 130
  141. MAX_DNS_SUFFIX_STRING_LENGTH = 256
  142. TIME_ZONE_ID_UNKNOWN = 0
  143. TIME_ZONE_ID_STANDARD = 1
  144. TIME_ZONE_ID_DAYLIGHT = 2
  145. IGNORE = 0
  146. INFINITE = 0xffffffff
  147. WAIT_ABANDONED = 0x00000080
  148. WAIT_OBJECT_0 = 0x00000000
  149. WAIT_FAILED = 0xFFFFFFFF
  150. // Access rights for process.
  151. PROCESS_CREATE_PROCESS = 0x0080
  152. PROCESS_CREATE_THREAD = 0x0002
  153. PROCESS_DUP_HANDLE = 0x0040
  154. PROCESS_QUERY_INFORMATION = 0x0400
  155. PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
  156. PROCESS_SET_INFORMATION = 0x0200
  157. PROCESS_SET_QUOTA = 0x0100
  158. PROCESS_SUSPEND_RESUME = 0x0800
  159. PROCESS_TERMINATE = 0x0001
  160. PROCESS_VM_OPERATION = 0x0008
  161. PROCESS_VM_READ = 0x0010
  162. PROCESS_VM_WRITE = 0x0020
  163. // Access rights for thread.
  164. THREAD_DIRECT_IMPERSONATION = 0x0200
  165. THREAD_GET_CONTEXT = 0x0008
  166. THREAD_IMPERSONATE = 0x0100
  167. THREAD_QUERY_INFORMATION = 0x0040
  168. THREAD_QUERY_LIMITED_INFORMATION = 0x0800
  169. THREAD_SET_CONTEXT = 0x0010
  170. THREAD_SET_INFORMATION = 0x0020
  171. THREAD_SET_LIMITED_INFORMATION = 0x0400
  172. THREAD_SET_THREAD_TOKEN = 0x0080
  173. THREAD_SUSPEND_RESUME = 0x0002
  174. THREAD_TERMINATE = 0x0001
  175. FILE_MAP_COPY = 0x01
  176. FILE_MAP_WRITE = 0x02
  177. FILE_MAP_READ = 0x04
  178. FILE_MAP_EXECUTE = 0x20
  179. CTRL_C_EVENT = 0
  180. CTRL_BREAK_EVENT = 1
  181. CTRL_CLOSE_EVENT = 2
  182. CTRL_LOGOFF_EVENT = 5
  183. CTRL_SHUTDOWN_EVENT = 6
  184. // Windows reserves errors >= 1<<29 for application use.
  185. APPLICATION_ERROR = 1 << 29
  186. )
  187. const (
  188. // Process creation flags.
  189. CREATE_BREAKAWAY_FROM_JOB = 0x01000000
  190. CREATE_DEFAULT_ERROR_MODE = 0x04000000
  191. CREATE_NEW_CONSOLE = 0x00000010
  192. CREATE_NEW_PROCESS_GROUP = 0x00000200
  193. CREATE_NO_WINDOW = 0x08000000
  194. CREATE_PROTECTED_PROCESS = 0x00040000
  195. CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
  196. CREATE_SEPARATE_WOW_VDM = 0x00000800
  197. CREATE_SHARED_WOW_VDM = 0x00001000
  198. CREATE_SUSPENDED = 0x00000004
  199. CREATE_UNICODE_ENVIRONMENT = 0x00000400
  200. DEBUG_ONLY_THIS_PROCESS = 0x00000002
  201. DEBUG_PROCESS = 0x00000001
  202. DETACHED_PROCESS = 0x00000008
  203. EXTENDED_STARTUPINFO_PRESENT = 0x00080000
  204. INHERIT_PARENT_AFFINITY = 0x00010000
  205. )
  206. const (
  207. // attributes for ProcThreadAttributeList
  208. PROC_THREAD_ATTRIBUTE_PARENT_PROCESS = 0x00020000
  209. PROC_THREAD_ATTRIBUTE_HANDLE_LIST = 0x00020002
  210. PROC_THREAD_ATTRIBUTE_GROUP_AFFINITY = 0x00030003
  211. PROC_THREAD_ATTRIBUTE_PREFERRED_NODE = 0x00020004
  212. PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR = 0x00030005
  213. PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY = 0x00020007
  214. PROC_THREAD_ATTRIBUTE_UMS_THREAD = 0x00030006
  215. PROC_THREAD_ATTRIBUTE_PROTECTION_LEVEL = 0x0002000b
  216. )
  217. const (
  218. // flags for CreateToolhelp32Snapshot
  219. TH32CS_SNAPHEAPLIST = 0x01
  220. TH32CS_SNAPPROCESS = 0x02
  221. TH32CS_SNAPTHREAD = 0x04
  222. TH32CS_SNAPMODULE = 0x08
  223. TH32CS_SNAPMODULE32 = 0x10
  224. TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
  225. TH32CS_INHERIT = 0x80000000
  226. )
  227. const (
  228. // flags for EnumProcessModulesEx
  229. LIST_MODULES_32BIT = 0x01
  230. LIST_MODULES_64BIT = 0x02
  231. LIST_MODULES_ALL = 0x03
  232. LIST_MODULES_DEFAULT = 0x00
  233. )
  234. const (
  235. // filters for ReadDirectoryChangesW and FindFirstChangeNotificationW
  236. FILE_NOTIFY_CHANGE_FILE_NAME = 0x001
  237. FILE_NOTIFY_CHANGE_DIR_NAME = 0x002
  238. FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x004
  239. FILE_NOTIFY_CHANGE_SIZE = 0x008
  240. FILE_NOTIFY_CHANGE_LAST_WRITE = 0x010
  241. FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x020
  242. FILE_NOTIFY_CHANGE_CREATION = 0x040
  243. FILE_NOTIFY_CHANGE_SECURITY = 0x100
  244. )
  245. const (
  246. // do not reorder
  247. FILE_ACTION_ADDED = iota + 1
  248. FILE_ACTION_REMOVED
  249. FILE_ACTION_MODIFIED
  250. FILE_ACTION_RENAMED_OLD_NAME
  251. FILE_ACTION_RENAMED_NEW_NAME
  252. )
  253. const (
  254. // wincrypt.h
  255. /* certenrolld_begin -- PROV_RSA_*/
  256. PROV_RSA_FULL = 1
  257. PROV_RSA_SIG = 2
  258. PROV_DSS = 3
  259. PROV_FORTEZZA = 4
  260. PROV_MS_EXCHANGE = 5
  261. PROV_SSL = 6
  262. PROV_RSA_SCHANNEL = 12
  263. PROV_DSS_DH = 13
  264. PROV_EC_ECDSA_SIG = 14
  265. PROV_EC_ECNRA_SIG = 15
  266. PROV_EC_ECDSA_FULL = 16
  267. PROV_EC_ECNRA_FULL = 17
  268. PROV_DH_SCHANNEL = 18
  269. PROV_SPYRUS_LYNKS = 20
  270. PROV_RNG = 21
  271. PROV_INTEL_SEC = 22
  272. PROV_REPLACE_OWF = 23
  273. PROV_RSA_AES = 24
  274. /* dwFlags definitions for CryptAcquireContext */
  275. CRYPT_VERIFYCONTEXT = 0xF0000000
  276. CRYPT_NEWKEYSET = 0x00000008
  277. CRYPT_DELETEKEYSET = 0x00000010
  278. CRYPT_MACHINE_KEYSET = 0x00000020
  279. CRYPT_SILENT = 0x00000040
  280. CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080
  281. /* Flags for PFXImportCertStore */
  282. CRYPT_EXPORTABLE = 0x00000001
  283. CRYPT_USER_PROTECTED = 0x00000002
  284. CRYPT_USER_KEYSET = 0x00001000
  285. PKCS12_PREFER_CNG_KSP = 0x00000100
  286. PKCS12_ALWAYS_CNG_KSP = 0x00000200
  287. PKCS12_ALLOW_OVERWRITE_KEY = 0x00004000
  288. PKCS12_NO_PERSIST_KEY = 0x00008000
  289. PKCS12_INCLUDE_EXTENDED_PROPERTIES = 0x00000010
  290. /* Flags for CryptAcquireCertificatePrivateKey */
  291. CRYPT_ACQUIRE_CACHE_FLAG = 0x00000001
  292. CRYPT_ACQUIRE_USE_PROV_INFO_FLAG = 0x00000002
  293. CRYPT_ACQUIRE_COMPARE_KEY_FLAG = 0x00000004
  294. CRYPT_ACQUIRE_NO_HEALING = 0x00000008
  295. CRYPT_ACQUIRE_SILENT_FLAG = 0x00000040
  296. CRYPT_ACQUIRE_WINDOW_HANDLE_FLAG = 0x00000080
  297. CRYPT_ACQUIRE_NCRYPT_KEY_FLAGS_MASK = 0x00070000
  298. CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG = 0x00010000
  299. CRYPT_ACQUIRE_PREFER_NCRYPT_KEY_FLAG = 0x00020000
  300. CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG = 0x00040000
  301. /* pdwKeySpec for CryptAcquireCertificatePrivateKey */
  302. AT_KEYEXCHANGE = 1
  303. AT_SIGNATURE = 2
  304. CERT_NCRYPT_KEY_SPEC = 0xFFFFFFFF
  305. /* Default usage match type is AND with value zero */
  306. USAGE_MATCH_TYPE_AND = 0
  307. USAGE_MATCH_TYPE_OR = 1
  308. /* msgAndCertEncodingType values for CertOpenStore function */
  309. X509_ASN_ENCODING = 0x00000001
  310. PKCS_7_ASN_ENCODING = 0x00010000
  311. /* storeProvider values for CertOpenStore function */
  312. CERT_STORE_PROV_MSG = 1
  313. CERT_STORE_PROV_MEMORY = 2
  314. CERT_STORE_PROV_FILE = 3
  315. CERT_STORE_PROV_REG = 4
  316. CERT_STORE_PROV_PKCS7 = 5
  317. CERT_STORE_PROV_SERIALIZED = 6
  318. CERT_STORE_PROV_FILENAME_A = 7
  319. CERT_STORE_PROV_FILENAME_W = 8
  320. CERT_STORE_PROV_FILENAME = CERT_STORE_PROV_FILENAME_W
  321. CERT_STORE_PROV_SYSTEM_A = 9
  322. CERT_STORE_PROV_SYSTEM_W = 10
  323. CERT_STORE_PROV_SYSTEM = CERT_STORE_PROV_SYSTEM_W
  324. CERT_STORE_PROV_COLLECTION = 11
  325. CERT_STORE_PROV_SYSTEM_REGISTRY_A = 12
  326. CERT_STORE_PROV_SYSTEM_REGISTRY_W = 13
  327. CERT_STORE_PROV_SYSTEM_REGISTRY = CERT_STORE_PROV_SYSTEM_REGISTRY_W
  328. CERT_STORE_PROV_PHYSICAL_W = 14
  329. CERT_STORE_PROV_PHYSICAL = CERT_STORE_PROV_PHYSICAL_W
  330. CERT_STORE_PROV_SMART_CARD_W = 15
  331. CERT_STORE_PROV_SMART_CARD = CERT_STORE_PROV_SMART_CARD_W
  332. CERT_STORE_PROV_LDAP_W = 16
  333. CERT_STORE_PROV_LDAP = CERT_STORE_PROV_LDAP_W
  334. CERT_STORE_PROV_PKCS12 = 17
  335. /* store characteristics (low WORD of flag) for CertOpenStore function */
  336. CERT_STORE_NO_CRYPT_RELEASE_FLAG = 0x00000001
  337. CERT_STORE_SET_LOCALIZED_NAME_FLAG = 0x00000002
  338. CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004
  339. CERT_STORE_DELETE_FLAG = 0x00000010
  340. CERT_STORE_UNSAFE_PHYSICAL_FLAG = 0x00000020
  341. CERT_STORE_SHARE_STORE_FLAG = 0x00000040
  342. CERT_STORE_SHARE_CONTEXT_FLAG = 0x00000080
  343. CERT_STORE_MANIFOLD_FLAG = 0x00000100
  344. CERT_STORE_ENUM_ARCHIVED_FLAG = 0x00000200
  345. CERT_STORE_UPDATE_KEYID_FLAG = 0x00000400
  346. CERT_STORE_BACKUP_RESTORE_FLAG = 0x00000800
  347. CERT_STORE_MAXIMUM_ALLOWED_FLAG = 0x00001000
  348. CERT_STORE_CREATE_NEW_FLAG = 0x00002000
  349. CERT_STORE_OPEN_EXISTING_FLAG = 0x00004000
  350. CERT_STORE_READONLY_FLAG = 0x00008000
  351. /* store locations (high WORD of flag) for CertOpenStore function */
  352. CERT_SYSTEM_STORE_CURRENT_USER = 0x00010000
  353. CERT_SYSTEM_STORE_LOCAL_MACHINE = 0x00020000
  354. CERT_SYSTEM_STORE_CURRENT_SERVICE = 0x00040000
  355. CERT_SYSTEM_STORE_SERVICES = 0x00050000
  356. CERT_SYSTEM_STORE_USERS = 0x00060000
  357. CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY = 0x00070000
  358. CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = 0x00080000
  359. CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE = 0x00090000
  360. CERT_SYSTEM_STORE_UNPROTECTED_FLAG = 0x40000000
  361. CERT_SYSTEM_STORE_RELOCATE_FLAG = 0x80000000
  362. /* Miscellaneous high-WORD flags for CertOpenStore function */
  363. CERT_REGISTRY_STORE_REMOTE_FLAG = 0x00010000
  364. CERT_REGISTRY_STORE_SERIALIZED_FLAG = 0x00020000
  365. CERT_REGISTRY_STORE_ROAMING_FLAG = 0x00040000
  366. CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG = 0x00080000
  367. CERT_REGISTRY_STORE_LM_GPT_FLAG = 0x01000000
  368. CERT_REGISTRY_STORE_CLIENT_GPT_FLAG = 0x80000000
  369. CERT_FILE_STORE_COMMIT_ENABLE_FLAG = 0x00010000
  370. CERT_LDAP_STORE_SIGN_FLAG = 0x00010000
  371. CERT_LDAP_STORE_AREC_EXCLUSIVE_FLAG = 0x00020000
  372. CERT_LDAP_STORE_OPENED_FLAG = 0x00040000
  373. CERT_LDAP_STORE_UNBIND_FLAG = 0x00080000
  374. /* addDisposition values for CertAddCertificateContextToStore function */
  375. CERT_STORE_ADD_NEW = 1
  376. CERT_STORE_ADD_USE_EXISTING = 2
  377. CERT_STORE_ADD_REPLACE_EXISTING = 3
  378. CERT_STORE_ADD_ALWAYS = 4
  379. CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5
  380. CERT_STORE_ADD_NEWER = 6
  381. CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES = 7
  382. /* ErrorStatus values for CertTrustStatus struct */
  383. CERT_TRUST_NO_ERROR = 0x00000000
  384. CERT_TRUST_IS_NOT_TIME_VALID = 0x00000001
  385. CERT_TRUST_IS_REVOKED = 0x00000004
  386. CERT_TRUST_IS_NOT_SIGNATURE_VALID = 0x00000008
  387. CERT_TRUST_IS_NOT_VALID_FOR_USAGE = 0x00000010
  388. CERT_TRUST_IS_UNTRUSTED_ROOT = 0x00000020
  389. CERT_TRUST_REVOCATION_STATUS_UNKNOWN = 0x00000040
  390. CERT_TRUST_IS_CYCLIC = 0x00000080
  391. CERT_TRUST_INVALID_EXTENSION = 0x00000100
  392. CERT_TRUST_INVALID_POLICY_CONSTRAINTS = 0x00000200
  393. CERT_TRUST_INVALID_BASIC_CONSTRAINTS = 0x00000400
  394. CERT_TRUST_INVALID_NAME_CONSTRAINTS = 0x00000800
  395. CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000
  396. CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT = 0x00002000
  397. CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000
  398. CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT = 0x00008000
  399. CERT_TRUST_IS_PARTIAL_CHAIN = 0x00010000
  400. CERT_TRUST_CTL_IS_NOT_TIME_VALID = 0x00020000
  401. CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID = 0x00040000
  402. CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE = 0x00080000
  403. CERT_TRUST_HAS_WEAK_SIGNATURE = 0x00100000
  404. CERT_TRUST_IS_OFFLINE_REVOCATION = 0x01000000
  405. CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY = 0x02000000
  406. CERT_TRUST_IS_EXPLICIT_DISTRUST = 0x04000000
  407. CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT = 0x08000000
  408. /* InfoStatus values for CertTrustStatus struct */
  409. CERT_TRUST_HAS_EXACT_MATCH_ISSUER = 0x00000001
  410. CERT_TRUST_HAS_KEY_MATCH_ISSUER = 0x00000002
  411. CERT_TRUST_HAS_NAME_MATCH_ISSUER = 0x00000004
  412. CERT_TRUST_IS_SELF_SIGNED = 0x00000008
  413. CERT_TRUST_HAS_PREFERRED_ISSUER = 0x00000100
  414. CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY = 0x00000400
  415. CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS = 0x00000400
  416. CERT_TRUST_IS_PEER_TRUSTED = 0x00000800
  417. CERT_TRUST_HAS_CRL_VALIDITY_EXTENDED = 0x00001000
  418. CERT_TRUST_IS_FROM_EXCLUSIVE_TRUST_STORE = 0x00002000
  419. CERT_TRUST_IS_CA_TRUSTED = 0x00004000
  420. CERT_TRUST_IS_COMPLEX_CHAIN = 0x00010000
  421. /* Certificate Information Flags */
  422. CERT_INFO_VERSION_FLAG = 1
  423. CERT_INFO_SERIAL_NUMBER_FLAG = 2
  424. CERT_INFO_SIGNATURE_ALGORITHM_FLAG = 3
  425. CERT_INFO_ISSUER_FLAG = 4
  426. CERT_INFO_NOT_BEFORE_FLAG = 5
  427. CERT_INFO_NOT_AFTER_FLAG = 6
  428. CERT_INFO_SUBJECT_FLAG = 7
  429. CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG = 8
  430. CERT_INFO_ISSUER_UNIQUE_ID_FLAG = 9
  431. CERT_INFO_SUBJECT_UNIQUE_ID_FLAG = 10
  432. CERT_INFO_EXTENSION_FLAG = 11
  433. /* dwFindType for CertFindCertificateInStore */
  434. CERT_COMPARE_MASK = 0xFFFF
  435. CERT_COMPARE_SHIFT = 16
  436. CERT_COMPARE_ANY = 0
  437. CERT_COMPARE_SHA1_HASH = 1
  438. CERT_COMPARE_NAME = 2
  439. CERT_COMPARE_ATTR = 3
  440. CERT_COMPARE_MD5_HASH = 4
  441. CERT_COMPARE_PROPERTY = 5
  442. CERT_COMPARE_PUBLIC_KEY = 6
  443. CERT_COMPARE_HASH = CERT_COMPARE_SHA1_HASH
  444. CERT_COMPARE_NAME_STR_A = 7
  445. CERT_COMPARE_NAME_STR_W = 8
  446. CERT_COMPARE_KEY_SPEC = 9
  447. CERT_COMPARE_ENHKEY_USAGE = 10
  448. CERT_COMPARE_CTL_USAGE = CERT_COMPARE_ENHKEY_USAGE
  449. CERT_COMPARE_SUBJECT_CERT = 11
  450. CERT_COMPARE_ISSUER_OF = 12
  451. CERT_COMPARE_EXISTING = 13
  452. CERT_COMPARE_SIGNATURE_HASH = 14
  453. CERT_COMPARE_KEY_IDENTIFIER = 15
  454. CERT_COMPARE_CERT_ID = 16
  455. CERT_COMPARE_CROSS_CERT_DIST_POINTS = 17
  456. CERT_COMPARE_PUBKEY_MD5_HASH = 18
  457. CERT_COMPARE_SUBJECT_INFO_ACCESS = 19
  458. CERT_COMPARE_HASH_STR = 20
  459. CERT_COMPARE_HAS_PRIVATE_KEY = 21
  460. CERT_FIND_ANY = (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT)
  461. CERT_FIND_SHA1_HASH = (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT)
  462. CERT_FIND_MD5_HASH = (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT)
  463. CERT_FIND_SIGNATURE_HASH = (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT)
  464. CERT_FIND_KEY_IDENTIFIER = (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT)
  465. CERT_FIND_HASH = CERT_FIND_SHA1_HASH
  466. CERT_FIND_PROPERTY = (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT)
  467. CERT_FIND_PUBLIC_KEY = (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT)
  468. CERT_FIND_SUBJECT_NAME = (CERT_COMPARE_NAME<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
  469. CERT_FIND_SUBJECT_ATTR = (CERT_COMPARE_ATTR<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
  470. CERT_FIND_ISSUER_NAME = (CERT_COMPARE_NAME<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
  471. CERT_FIND_ISSUER_ATTR = (CERT_COMPARE_ATTR<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
  472. CERT_FIND_SUBJECT_STR_A = (CERT_COMPARE_NAME_STR_A<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
  473. CERT_FIND_SUBJECT_STR_W = (CERT_COMPARE_NAME_STR_W<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
  474. CERT_FIND_SUBJECT_STR = CERT_FIND_SUBJECT_STR_W
  475. CERT_FIND_ISSUER_STR_A = (CERT_COMPARE_NAME_STR_A<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
  476. CERT_FIND_ISSUER_STR_W = (CERT_COMPARE_NAME_STR_W<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
  477. CERT_FIND_ISSUER_STR = CERT_FIND_ISSUER_STR_W
  478. CERT_FIND_KEY_SPEC = (CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT)
  479. CERT_FIND_ENHKEY_USAGE = (CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT)
  480. CERT_FIND_CTL_USAGE = CERT_FIND_ENHKEY_USAGE
  481. CERT_FIND_SUBJECT_CERT = (CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT)
  482. CERT_FIND_ISSUER_OF = (CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT)
  483. CERT_FIND_EXISTING = (CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT)
  484. CERT_FIND_CERT_ID = (CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT)
  485. CERT_FIND_CROSS_CERT_DIST_POINTS = (CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT)
  486. CERT_FIND_PUBKEY_MD5_HASH = (CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT)
  487. CERT_FIND_SUBJECT_INFO_ACCESS = (CERT_COMPARE_SUBJECT_INFO_ACCESS << CERT_COMPARE_SHIFT)
  488. CERT_FIND_HASH_STR = (CERT_COMPARE_HASH_STR << CERT_COMPARE_SHIFT)
  489. CERT_FIND_HAS_PRIVATE_KEY = (CERT_COMPARE_HAS_PRIVATE_KEY << CERT_COMPARE_SHIFT)
  490. CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG = 0x1
  491. CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG = 0x2
  492. CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG = 0x4
  493. CERT_FIND_NO_ENHKEY_USAGE_FLAG = 0x8
  494. CERT_FIND_OR_ENHKEY_USAGE_FLAG = 0x10
  495. CERT_FIND_VALID_ENHKEY_USAGE_FLAG = 0x20
  496. CERT_FIND_OPTIONAL_CTL_USAGE_FLAG = CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG
  497. CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG = CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG
  498. CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG = CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
  499. CERT_FIND_NO_CTL_USAGE_FLAG = CERT_FIND_NO_ENHKEY_USAGE_FLAG
  500. CERT_FIND_OR_CTL_USAGE_FLAG = CERT_FIND_OR_ENHKEY_USAGE_FLAG
  501. CERT_FIND_VALID_CTL_USAGE_FLAG = CERT_FIND_VALID_ENHKEY_USAGE_FLAG
  502. /* policyOID values for CertVerifyCertificateChainPolicy function */
  503. CERT_CHAIN_POLICY_BASE = 1
  504. CERT_CHAIN_POLICY_AUTHENTICODE = 2
  505. CERT_CHAIN_POLICY_AUTHENTICODE_TS = 3
  506. CERT_CHAIN_POLICY_SSL = 4
  507. CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5
  508. CERT_CHAIN_POLICY_NT_AUTH = 6
  509. CERT_CHAIN_POLICY_MICROSOFT_ROOT = 7
  510. CERT_CHAIN_POLICY_EV = 8
  511. CERT_CHAIN_POLICY_SSL_F12 = 9
  512. /* flag for dwFindType CertFindChainInStore */
  513. CERT_CHAIN_FIND_BY_ISSUER = 1
  514. /* dwFindFlags for CertFindChainInStore when dwFindType == CERT_CHAIN_FIND_BY_ISSUER */
  515. CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG = 0x0001
  516. CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG = 0x0002
  517. CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG = 0x0004
  518. CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG = 0x0008
  519. CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG = 0x4000
  520. CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG = 0x8000
  521. /* Certificate Store close flags */
  522. CERT_CLOSE_STORE_FORCE_FLAG = 0x00000001
  523. CERT_CLOSE_STORE_CHECK_FLAG = 0x00000002
  524. /* CryptQueryObject object type */
  525. CERT_QUERY_OBJECT_FILE = 1
  526. CERT_QUERY_OBJECT_BLOB = 2
  527. /* CryptQueryObject content type flags */
  528. CERT_QUERY_CONTENT_CERT = 1
  529. CERT_QUERY_CONTENT_CTL = 2
  530. CERT_QUERY_CONTENT_CRL = 3
  531. CERT_QUERY_CONTENT_SERIALIZED_STORE = 4
  532. CERT_QUERY_CONTENT_SERIALIZED_CERT = 5
  533. CERT_QUERY_CONTENT_SERIALIZED_CTL = 6
  534. CERT_QUERY_CONTENT_SERIALIZED_CRL = 7
  535. CERT_QUERY_CONTENT_PKCS7_SIGNED = 8
  536. CERT_QUERY_CONTENT_PKCS7_UNSIGNED = 9
  537. CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED = 10
  538. CERT_QUERY_CONTENT_PKCS10 = 11
  539. CERT_QUERY_CONTENT_PFX = 12
  540. CERT_QUERY_CONTENT_CERT_PAIR = 13
  541. CERT_QUERY_CONTENT_PFX_AND_LOAD = 14
  542. CERT_QUERY_CONTENT_FLAG_CERT = (1 << CERT_QUERY_CONTENT_CERT)
  543. CERT_QUERY_CONTENT_FLAG_CTL = (1 << CERT_QUERY_CONTENT_CTL)
  544. CERT_QUERY_CONTENT_FLAG_CRL = (1 << CERT_QUERY_CONTENT_CRL)
  545. CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE = (1 << CERT_QUERY_CONTENT_SERIALIZED_STORE)
  546. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT = (1 << CERT_QUERY_CONTENT_SERIALIZED_CERT)
  547. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL = (1 << CERT_QUERY_CONTENT_SERIALIZED_CTL)
  548. CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL = (1 << CERT_QUERY_CONTENT_SERIALIZED_CRL)
  549. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED)
  550. CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED = (1 << CERT_QUERY_CONTENT_PKCS7_UNSIGNED)
  551. CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED)
  552. CERT_QUERY_CONTENT_FLAG_PKCS10 = (1 << CERT_QUERY_CONTENT_PKCS10)
  553. CERT_QUERY_CONTENT_FLAG_PFX = (1 << CERT_QUERY_CONTENT_PFX)
  554. CERT_QUERY_CONTENT_FLAG_CERT_PAIR = (1 << CERT_QUERY_CONTENT_CERT_PAIR)
  555. CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD = (1 << CERT_QUERY_CONTENT_PFX_AND_LOAD)
  556. CERT_QUERY_CONTENT_FLAG_ALL = (CERT_QUERY_CONTENT_FLAG_CERT | CERT_QUERY_CONTENT_FLAG_CTL | CERT_QUERY_CONTENT_FLAG_CRL | CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED | CERT_QUERY_CONTENT_FLAG_PKCS10 | CERT_QUERY_CONTENT_FLAG_PFX | CERT_QUERY_CONTENT_FLAG_CERT_PAIR)
  557. CERT_QUERY_CONTENT_FLAG_ALL_ISSUER_CERT = (CERT_QUERY_CONTENT_FLAG_CERT | CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE | CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT | CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED | CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED)
  558. /* CryptQueryObject format type flags */
  559. CERT_QUERY_FORMAT_BINARY = 1
  560. CERT_QUERY_FORMAT_BASE64_ENCODED = 2
  561. CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED = 3
  562. CERT_QUERY_FORMAT_FLAG_BINARY = (1 << CERT_QUERY_FORMAT_BINARY)
  563. CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED = (1 << CERT_QUERY_FORMAT_BASE64_ENCODED)
  564. CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED = (1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED)
  565. CERT_QUERY_FORMAT_FLAG_ALL = (CERT_QUERY_FORMAT_FLAG_BINARY | CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED | CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED)
  566. /* CertGetNameString name types */
  567. CERT_NAME_EMAIL_TYPE = 1
  568. CERT_NAME_RDN_TYPE = 2
  569. CERT_NAME_ATTR_TYPE = 3
  570. CERT_NAME_SIMPLE_DISPLAY_TYPE = 4
  571. CERT_NAME_FRIENDLY_DISPLAY_TYPE = 5
  572. CERT_NAME_DNS_TYPE = 6
  573. CERT_NAME_URL_TYPE = 7
  574. CERT_NAME_UPN_TYPE = 8
  575. /* CertGetNameString flags */
  576. CERT_NAME_ISSUER_FLAG = 0x1
  577. CERT_NAME_DISABLE_IE4_UTF8_FLAG = 0x10000
  578. CERT_NAME_SEARCH_ALL_NAMES_FLAG = 0x2
  579. CERT_NAME_STR_ENABLE_PUNYCODE_FLAG = 0x00200000
  580. /* AuthType values for SSLExtraCertChainPolicyPara struct */
  581. AUTHTYPE_CLIENT = 1
  582. AUTHTYPE_SERVER = 2
  583. /* Checks values for SSLExtraCertChainPolicyPara struct */
  584. SECURITY_FLAG_IGNORE_REVOCATION = 0x00000080
  585. SECURITY_FLAG_IGNORE_UNKNOWN_CA = 0x00000100
  586. SECURITY_FLAG_IGNORE_WRONG_USAGE = 0x00000200
  587. SECURITY_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000
  588. SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000
  589. /* Flags for Crypt[Un]ProtectData */
  590. CRYPTPROTECT_UI_FORBIDDEN = 0x1
  591. CRYPTPROTECT_LOCAL_MACHINE = 0x4
  592. CRYPTPROTECT_CRED_SYNC = 0x8
  593. CRYPTPROTECT_AUDIT = 0x10
  594. CRYPTPROTECT_NO_RECOVERY = 0x20
  595. CRYPTPROTECT_VERIFY_PROTECTION = 0x40
  596. CRYPTPROTECT_CRED_REGENERATE = 0x80
  597. /* Flags for CryptProtectPromptStruct */
  598. CRYPTPROTECT_PROMPT_ON_UNPROTECT = 1
  599. CRYPTPROTECT_PROMPT_ON_PROTECT = 2
  600. CRYPTPROTECT_PROMPT_RESERVED = 4
  601. CRYPTPROTECT_PROMPT_STRONG = 8
  602. CRYPTPROTECT_PROMPT_REQUIRE_STRONG = 16
  603. )
  604. const (
  605. // flags for SetErrorMode
  606. SEM_FAILCRITICALERRORS = 0x0001
  607. SEM_NOALIGNMENTFAULTEXCEPT = 0x0004
  608. SEM_NOGPFAULTERRORBOX = 0x0002
  609. SEM_NOOPENFILEERRORBOX = 0x8000
  610. )
  611. const (
  612. // Priority class.
  613. ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
  614. BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
  615. HIGH_PRIORITY_CLASS = 0x00000080
  616. IDLE_PRIORITY_CLASS = 0x00000040
  617. NORMAL_PRIORITY_CLASS = 0x00000020
  618. PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000
  619. PROCESS_MODE_BACKGROUND_END = 0x00200000
  620. REALTIME_PRIORITY_CLASS = 0x00000100
  621. )
  622. /* wintrust.h constants for WinVerifyTrustEx */
  623. const (
  624. WTD_UI_ALL = 1
  625. WTD_UI_NONE = 2
  626. WTD_UI_NOBAD = 3
  627. WTD_UI_NOGOOD = 4
  628. WTD_REVOKE_NONE = 0
  629. WTD_REVOKE_WHOLECHAIN = 1
  630. WTD_CHOICE_FILE = 1
  631. WTD_CHOICE_CATALOG = 2
  632. WTD_CHOICE_BLOB = 3
  633. WTD_CHOICE_SIGNER = 4
  634. WTD_CHOICE_CERT = 5
  635. WTD_STATEACTION_IGNORE = 0x00000000
  636. WTD_STATEACTION_VERIFY = 0x00000001
  637. WTD_STATEACTION_CLOSE = 0x00000002
  638. WTD_STATEACTION_AUTO_CACHE = 0x00000003
  639. WTD_STATEACTION_AUTO_CACHE_FLUSH = 0x00000004
  640. WTD_USE_IE4_TRUST_FLAG = 0x1
  641. WTD_NO_IE4_CHAIN_FLAG = 0x2
  642. WTD_NO_POLICY_USAGE_FLAG = 0x4
  643. WTD_REVOCATION_CHECK_NONE = 0x10
  644. WTD_REVOCATION_CHECK_END_CERT = 0x20
  645. WTD_REVOCATION_CHECK_CHAIN = 0x40
  646. WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x80
  647. WTD_SAFER_FLAG = 0x100
  648. WTD_HASH_ONLY_FLAG = 0x200
  649. WTD_USE_DEFAULT_OSVER_CHECK = 0x400
  650. WTD_LIFETIME_SIGNING_FLAG = 0x800
  651. WTD_CACHE_ONLY_URL_RETRIEVAL = 0x1000
  652. WTD_DISABLE_MD2_MD4 = 0x2000
  653. WTD_MOTW = 0x4000
  654. WTD_UICONTEXT_EXECUTE = 0
  655. WTD_UICONTEXT_INSTALL = 1
  656. )
  657. var (
  658. OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00")
  659. OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00")
  660. OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00")
  661. WINTRUST_ACTION_GENERIC_VERIFY_V2 = GUID{
  662. Data1: 0xaac56b,
  663. Data2: 0xcd44,
  664. Data3: 0x11d0,
  665. Data4: [8]byte{0x8c, 0xc2, 0x0, 0xc0, 0x4f, 0xc2, 0x95, 0xee},
  666. }
  667. )
  668. // Pointer represents a pointer to an arbitrary Windows type.
  669. //
  670. // Pointer-typed fields may point to one of many different types. It's
  671. // up to the caller to provide a pointer to the appropriate type, cast
  672. // to Pointer. The caller must obey the unsafe.Pointer rules while
  673. // doing so.
  674. type Pointer *struct{}
  675. // Invented values to support what package os expects.
  676. type Timeval struct {
  677. Sec int32
  678. Usec int32
  679. }
  680. func (tv *Timeval) Nanoseconds() int64 {
  681. return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3
  682. }
  683. func NsecToTimeval(nsec int64) (tv Timeval) {
  684. tv.Sec = int32(nsec / 1e9)
  685. tv.Usec = int32(nsec % 1e9 / 1e3)
  686. return
  687. }
  688. type Overlapped struct {
  689. Internal uintptr
  690. InternalHigh uintptr
  691. Offset uint32
  692. OffsetHigh uint32
  693. HEvent Handle
  694. }
  695. type FileNotifyInformation struct {
  696. NextEntryOffset uint32
  697. Action uint32
  698. FileNameLength uint32
  699. FileName uint16
  700. }
  701. type Filetime struct {
  702. LowDateTime uint32
  703. HighDateTime uint32
  704. }
  705. // Nanoseconds returns Filetime ft in nanoseconds
  706. // since Epoch (00:00:00 UTC, January 1, 1970).
  707. func (ft *Filetime) Nanoseconds() int64 {
  708. // 100-nanosecond intervals since January 1, 1601
  709. nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)
  710. // change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
  711. nsec -= 116444736000000000
  712. // convert into nanoseconds
  713. nsec *= 100
  714. return nsec
  715. }
  716. func NsecToFiletime(nsec int64) (ft Filetime) {
  717. // convert into 100-nanosecond
  718. nsec /= 100
  719. // change starting time to January 1, 1601
  720. nsec += 116444736000000000
  721. // split into high / low
  722. ft.LowDateTime = uint32(nsec & 0xffffffff)
  723. ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff)
  724. return ft
  725. }
  726. type Win32finddata struct {
  727. FileAttributes uint32
  728. CreationTime Filetime
  729. LastAccessTime Filetime
  730. LastWriteTime Filetime
  731. FileSizeHigh uint32
  732. FileSizeLow uint32
  733. Reserved0 uint32
  734. Reserved1 uint32
  735. FileName [MAX_PATH - 1]uint16
  736. AlternateFileName [13]uint16
  737. }
  738. // This is the actual system call structure.
  739. // Win32finddata is what we committed to in Go 1.
  740. type win32finddata1 struct {
  741. FileAttributes uint32
  742. CreationTime Filetime
  743. LastAccessTime Filetime
  744. LastWriteTime Filetime
  745. FileSizeHigh uint32
  746. FileSizeLow uint32
  747. Reserved0 uint32
  748. Reserved1 uint32
  749. FileName [MAX_PATH]uint16
  750. AlternateFileName [14]uint16
  751. // The Microsoft documentation for this struct¹ describes three additional
  752. // fields: dwFileType, dwCreatorType, and wFinderFlags. However, those fields
  753. // are empirically only present in the macOS port of the Win32 API,² and thus
  754. // not needed for binaries built for Windows.
  755. //
  756. // ¹ https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-win32_find_dataw describe
  757. // ² https://golang.org/issue/42637#issuecomment-760715755.
  758. }
  759. func copyFindData(dst *Win32finddata, src *win32finddata1) {
  760. dst.FileAttributes = src.FileAttributes
  761. dst.CreationTime = src.CreationTime
  762. dst.LastAccessTime = src.LastAccessTime
  763. dst.LastWriteTime = src.LastWriteTime
  764. dst.FileSizeHigh = src.FileSizeHigh
  765. dst.FileSizeLow = src.FileSizeLow
  766. dst.Reserved0 = src.Reserved0
  767. dst.Reserved1 = src.Reserved1
  768. // The src is 1 element bigger than dst, but it must be NUL.
  769. copy(dst.FileName[:], src.FileName[:])
  770. copy(dst.AlternateFileName[:], src.AlternateFileName[:])
  771. }
  772. type ByHandleFileInformation struct {
  773. FileAttributes uint32
  774. CreationTime Filetime
  775. LastAccessTime Filetime
  776. LastWriteTime Filetime
  777. VolumeSerialNumber uint32
  778. FileSizeHigh uint32
  779. FileSizeLow uint32
  780. NumberOfLinks uint32
  781. FileIndexHigh uint32
  782. FileIndexLow uint32
  783. }
  784. const (
  785. GetFileExInfoStandard = 0
  786. GetFileExMaxInfoLevel = 1
  787. )
  788. type Win32FileAttributeData struct {
  789. FileAttributes uint32
  790. CreationTime Filetime
  791. LastAccessTime Filetime
  792. LastWriteTime Filetime
  793. FileSizeHigh uint32
  794. FileSizeLow uint32
  795. }
  796. // ShowWindow constants
  797. const (
  798. // winuser.h
  799. SW_HIDE = 0
  800. SW_NORMAL = 1
  801. SW_SHOWNORMAL = 1
  802. SW_SHOWMINIMIZED = 2
  803. SW_SHOWMAXIMIZED = 3
  804. SW_MAXIMIZE = 3
  805. SW_SHOWNOACTIVATE = 4
  806. SW_SHOW = 5
  807. SW_MINIMIZE = 6
  808. SW_SHOWMINNOACTIVE = 7
  809. SW_SHOWNA = 8
  810. SW_RESTORE = 9
  811. SW_SHOWDEFAULT = 10
  812. SW_FORCEMINIMIZE = 11
  813. )
  814. type StartupInfo struct {
  815. Cb uint32
  816. _ *uint16
  817. Desktop *uint16
  818. Title *uint16
  819. X uint32
  820. Y uint32
  821. XSize uint32
  822. YSize uint32
  823. XCountChars uint32
  824. YCountChars uint32
  825. FillAttribute uint32
  826. Flags uint32
  827. ShowWindow uint16
  828. _ uint16
  829. _ *byte
  830. StdInput Handle
  831. StdOutput Handle
  832. StdErr Handle
  833. }
  834. type StartupInfoEx struct {
  835. StartupInfo
  836. ProcThreadAttributeList *ProcThreadAttributeList
  837. }
  838. // ProcThreadAttributeList is a placeholder type to represent a PROC_THREAD_ATTRIBUTE_LIST.
  839. //
  840. // To create a *ProcThreadAttributeList, use NewProcThreadAttributeList, update
  841. // it with ProcThreadAttributeListContainer.Update, free its memory using
  842. // ProcThreadAttributeListContainer.Delete, and access the list itself using
  843. // ProcThreadAttributeListContainer.List.
  844. type ProcThreadAttributeList struct{}
  845. type ProcThreadAttributeListContainer struct {
  846. data *ProcThreadAttributeList
  847. pointers []unsafe.Pointer
  848. }
  849. type ProcessInformation struct {
  850. Process Handle
  851. Thread Handle
  852. ProcessId uint32
  853. ThreadId uint32
  854. }
  855. type ProcessEntry32 struct {
  856. Size uint32
  857. Usage uint32
  858. ProcessID uint32
  859. DefaultHeapID uintptr
  860. ModuleID uint32
  861. Threads uint32
  862. ParentProcessID uint32
  863. PriClassBase int32
  864. Flags uint32
  865. ExeFile [MAX_PATH]uint16
  866. }
  867. type ThreadEntry32 struct {
  868. Size uint32
  869. Usage uint32
  870. ThreadID uint32
  871. OwnerProcessID uint32
  872. BasePri int32
  873. DeltaPri int32
  874. Flags uint32
  875. }
  876. type ModuleEntry32 struct {
  877. Size uint32
  878. ModuleID uint32
  879. ProcessID uint32
  880. GlblcntUsage uint32
  881. ProccntUsage uint32
  882. ModBaseAddr uintptr
  883. ModBaseSize uint32
  884. ModuleHandle Handle
  885. Module [MAX_MODULE_NAME32 + 1]uint16
  886. ExePath [MAX_PATH]uint16
  887. }
  888. const SizeofModuleEntry32 = unsafe.Sizeof(ModuleEntry32{})
  889. type Systemtime struct {
  890. Year uint16
  891. Month uint16
  892. DayOfWeek uint16
  893. Day uint16
  894. Hour uint16
  895. Minute uint16
  896. Second uint16
  897. Milliseconds uint16
  898. }
  899. type Timezoneinformation struct {
  900. Bias int32
  901. StandardName [32]uint16
  902. StandardDate Systemtime
  903. StandardBias int32
  904. DaylightName [32]uint16
  905. DaylightDate Systemtime
  906. DaylightBias int32
  907. }
  908. // Socket related.
  909. const (
  910. AF_UNSPEC = 0
  911. AF_UNIX = 1
  912. AF_INET = 2
  913. AF_NETBIOS = 17
  914. AF_INET6 = 23
  915. AF_IRDA = 26
  916. AF_BTH = 32
  917. SOCK_STREAM = 1
  918. SOCK_DGRAM = 2
  919. SOCK_RAW = 3
  920. SOCK_RDM = 4
  921. SOCK_SEQPACKET = 5
  922. IPPROTO_IP = 0
  923. IPPROTO_ICMP = 1
  924. IPPROTO_IGMP = 2
  925. BTHPROTO_RFCOMM = 3
  926. IPPROTO_TCP = 6
  927. IPPROTO_UDP = 17
  928. IPPROTO_IPV6 = 41
  929. IPPROTO_ICMPV6 = 58
  930. IPPROTO_RM = 113
  931. SOL_SOCKET = 0xffff
  932. SO_REUSEADDR = 4
  933. SO_KEEPALIVE = 8
  934. SO_DONTROUTE = 16
  935. SO_BROADCAST = 32
  936. SO_LINGER = 128
  937. SO_RCVBUF = 0x1002
  938. SO_RCVTIMEO = 0x1006
  939. SO_SNDBUF = 0x1001
  940. SO_UPDATE_ACCEPT_CONTEXT = 0x700b
  941. SO_UPDATE_CONNECT_CONTEXT = 0x7010
  942. IOC_OUT = 0x40000000
  943. IOC_IN = 0x80000000
  944. IOC_VENDOR = 0x18000000
  945. IOC_INOUT = IOC_IN | IOC_OUT
  946. IOC_WS2 = 0x08000000
  947. SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6
  948. SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4
  949. SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12
  950. // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460
  951. IP_HDRINCL = 0x2
  952. IP_TOS = 0x3
  953. IP_TTL = 0x4
  954. IP_MULTICAST_IF = 0x9
  955. IP_MULTICAST_TTL = 0xa
  956. IP_MULTICAST_LOOP = 0xb
  957. IP_ADD_MEMBERSHIP = 0xc
  958. IP_DROP_MEMBERSHIP = 0xd
  959. IP_PKTINFO = 0x13
  960. IPV6_V6ONLY = 0x1b
  961. IPV6_UNICAST_HOPS = 0x4
  962. IPV6_MULTICAST_IF = 0x9
  963. IPV6_MULTICAST_HOPS = 0xa
  964. IPV6_MULTICAST_LOOP = 0xb
  965. IPV6_JOIN_GROUP = 0xc
  966. IPV6_LEAVE_GROUP = 0xd
  967. IPV6_PKTINFO = 0x13
  968. MSG_OOB = 0x1
  969. MSG_PEEK = 0x2
  970. MSG_DONTROUTE = 0x4
  971. MSG_WAITALL = 0x8
  972. MSG_TRUNC = 0x0100
  973. MSG_CTRUNC = 0x0200
  974. MSG_BCAST = 0x0400
  975. MSG_MCAST = 0x0800
  976. SOMAXCONN = 0x7fffffff
  977. TCP_NODELAY = 1
  978. SHUT_RD = 0
  979. SHUT_WR = 1
  980. SHUT_RDWR = 2
  981. WSADESCRIPTION_LEN = 256
  982. WSASYS_STATUS_LEN = 128
  983. )
  984. type WSABuf struct {
  985. Len uint32
  986. Buf *byte
  987. }
  988. type WSAMsg struct {
  989. Name *syscall.RawSockaddrAny
  990. Namelen int32
  991. Buffers *WSABuf
  992. BufferCount uint32
  993. Control WSABuf
  994. Flags uint32
  995. }
  996. // Flags for WSASocket
  997. const (
  998. WSA_FLAG_OVERLAPPED = 0x01
  999. WSA_FLAG_MULTIPOINT_C_ROOT = 0x02
  1000. WSA_FLAG_MULTIPOINT_C_LEAF = 0x04
  1001. WSA_FLAG_MULTIPOINT_D_ROOT = 0x08
  1002. WSA_FLAG_MULTIPOINT_D_LEAF = 0x10
  1003. WSA_FLAG_ACCESS_SYSTEM_SECURITY = 0x40
  1004. WSA_FLAG_NO_HANDLE_INHERIT = 0x80
  1005. WSA_FLAG_REGISTERED_IO = 0x100
  1006. )
  1007. // Invented values to support what package os expects.
  1008. const (
  1009. S_IFMT = 0x1f000
  1010. S_IFIFO = 0x1000
  1011. S_IFCHR = 0x2000
  1012. S_IFDIR = 0x4000
  1013. S_IFBLK = 0x6000
  1014. S_IFREG = 0x8000
  1015. S_IFLNK = 0xa000
  1016. S_IFSOCK = 0xc000
  1017. S_ISUID = 0x800
  1018. S_ISGID = 0x400
  1019. S_ISVTX = 0x200
  1020. S_IRUSR = 0x100
  1021. S_IWRITE = 0x80
  1022. S_IWUSR = 0x80
  1023. S_IXUSR = 0x40
  1024. )
  1025. const (
  1026. FILE_TYPE_CHAR = 0x0002
  1027. FILE_TYPE_DISK = 0x0001
  1028. FILE_TYPE_PIPE = 0x0003
  1029. FILE_TYPE_REMOTE = 0x8000
  1030. FILE_TYPE_UNKNOWN = 0x0000
  1031. )
  1032. type Hostent struct {
  1033. Name *byte
  1034. Aliases **byte
  1035. AddrType uint16
  1036. Length uint16
  1037. AddrList **byte
  1038. }
  1039. type Protoent struct {
  1040. Name *byte
  1041. Aliases **byte
  1042. Proto uint16
  1043. }
  1044. const (
  1045. DNS_TYPE_A = 0x0001
  1046. DNS_TYPE_NS = 0x0002
  1047. DNS_TYPE_MD = 0x0003
  1048. DNS_TYPE_MF = 0x0004
  1049. DNS_TYPE_CNAME = 0x0005
  1050. DNS_TYPE_SOA = 0x0006
  1051. DNS_TYPE_MB = 0x0007
  1052. DNS_TYPE_MG = 0x0008
  1053. DNS_TYPE_MR = 0x0009
  1054. DNS_TYPE_NULL = 0x000a
  1055. DNS_TYPE_WKS = 0x000b
  1056. DNS_TYPE_PTR = 0x000c
  1057. DNS_TYPE_HINFO = 0x000d
  1058. DNS_TYPE_MINFO = 0x000e
  1059. DNS_TYPE_MX = 0x000f
  1060. DNS_TYPE_TEXT = 0x0010
  1061. DNS_TYPE_RP = 0x0011
  1062. DNS_TYPE_AFSDB = 0x0012
  1063. DNS_TYPE_X25 = 0x0013
  1064. DNS_TYPE_ISDN = 0x0014
  1065. DNS_TYPE_RT = 0x0015
  1066. DNS_TYPE_NSAP = 0x0016
  1067. DNS_TYPE_NSAPPTR = 0x0017
  1068. DNS_TYPE_SIG = 0x0018
  1069. DNS_TYPE_KEY = 0x0019
  1070. DNS_TYPE_PX = 0x001a
  1071. DNS_TYPE_GPOS = 0x001b
  1072. DNS_TYPE_AAAA = 0x001c
  1073. DNS_TYPE_LOC = 0x001d
  1074. DNS_TYPE_NXT = 0x001e
  1075. DNS_TYPE_EID = 0x001f
  1076. DNS_TYPE_NIMLOC = 0x0020
  1077. DNS_TYPE_SRV = 0x0021
  1078. DNS_TYPE_ATMA = 0x0022
  1079. DNS_TYPE_NAPTR = 0x0023
  1080. DNS_TYPE_KX = 0x0024
  1081. DNS_TYPE_CERT = 0x0025
  1082. DNS_TYPE_A6 = 0x0026
  1083. DNS_TYPE_DNAME = 0x0027
  1084. DNS_TYPE_SINK = 0x0028
  1085. DNS_TYPE_OPT = 0x0029
  1086. DNS_TYPE_DS = 0x002B
  1087. DNS_TYPE_RRSIG = 0x002E
  1088. DNS_TYPE_NSEC = 0x002F
  1089. DNS_TYPE_DNSKEY = 0x0030
  1090. DNS_TYPE_DHCID = 0x0031
  1091. DNS_TYPE_UINFO = 0x0064
  1092. DNS_TYPE_UID = 0x0065
  1093. DNS_TYPE_GID = 0x0066
  1094. DNS_TYPE_UNSPEC = 0x0067
  1095. DNS_TYPE_ADDRS = 0x00f8
  1096. DNS_TYPE_TKEY = 0x00f9
  1097. DNS_TYPE_TSIG = 0x00fa
  1098. DNS_TYPE_IXFR = 0x00fb
  1099. DNS_TYPE_AXFR = 0x00fc
  1100. DNS_TYPE_MAILB = 0x00fd
  1101. DNS_TYPE_MAILA = 0x00fe
  1102. DNS_TYPE_ALL = 0x00ff
  1103. DNS_TYPE_ANY = 0x00ff
  1104. DNS_TYPE_WINS = 0xff01
  1105. DNS_TYPE_WINSR = 0xff02
  1106. DNS_TYPE_NBSTAT = 0xff01
  1107. )
  1108. const (
  1109. // flags inside DNSRecord.Dw
  1110. DnsSectionQuestion = 0x0000
  1111. DnsSectionAnswer = 0x0001
  1112. DnsSectionAuthority = 0x0002
  1113. DnsSectionAdditional = 0x0003
  1114. )
  1115. const (
  1116. // flags of WSALookupService
  1117. LUP_DEEP = 0x0001
  1118. LUP_CONTAINERS = 0x0002
  1119. LUP_NOCONTAINERS = 0x0004
  1120. LUP_NEAREST = 0x0008
  1121. LUP_RETURN_NAME = 0x0010
  1122. LUP_RETURN_TYPE = 0x0020
  1123. LUP_RETURN_VERSION = 0x0040
  1124. LUP_RETURN_COMMENT = 0x0080
  1125. LUP_RETURN_ADDR = 0x0100
  1126. LUP_RETURN_BLOB = 0x0200
  1127. LUP_RETURN_ALIASES = 0x0400
  1128. LUP_RETURN_QUERY_STRING = 0x0800
  1129. LUP_RETURN_ALL = 0x0FF0
  1130. LUP_RES_SERVICE = 0x8000
  1131. LUP_FLUSHCACHE = 0x1000
  1132. LUP_FLUSHPREVIOUS = 0x2000
  1133. LUP_NON_AUTHORITATIVE = 0x4000
  1134. LUP_SECURE = 0x8000
  1135. LUP_RETURN_PREFERRED_NAMES = 0x10000
  1136. LUP_DNS_ONLY = 0x20000
  1137. LUP_ADDRCONFIG = 0x100000
  1138. LUP_DUAL_ADDR = 0x200000
  1139. LUP_FILESERVER = 0x400000
  1140. LUP_DISABLE_IDN_ENCODING = 0x00800000
  1141. LUP_API_ANSI = 0x01000000
  1142. LUP_RESOLUTION_HANDLE = 0x80000000
  1143. )
  1144. const (
  1145. // values of WSAQUERYSET's namespace
  1146. NS_ALL = 0
  1147. NS_DNS = 12
  1148. NS_NLA = 15
  1149. NS_BTH = 16
  1150. NS_EMAIL = 37
  1151. NS_PNRPNAME = 38
  1152. NS_PNRPCLOUD = 39
  1153. )
  1154. type DNSSRVData struct {
  1155. Target *uint16
  1156. Priority uint16
  1157. Weight uint16
  1158. Port uint16
  1159. Pad uint16
  1160. }
  1161. type DNSPTRData struct {
  1162. Host *uint16
  1163. }
  1164. type DNSMXData struct {
  1165. NameExchange *uint16
  1166. Preference uint16
  1167. Pad uint16
  1168. }
  1169. type DNSTXTData struct {
  1170. StringCount uint16
  1171. StringArray [1]*uint16
  1172. }
  1173. type DNSRecord struct {
  1174. Next *DNSRecord
  1175. Name *uint16
  1176. Type uint16
  1177. Length uint16
  1178. Dw uint32
  1179. Ttl uint32
  1180. Reserved uint32
  1181. Data [40]byte
  1182. }
  1183. const (
  1184. TF_DISCONNECT = 1
  1185. TF_REUSE_SOCKET = 2
  1186. TF_WRITE_BEHIND = 4
  1187. TF_USE_DEFAULT_WORKER = 0
  1188. TF_USE_SYSTEM_THREAD = 16
  1189. TF_USE_KERNEL_APC = 32
  1190. )
  1191. type TransmitFileBuffers struct {
  1192. Head uintptr
  1193. HeadLength uint32
  1194. Tail uintptr
  1195. TailLength uint32
  1196. }
  1197. const (
  1198. IFF_UP = 1
  1199. IFF_BROADCAST = 2
  1200. IFF_LOOPBACK = 4
  1201. IFF_POINTTOPOINT = 8
  1202. IFF_MULTICAST = 16
  1203. )
  1204. const SIO_GET_INTERFACE_LIST = 0x4004747F
  1205. // TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old.
  1206. // will be fixed to change variable type as suitable.
  1207. type SockaddrGen [24]byte
  1208. type InterfaceInfo struct {
  1209. Flags uint32
  1210. Address SockaddrGen
  1211. BroadcastAddress SockaddrGen
  1212. Netmask SockaddrGen
  1213. }
  1214. type IpAddressString struct {
  1215. String [16]byte
  1216. }
  1217. type IpMaskString IpAddressString
  1218. type IpAddrString struct {
  1219. Next *IpAddrString
  1220. IpAddress IpAddressString
  1221. IpMask IpMaskString
  1222. Context uint32
  1223. }
  1224. const MAX_ADAPTER_NAME_LENGTH = 256
  1225. const MAX_ADAPTER_DESCRIPTION_LENGTH = 128
  1226. const MAX_ADAPTER_ADDRESS_LENGTH = 8
  1227. type IpAdapterInfo struct {
  1228. Next *IpAdapterInfo
  1229. ComboIndex uint32
  1230. AdapterName [MAX_ADAPTER_NAME_LENGTH + 4]byte
  1231. Description [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte
  1232. AddressLength uint32
  1233. Address [MAX_ADAPTER_ADDRESS_LENGTH]byte
  1234. Index uint32
  1235. Type uint32
  1236. DhcpEnabled uint32
  1237. CurrentIpAddress *IpAddrString
  1238. IpAddressList IpAddrString
  1239. GatewayList IpAddrString
  1240. DhcpServer IpAddrString
  1241. HaveWins bool
  1242. PrimaryWinsServer IpAddrString
  1243. SecondaryWinsServer IpAddrString
  1244. LeaseObtained int64
  1245. LeaseExpires int64
  1246. }
  1247. const MAXLEN_PHYSADDR = 8
  1248. const MAX_INTERFACE_NAME_LEN = 256
  1249. const MAXLEN_IFDESCR = 256
  1250. type MibIfRow struct {
  1251. Name [MAX_INTERFACE_NAME_LEN]uint16
  1252. Index uint32
  1253. Type uint32
  1254. Mtu uint32
  1255. Speed uint32
  1256. PhysAddrLen uint32
  1257. PhysAddr [MAXLEN_PHYSADDR]byte
  1258. AdminStatus uint32
  1259. OperStatus uint32
  1260. LastChange uint32
  1261. InOctets uint32
  1262. InUcastPkts uint32
  1263. InNUcastPkts uint32
  1264. InDiscards uint32
  1265. InErrors uint32
  1266. InUnknownProtos uint32
  1267. OutOctets uint32
  1268. OutUcastPkts uint32
  1269. OutNUcastPkts uint32
  1270. OutDiscards uint32
  1271. OutErrors uint32
  1272. OutQLen uint32
  1273. DescrLen uint32
  1274. Descr [MAXLEN_IFDESCR]byte
  1275. }
  1276. type CertInfo struct {
  1277. Version uint32
  1278. SerialNumber CryptIntegerBlob
  1279. SignatureAlgorithm CryptAlgorithmIdentifier
  1280. Issuer CertNameBlob
  1281. NotBefore Filetime
  1282. NotAfter Filetime
  1283. Subject CertNameBlob
  1284. SubjectPublicKeyInfo CertPublicKeyInfo
  1285. IssuerUniqueId CryptBitBlob
  1286. SubjectUniqueId CryptBitBlob
  1287. CountExtensions uint32
  1288. Extensions *CertExtension
  1289. }
  1290. type CertExtension struct {
  1291. ObjId *byte
  1292. Critical int32
  1293. Value CryptObjidBlob
  1294. }
  1295. type CryptAlgorithmIdentifier struct {
  1296. ObjId *byte
  1297. Parameters CryptObjidBlob
  1298. }
  1299. type CertPublicKeyInfo struct {
  1300. Algorithm CryptAlgorithmIdentifier
  1301. PublicKey CryptBitBlob
  1302. }
  1303. type DataBlob struct {
  1304. Size uint32
  1305. Data *byte
  1306. }
  1307. type CryptIntegerBlob DataBlob
  1308. type CryptUintBlob DataBlob
  1309. type CryptObjidBlob DataBlob
  1310. type CertNameBlob DataBlob
  1311. type CertRdnValueBlob DataBlob
  1312. type CertBlob DataBlob
  1313. type CrlBlob DataBlob
  1314. type CryptDataBlob DataBlob
  1315. type CryptHashBlob DataBlob
  1316. type CryptDigestBlob DataBlob
  1317. type CryptDerBlob DataBlob
  1318. type CryptAttrBlob DataBlob
  1319. type CryptBitBlob struct {
  1320. Size uint32
  1321. Data *byte
  1322. UnusedBits uint32
  1323. }
  1324. type CertContext struct {
  1325. EncodingType uint32
  1326. EncodedCert *byte
  1327. Length uint32
  1328. CertInfo *CertInfo
  1329. Store Handle
  1330. }
  1331. type CertChainContext struct {
  1332. Size uint32
  1333. TrustStatus CertTrustStatus
  1334. ChainCount uint32
  1335. Chains **CertSimpleChain
  1336. LowerQualityChainCount uint32
  1337. LowerQualityChains **CertChainContext
  1338. HasRevocationFreshnessTime uint32
  1339. RevocationFreshnessTime uint32
  1340. }
  1341. type CertTrustListInfo struct {
  1342. // Not implemented
  1343. }
  1344. type CertSimpleChain struct {
  1345. Size uint32
  1346. TrustStatus CertTrustStatus
  1347. NumElements uint32
  1348. Elements **CertChainElement
  1349. TrustListInfo *CertTrustListInfo
  1350. HasRevocationFreshnessTime uint32
  1351. RevocationFreshnessTime uint32
  1352. }
  1353. type CertChainElement struct {
  1354. Size uint32
  1355. CertContext *CertContext
  1356. TrustStatus CertTrustStatus
  1357. RevocationInfo *CertRevocationInfo
  1358. IssuanceUsage *CertEnhKeyUsage
  1359. ApplicationUsage *CertEnhKeyUsage
  1360. ExtendedErrorInfo *uint16
  1361. }
  1362. type CertRevocationCrlInfo struct {
  1363. // Not implemented
  1364. }
  1365. type CertRevocationInfo struct {
  1366. Size uint32
  1367. RevocationResult uint32
  1368. RevocationOid *byte
  1369. OidSpecificInfo Pointer
  1370. HasFreshnessTime uint32
  1371. FreshnessTime uint32
  1372. CrlInfo *CertRevocationCrlInfo
  1373. }
  1374. type CertTrustStatus struct {
  1375. ErrorStatus uint32
  1376. InfoStatus uint32
  1377. }
  1378. type CertUsageMatch struct {
  1379. Type uint32
  1380. Usage CertEnhKeyUsage
  1381. }
  1382. type CertEnhKeyUsage struct {
  1383. Length uint32
  1384. UsageIdentifiers **byte
  1385. }
  1386. type CertChainPara struct {
  1387. Size uint32
  1388. RequestedUsage CertUsageMatch
  1389. RequstedIssuancePolicy CertUsageMatch
  1390. URLRetrievalTimeout uint32
  1391. CheckRevocationFreshnessTime uint32
  1392. RevocationFreshnessTime uint32
  1393. CacheResync *Filetime
  1394. }
  1395. type CertChainPolicyPara struct {
  1396. Size uint32
  1397. Flags uint32
  1398. ExtraPolicyPara Pointer
  1399. }
  1400. type SSLExtraCertChainPolicyPara struct {
  1401. Size uint32
  1402. AuthType uint32
  1403. Checks uint32
  1404. ServerName *uint16
  1405. }
  1406. type CertChainPolicyStatus struct {
  1407. Size uint32
  1408. Error uint32
  1409. ChainIndex uint32
  1410. ElementIndex uint32
  1411. ExtraPolicyStatus Pointer
  1412. }
  1413. type CertPolicyInfo struct {
  1414. Identifier *byte
  1415. CountQualifiers uint32
  1416. Qualifiers *CertPolicyQualifierInfo
  1417. }
  1418. type CertPoliciesInfo struct {
  1419. Count uint32
  1420. PolicyInfos *CertPolicyInfo
  1421. }
  1422. type CertPolicyQualifierInfo struct {
  1423. // Not implemented
  1424. }
  1425. type CertStrongSignPara struct {
  1426. Size uint32
  1427. InfoChoice uint32
  1428. InfoOrSerializedInfoOrOID unsafe.Pointer
  1429. }
  1430. type CryptProtectPromptStruct struct {
  1431. Size uint32
  1432. PromptFlags uint32
  1433. App HWND
  1434. Prompt *uint16
  1435. }
  1436. type CertChainFindByIssuerPara struct {
  1437. Size uint32
  1438. UsageIdentifier *byte
  1439. KeySpec uint32
  1440. AcquirePrivateKeyFlags uint32
  1441. IssuerCount uint32
  1442. Issuer Pointer
  1443. FindCallback Pointer
  1444. FindArg Pointer
  1445. IssuerChainIndex *uint32
  1446. IssuerElementIndex *uint32
  1447. }
  1448. type WinTrustData struct {
  1449. Size uint32
  1450. PolicyCallbackData uintptr
  1451. SIPClientData uintptr
  1452. UIChoice uint32
  1453. RevocationChecks uint32
  1454. UnionChoice uint32
  1455. FileOrCatalogOrBlobOrSgnrOrCert unsafe.Pointer
  1456. StateAction uint32
  1457. StateData Handle
  1458. URLReference *uint16
  1459. ProvFlags uint32
  1460. UIContext uint32
  1461. SignatureSettings *WinTrustSignatureSettings
  1462. }
  1463. type WinTrustFileInfo struct {
  1464. Size uint32
  1465. FilePath *uint16
  1466. File Handle
  1467. KnownSubject *GUID
  1468. }
  1469. type WinTrustSignatureSettings struct {
  1470. Size uint32
  1471. Index uint32
  1472. Flags uint32
  1473. SecondarySigs uint32
  1474. VerifiedSigIndex uint32
  1475. CryptoPolicy *CertStrongSignPara
  1476. }
  1477. const (
  1478. // do not reorder
  1479. HKEY_CLASSES_ROOT = 0x80000000 + iota
  1480. HKEY_CURRENT_USER
  1481. HKEY_LOCAL_MACHINE
  1482. HKEY_USERS
  1483. HKEY_PERFORMANCE_DATA
  1484. HKEY_CURRENT_CONFIG
  1485. HKEY_DYN_DATA
  1486. KEY_QUERY_VALUE = 1
  1487. KEY_SET_VALUE = 2
  1488. KEY_CREATE_SUB_KEY = 4
  1489. KEY_ENUMERATE_SUB_KEYS = 8
  1490. KEY_NOTIFY = 16
  1491. KEY_CREATE_LINK = 32
  1492. KEY_WRITE = 0x20006
  1493. KEY_EXECUTE = 0x20019
  1494. KEY_READ = 0x20019
  1495. KEY_WOW64_64KEY = 0x0100
  1496. KEY_WOW64_32KEY = 0x0200
  1497. KEY_ALL_ACCESS = 0xf003f
  1498. )
  1499. const (
  1500. // do not reorder
  1501. REG_NONE = iota
  1502. REG_SZ
  1503. REG_EXPAND_SZ
  1504. REG_BINARY
  1505. REG_DWORD_LITTLE_ENDIAN
  1506. REG_DWORD_BIG_ENDIAN
  1507. REG_LINK
  1508. REG_MULTI_SZ
  1509. REG_RESOURCE_LIST
  1510. REG_FULL_RESOURCE_DESCRIPTOR
  1511. REG_RESOURCE_REQUIREMENTS_LIST
  1512. REG_QWORD_LITTLE_ENDIAN
  1513. REG_DWORD = REG_DWORD_LITTLE_ENDIAN
  1514. REG_QWORD = REG_QWORD_LITTLE_ENDIAN
  1515. )
  1516. const (
  1517. EVENT_MODIFY_STATE = 0x0002
  1518. EVENT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1519. MUTANT_QUERY_STATE = 0x0001
  1520. MUTANT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE
  1521. SEMAPHORE_MODIFY_STATE = 0x0002
  1522. SEMAPHORE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1523. TIMER_QUERY_STATE = 0x0001
  1524. TIMER_MODIFY_STATE = 0x0002
  1525. TIMER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE | TIMER_MODIFY_STATE
  1526. MUTEX_MODIFY_STATE = MUTANT_QUERY_STATE
  1527. MUTEX_ALL_ACCESS = MUTANT_ALL_ACCESS
  1528. CREATE_EVENT_MANUAL_RESET = 0x1
  1529. CREATE_EVENT_INITIAL_SET = 0x2
  1530. CREATE_MUTEX_INITIAL_OWNER = 0x1
  1531. )
  1532. type AddrinfoW struct {
  1533. Flags int32
  1534. Family int32
  1535. Socktype int32
  1536. Protocol int32
  1537. Addrlen uintptr
  1538. Canonname *uint16
  1539. Addr uintptr
  1540. Next *AddrinfoW
  1541. }
  1542. const (
  1543. AI_PASSIVE = 1
  1544. AI_CANONNAME = 2
  1545. AI_NUMERICHOST = 4
  1546. )
  1547. type GUID struct {
  1548. Data1 uint32
  1549. Data2 uint16
  1550. Data3 uint16
  1551. Data4 [8]byte
  1552. }
  1553. var WSAID_CONNECTEX = GUID{
  1554. 0x25a207b9,
  1555. 0xddf3,
  1556. 0x4660,
  1557. [8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e},
  1558. }
  1559. var WSAID_WSASENDMSG = GUID{
  1560. 0xa441e712,
  1561. 0x754f,
  1562. 0x43ca,
  1563. [8]byte{0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d},
  1564. }
  1565. var WSAID_WSARECVMSG = GUID{
  1566. 0xf689d7c8,
  1567. 0x6f1f,
  1568. 0x436b,
  1569. [8]byte{0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22},
  1570. }
  1571. const (
  1572. FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
  1573. FILE_SKIP_SET_EVENT_ON_HANDLE = 2
  1574. )
  1575. const (
  1576. WSAPROTOCOL_LEN = 255
  1577. MAX_PROTOCOL_CHAIN = 7
  1578. BASE_PROTOCOL = 1
  1579. LAYERED_PROTOCOL = 0
  1580. XP1_CONNECTIONLESS = 0x00000001
  1581. XP1_GUARANTEED_DELIVERY = 0x00000002
  1582. XP1_GUARANTEED_ORDER = 0x00000004
  1583. XP1_MESSAGE_ORIENTED = 0x00000008
  1584. XP1_PSEUDO_STREAM = 0x00000010
  1585. XP1_GRACEFUL_CLOSE = 0x00000020
  1586. XP1_EXPEDITED_DATA = 0x00000040
  1587. XP1_CONNECT_DATA = 0x00000080
  1588. XP1_DISCONNECT_DATA = 0x00000100
  1589. XP1_SUPPORT_BROADCAST = 0x00000200
  1590. XP1_SUPPORT_MULTIPOINT = 0x00000400
  1591. XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800
  1592. XP1_MULTIPOINT_DATA_PLANE = 0x00001000
  1593. XP1_QOS_SUPPORTED = 0x00002000
  1594. XP1_UNI_SEND = 0x00008000
  1595. XP1_UNI_RECV = 0x00010000
  1596. XP1_IFS_HANDLES = 0x00020000
  1597. XP1_PARTIAL_MESSAGE = 0x00040000
  1598. XP1_SAN_SUPPORT_SDP = 0x00080000
  1599. PFL_MULTIPLE_PROTO_ENTRIES = 0x00000001
  1600. PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002
  1601. PFL_HIDDEN = 0x00000004
  1602. PFL_MATCHES_PROTOCOL_ZERO = 0x00000008
  1603. PFL_NETWORKDIRECT_PROVIDER = 0x00000010
  1604. )
  1605. type WSAProtocolInfo struct {
  1606. ServiceFlags1 uint32
  1607. ServiceFlags2 uint32
  1608. ServiceFlags3 uint32
  1609. ServiceFlags4 uint32
  1610. ProviderFlags uint32
  1611. ProviderId GUID
  1612. CatalogEntryId uint32
  1613. ProtocolChain WSAProtocolChain
  1614. Version int32
  1615. AddressFamily int32
  1616. MaxSockAddr int32
  1617. MinSockAddr int32
  1618. SocketType int32
  1619. Protocol int32
  1620. ProtocolMaxOffset int32
  1621. NetworkByteOrder int32
  1622. SecurityScheme int32
  1623. MessageSize uint32
  1624. ProviderReserved uint32
  1625. ProtocolName [WSAPROTOCOL_LEN + 1]uint16
  1626. }
  1627. type WSAProtocolChain struct {
  1628. ChainLen int32
  1629. ChainEntries [MAX_PROTOCOL_CHAIN]uint32
  1630. }
  1631. type TCPKeepalive struct {
  1632. OnOff uint32
  1633. Time uint32
  1634. Interval uint32
  1635. }
  1636. type symbolicLinkReparseBuffer struct {
  1637. SubstituteNameOffset uint16
  1638. SubstituteNameLength uint16
  1639. PrintNameOffset uint16
  1640. PrintNameLength uint16
  1641. Flags uint32
  1642. PathBuffer [1]uint16
  1643. }
  1644. type mountPointReparseBuffer struct {
  1645. SubstituteNameOffset uint16
  1646. SubstituteNameLength uint16
  1647. PrintNameOffset uint16
  1648. PrintNameLength uint16
  1649. PathBuffer [1]uint16
  1650. }
  1651. type reparseDataBuffer struct {
  1652. ReparseTag uint32
  1653. ReparseDataLength uint16
  1654. Reserved uint16
  1655. // GenericReparseBuffer
  1656. reparseBuffer byte
  1657. }
  1658. const (
  1659. FSCTL_CREATE_OR_GET_OBJECT_ID = 0x0900C0
  1660. FSCTL_DELETE_OBJECT_ID = 0x0900A0
  1661. FSCTL_DELETE_REPARSE_POINT = 0x0900AC
  1662. FSCTL_DUPLICATE_EXTENTS_TO_FILE = 0x098344
  1663. FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX = 0x0983E8
  1664. FSCTL_FILESYSTEM_GET_STATISTICS = 0x090060
  1665. FSCTL_FILE_LEVEL_TRIM = 0x098208
  1666. FSCTL_FIND_FILES_BY_SID = 0x09008F
  1667. FSCTL_GET_COMPRESSION = 0x09003C
  1668. FSCTL_GET_INTEGRITY_INFORMATION = 0x09027C
  1669. FSCTL_GET_NTFS_VOLUME_DATA = 0x090064
  1670. FSCTL_GET_REFS_VOLUME_DATA = 0x0902D8
  1671. FSCTL_GET_OBJECT_ID = 0x09009C
  1672. FSCTL_GET_REPARSE_POINT = 0x0900A8
  1673. FSCTL_GET_RETRIEVAL_POINTER_COUNT = 0x09042B
  1674. FSCTL_GET_RETRIEVAL_POINTERS = 0x090073
  1675. FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT = 0x0903D3
  1676. FSCTL_IS_PATHNAME_VALID = 0x09002C
  1677. FSCTL_LMR_SET_LINK_TRACKING_INFORMATION = 0x1400EC
  1678. FSCTL_MARK_HANDLE = 0x0900FC
  1679. FSCTL_OFFLOAD_READ = 0x094264
  1680. FSCTL_OFFLOAD_WRITE = 0x098268
  1681. FSCTL_PIPE_PEEK = 0x11400C
  1682. FSCTL_PIPE_TRANSCEIVE = 0x11C017
  1683. FSCTL_PIPE_WAIT = 0x110018
  1684. FSCTL_QUERY_ALLOCATED_RANGES = 0x0940CF
  1685. FSCTL_QUERY_FAT_BPB = 0x090058
  1686. FSCTL_QUERY_FILE_REGIONS = 0x090284
  1687. FSCTL_QUERY_ON_DISK_VOLUME_INFO = 0x09013C
  1688. FSCTL_QUERY_SPARING_INFO = 0x090138
  1689. FSCTL_READ_FILE_USN_DATA = 0x0900EB
  1690. FSCTL_RECALL_FILE = 0x090117
  1691. FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT = 0x090440
  1692. FSCTL_SET_COMPRESSION = 0x09C040
  1693. FSCTL_SET_DEFECT_MANAGEMENT = 0x098134
  1694. FSCTL_SET_ENCRYPTION = 0x0900D7
  1695. FSCTL_SET_INTEGRITY_INFORMATION = 0x09C280
  1696. FSCTL_SET_INTEGRITY_INFORMATION_EX = 0x090380
  1697. FSCTL_SET_OBJECT_ID = 0x090098
  1698. FSCTL_SET_OBJECT_ID_EXTENDED = 0x0900BC
  1699. FSCTL_SET_REPARSE_POINT = 0x0900A4
  1700. FSCTL_SET_SPARSE = 0x0900C4
  1701. FSCTL_SET_ZERO_DATA = 0x0980C8
  1702. FSCTL_SET_ZERO_ON_DEALLOCATION = 0x090194
  1703. FSCTL_SIS_COPYFILE = 0x090100
  1704. FSCTL_WRITE_USN_CLOSE_RECORD = 0x0900EF
  1705. MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
  1706. IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
  1707. IO_REPARSE_TAG_SYMLINK = 0xA000000C
  1708. SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
  1709. )
  1710. const (
  1711. ComputerNameNetBIOS = 0
  1712. ComputerNameDnsHostname = 1
  1713. ComputerNameDnsDomain = 2
  1714. ComputerNameDnsFullyQualified = 3
  1715. ComputerNamePhysicalNetBIOS = 4
  1716. ComputerNamePhysicalDnsHostname = 5
  1717. ComputerNamePhysicalDnsDomain = 6
  1718. ComputerNamePhysicalDnsFullyQualified = 7
  1719. ComputerNameMax = 8
  1720. )
  1721. // For MessageBox()
  1722. const (
  1723. MB_OK = 0x00000000
  1724. MB_OKCANCEL = 0x00000001
  1725. MB_ABORTRETRYIGNORE = 0x00000002
  1726. MB_YESNOCANCEL = 0x00000003
  1727. MB_YESNO = 0x00000004
  1728. MB_RETRYCANCEL = 0x00000005
  1729. MB_CANCELTRYCONTINUE = 0x00000006
  1730. MB_ICONHAND = 0x00000010
  1731. MB_ICONQUESTION = 0x00000020
  1732. MB_ICONEXCLAMATION = 0x00000030
  1733. MB_ICONASTERISK = 0x00000040
  1734. MB_USERICON = 0x00000080
  1735. MB_ICONWARNING = MB_ICONEXCLAMATION
  1736. MB_ICONERROR = MB_ICONHAND
  1737. MB_ICONINFORMATION = MB_ICONASTERISK
  1738. MB_ICONSTOP = MB_ICONHAND
  1739. MB_DEFBUTTON1 = 0x00000000
  1740. MB_DEFBUTTON2 = 0x00000100
  1741. MB_DEFBUTTON3 = 0x00000200
  1742. MB_DEFBUTTON4 = 0x00000300
  1743. MB_APPLMODAL = 0x00000000
  1744. MB_SYSTEMMODAL = 0x00001000
  1745. MB_TASKMODAL = 0x00002000
  1746. MB_HELP = 0x00004000
  1747. MB_NOFOCUS = 0x00008000
  1748. MB_SETFOREGROUND = 0x00010000
  1749. MB_DEFAULT_DESKTOP_ONLY = 0x00020000
  1750. MB_TOPMOST = 0x00040000
  1751. MB_RIGHT = 0x00080000
  1752. MB_RTLREADING = 0x00100000
  1753. MB_SERVICE_NOTIFICATION = 0x00200000
  1754. )
  1755. const (
  1756. MOVEFILE_REPLACE_EXISTING = 0x1
  1757. MOVEFILE_COPY_ALLOWED = 0x2
  1758. MOVEFILE_DELAY_UNTIL_REBOOT = 0x4
  1759. MOVEFILE_WRITE_THROUGH = 0x8
  1760. MOVEFILE_CREATE_HARDLINK = 0x10
  1761. MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20
  1762. )
  1763. const GAA_FLAG_INCLUDE_PREFIX = 0x00000010
  1764. const (
  1765. IF_TYPE_OTHER = 1
  1766. IF_TYPE_ETHERNET_CSMACD = 6
  1767. IF_TYPE_ISO88025_TOKENRING = 9
  1768. IF_TYPE_PPP = 23
  1769. IF_TYPE_SOFTWARE_LOOPBACK = 24
  1770. IF_TYPE_ATM = 37
  1771. IF_TYPE_IEEE80211 = 71
  1772. IF_TYPE_TUNNEL = 131
  1773. IF_TYPE_IEEE1394 = 144
  1774. )
  1775. type SocketAddress struct {
  1776. Sockaddr *syscall.RawSockaddrAny
  1777. SockaddrLength int32
  1778. }
  1779. // IP returns an IPv4 or IPv6 address, or nil if the underlying SocketAddress is neither.
  1780. func (addr *SocketAddress) IP() net.IP {
  1781. if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet4{}) && addr.Sockaddr.Addr.Family == AF_INET {
  1782. return (*RawSockaddrInet4)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  1783. } else if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet6{}) && addr.Sockaddr.Addr.Family == AF_INET6 {
  1784. return (*RawSockaddrInet6)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  1785. }
  1786. return nil
  1787. }
  1788. type IpAdapterUnicastAddress struct {
  1789. Length uint32
  1790. Flags uint32
  1791. Next *IpAdapterUnicastAddress
  1792. Address SocketAddress
  1793. PrefixOrigin int32
  1794. SuffixOrigin int32
  1795. DadState int32
  1796. ValidLifetime uint32
  1797. PreferredLifetime uint32
  1798. LeaseLifetime uint32
  1799. OnLinkPrefixLength uint8
  1800. }
  1801. type IpAdapterAnycastAddress struct {
  1802. Length uint32
  1803. Flags uint32
  1804. Next *IpAdapterAnycastAddress
  1805. Address SocketAddress
  1806. }
  1807. type IpAdapterMulticastAddress struct {
  1808. Length uint32
  1809. Flags uint32
  1810. Next *IpAdapterMulticastAddress
  1811. Address SocketAddress
  1812. }
  1813. type IpAdapterDnsServerAdapter struct {
  1814. Length uint32
  1815. Reserved uint32
  1816. Next *IpAdapterDnsServerAdapter
  1817. Address SocketAddress
  1818. }
  1819. type IpAdapterPrefix struct {
  1820. Length uint32
  1821. Flags uint32
  1822. Next *IpAdapterPrefix
  1823. Address SocketAddress
  1824. PrefixLength uint32
  1825. }
  1826. type IpAdapterAddresses struct {
  1827. Length uint32
  1828. IfIndex uint32
  1829. Next *IpAdapterAddresses
  1830. AdapterName *byte
  1831. FirstUnicastAddress *IpAdapterUnicastAddress
  1832. FirstAnycastAddress *IpAdapterAnycastAddress
  1833. FirstMulticastAddress *IpAdapterMulticastAddress
  1834. FirstDnsServerAddress *IpAdapterDnsServerAdapter
  1835. DnsSuffix *uint16
  1836. Description *uint16
  1837. FriendlyName *uint16
  1838. PhysicalAddress [syscall.MAX_ADAPTER_ADDRESS_LENGTH]byte
  1839. PhysicalAddressLength uint32
  1840. Flags uint32
  1841. Mtu uint32
  1842. IfType uint32
  1843. OperStatus uint32
  1844. Ipv6IfIndex uint32
  1845. ZoneIndices [16]uint32
  1846. FirstPrefix *IpAdapterPrefix
  1847. TransmitLinkSpeed uint64
  1848. ReceiveLinkSpeed uint64
  1849. FirstWinsServerAddress *IpAdapterWinsServerAddress
  1850. FirstGatewayAddress *IpAdapterGatewayAddress
  1851. Ipv4Metric uint32
  1852. Ipv6Metric uint32
  1853. Luid uint64
  1854. Dhcpv4Server SocketAddress
  1855. CompartmentId uint32
  1856. NetworkGuid GUID
  1857. ConnectionType uint32
  1858. TunnelType uint32
  1859. Dhcpv6Server SocketAddress
  1860. Dhcpv6ClientDuid [MAX_DHCPV6_DUID_LENGTH]byte
  1861. Dhcpv6ClientDuidLength uint32
  1862. Dhcpv6Iaid uint32
  1863. FirstDnsSuffix *IpAdapterDNSSuffix
  1864. }
  1865. type IpAdapterWinsServerAddress struct {
  1866. Length uint32
  1867. Reserved uint32
  1868. Next *IpAdapterWinsServerAddress
  1869. Address SocketAddress
  1870. }
  1871. type IpAdapterGatewayAddress struct {
  1872. Length uint32
  1873. Reserved uint32
  1874. Next *IpAdapterGatewayAddress
  1875. Address SocketAddress
  1876. }
  1877. type IpAdapterDNSSuffix struct {
  1878. Next *IpAdapterDNSSuffix
  1879. String [MAX_DNS_SUFFIX_STRING_LENGTH]uint16
  1880. }
  1881. const (
  1882. IfOperStatusUp = 1
  1883. IfOperStatusDown = 2
  1884. IfOperStatusTesting = 3
  1885. IfOperStatusUnknown = 4
  1886. IfOperStatusDormant = 5
  1887. IfOperStatusNotPresent = 6
  1888. IfOperStatusLowerLayerDown = 7
  1889. )
  1890. // Console related constants used for the mode parameter to SetConsoleMode. See
  1891. // https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
  1892. const (
  1893. ENABLE_PROCESSED_INPUT = 0x1
  1894. ENABLE_LINE_INPUT = 0x2
  1895. ENABLE_ECHO_INPUT = 0x4
  1896. ENABLE_WINDOW_INPUT = 0x8
  1897. ENABLE_MOUSE_INPUT = 0x10
  1898. ENABLE_INSERT_MODE = 0x20
  1899. ENABLE_QUICK_EDIT_MODE = 0x40
  1900. ENABLE_EXTENDED_FLAGS = 0x80
  1901. ENABLE_AUTO_POSITION = 0x100
  1902. ENABLE_VIRTUAL_TERMINAL_INPUT = 0x200
  1903. ENABLE_PROCESSED_OUTPUT = 0x1
  1904. ENABLE_WRAP_AT_EOL_OUTPUT = 0x2
  1905. ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
  1906. DISABLE_NEWLINE_AUTO_RETURN = 0x8
  1907. ENABLE_LVB_GRID_WORLDWIDE = 0x10
  1908. )
  1909. type Coord struct {
  1910. X int16
  1911. Y int16
  1912. }
  1913. type SmallRect struct {
  1914. Left int16
  1915. Top int16
  1916. Right int16
  1917. Bottom int16
  1918. }
  1919. // Used with GetConsoleScreenBuffer to retrieve information about a console
  1920. // screen buffer. See
  1921. // https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str
  1922. // for details.
  1923. type ConsoleScreenBufferInfo struct {
  1924. Size Coord
  1925. CursorPosition Coord
  1926. Attributes uint16
  1927. Window SmallRect
  1928. MaximumWindowSize Coord
  1929. }
  1930. const UNIX_PATH_MAX = 108 // defined in afunix.h
  1931. const (
  1932. // flags for JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags
  1933. JOB_OBJECT_LIMIT_ACTIVE_PROCESS = 0x00000008
  1934. JOB_OBJECT_LIMIT_AFFINITY = 0x00000010
  1935. JOB_OBJECT_LIMIT_BREAKAWAY_OK = 0x00000800
  1936. JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x00000400
  1937. JOB_OBJECT_LIMIT_JOB_MEMORY = 0x00000200
  1938. JOB_OBJECT_LIMIT_JOB_TIME = 0x00000004
  1939. JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x00002000
  1940. JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME = 0x00000040
  1941. JOB_OBJECT_LIMIT_PRIORITY_CLASS = 0x00000020
  1942. JOB_OBJECT_LIMIT_PROCESS_MEMORY = 0x00000100
  1943. JOB_OBJECT_LIMIT_PROCESS_TIME = 0x00000002
  1944. JOB_OBJECT_LIMIT_SCHEDULING_CLASS = 0x00000080
  1945. JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK = 0x00001000
  1946. JOB_OBJECT_LIMIT_SUBSET_AFFINITY = 0x00004000
  1947. JOB_OBJECT_LIMIT_WORKINGSET = 0x00000001
  1948. )
  1949. type IO_COUNTERS struct {
  1950. ReadOperationCount uint64
  1951. WriteOperationCount uint64
  1952. OtherOperationCount uint64
  1953. ReadTransferCount uint64
  1954. WriteTransferCount uint64
  1955. OtherTransferCount uint64
  1956. }
  1957. type JOBOBJECT_EXTENDED_LIMIT_INFORMATION struct {
  1958. BasicLimitInformation JOBOBJECT_BASIC_LIMIT_INFORMATION
  1959. IoInfo IO_COUNTERS
  1960. ProcessMemoryLimit uintptr
  1961. JobMemoryLimit uintptr
  1962. PeakProcessMemoryUsed uintptr
  1963. PeakJobMemoryUsed uintptr
  1964. }
  1965. const (
  1966. // UIRestrictionsClass
  1967. JOB_OBJECT_UILIMIT_DESKTOP = 0x00000040
  1968. JOB_OBJECT_UILIMIT_DISPLAYSETTINGS = 0x00000010
  1969. JOB_OBJECT_UILIMIT_EXITWINDOWS = 0x00000080
  1970. JOB_OBJECT_UILIMIT_GLOBALATOMS = 0x00000020
  1971. JOB_OBJECT_UILIMIT_HANDLES = 0x00000001
  1972. JOB_OBJECT_UILIMIT_READCLIPBOARD = 0x00000002
  1973. JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = 0x00000008
  1974. JOB_OBJECT_UILIMIT_WRITECLIPBOARD = 0x00000004
  1975. )
  1976. type JOBOBJECT_BASIC_UI_RESTRICTIONS struct {
  1977. UIRestrictionsClass uint32
  1978. }
  1979. const (
  1980. // JobObjectInformationClass for QueryInformationJobObject and SetInformationJobObject
  1981. JobObjectAssociateCompletionPortInformation = 7
  1982. JobObjectBasicAccountingInformation = 1
  1983. JobObjectBasicAndIoAccountingInformation = 8
  1984. JobObjectBasicLimitInformation = 2
  1985. JobObjectBasicProcessIdList = 3
  1986. JobObjectBasicUIRestrictions = 4
  1987. JobObjectCpuRateControlInformation = 15
  1988. JobObjectEndOfJobTimeInformation = 6
  1989. JobObjectExtendedLimitInformation = 9
  1990. JobObjectGroupInformation = 11
  1991. JobObjectGroupInformationEx = 14
  1992. JobObjectLimitViolationInformation = 13
  1993. JobObjectLimitViolationInformation2 = 34
  1994. JobObjectNetRateControlInformation = 32
  1995. JobObjectNotificationLimitInformation = 12
  1996. JobObjectNotificationLimitInformation2 = 33
  1997. JobObjectSecurityLimitInformation = 5
  1998. )
  1999. const (
  2000. KF_FLAG_DEFAULT = 0x00000000
  2001. KF_FLAG_FORCE_APP_DATA_REDIRECTION = 0x00080000
  2002. KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET = 0x00040000
  2003. KF_FLAG_FORCE_PACKAGE_REDIRECTION = 0x00020000
  2004. KF_FLAG_NO_PACKAGE_REDIRECTION = 0x00010000
  2005. KF_FLAG_FORCE_APPCONTAINER_REDIRECTION = 0x00020000
  2006. KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000
  2007. KF_FLAG_CREATE = 0x00008000
  2008. KF_FLAG_DONT_VERIFY = 0x00004000
  2009. KF_FLAG_DONT_UNEXPAND = 0x00002000
  2010. KF_FLAG_NO_ALIAS = 0x00001000
  2011. KF_FLAG_INIT = 0x00000800
  2012. KF_FLAG_DEFAULT_PATH = 0x00000400
  2013. KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200
  2014. KF_FLAG_SIMPLE_IDLIST = 0x00000100
  2015. KF_FLAG_ALIAS_ONLY = 0x80000000
  2016. )
  2017. type OsVersionInfoEx struct {
  2018. osVersionInfoSize uint32
  2019. MajorVersion uint32
  2020. MinorVersion uint32
  2021. BuildNumber uint32
  2022. PlatformId uint32
  2023. CsdVersion [128]uint16
  2024. ServicePackMajor uint16
  2025. ServicePackMinor uint16
  2026. SuiteMask uint16
  2027. ProductType byte
  2028. _ byte
  2029. }
  2030. const (
  2031. EWX_LOGOFF = 0x00000000
  2032. EWX_SHUTDOWN = 0x00000001
  2033. EWX_REBOOT = 0x00000002
  2034. EWX_FORCE = 0x00000004
  2035. EWX_POWEROFF = 0x00000008
  2036. EWX_FORCEIFHUNG = 0x00000010
  2037. EWX_QUICKRESOLVE = 0x00000020
  2038. EWX_RESTARTAPPS = 0x00000040
  2039. EWX_HYBRID_SHUTDOWN = 0x00400000
  2040. EWX_BOOTOPTIONS = 0x01000000
  2041. SHTDN_REASON_FLAG_COMMENT_REQUIRED = 0x01000000
  2042. SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED = 0x02000000
  2043. SHTDN_REASON_FLAG_CLEAN_UI = 0x04000000
  2044. SHTDN_REASON_FLAG_DIRTY_UI = 0x08000000
  2045. SHTDN_REASON_FLAG_USER_DEFINED = 0x40000000
  2046. SHTDN_REASON_FLAG_PLANNED = 0x80000000
  2047. SHTDN_REASON_MAJOR_OTHER = 0x00000000
  2048. SHTDN_REASON_MAJOR_NONE = 0x00000000
  2049. SHTDN_REASON_MAJOR_HARDWARE = 0x00010000
  2050. SHTDN_REASON_MAJOR_OPERATINGSYSTEM = 0x00020000
  2051. SHTDN_REASON_MAJOR_SOFTWARE = 0x00030000
  2052. SHTDN_REASON_MAJOR_APPLICATION = 0x00040000
  2053. SHTDN_REASON_MAJOR_SYSTEM = 0x00050000
  2054. SHTDN_REASON_MAJOR_POWER = 0x00060000
  2055. SHTDN_REASON_MAJOR_LEGACY_API = 0x00070000
  2056. SHTDN_REASON_MINOR_OTHER = 0x00000000
  2057. SHTDN_REASON_MINOR_NONE = 0x000000ff
  2058. SHTDN_REASON_MINOR_MAINTENANCE = 0x00000001
  2059. SHTDN_REASON_MINOR_INSTALLATION = 0x00000002
  2060. SHTDN_REASON_MINOR_UPGRADE = 0x00000003
  2061. SHTDN_REASON_MINOR_RECONFIG = 0x00000004
  2062. SHTDN_REASON_MINOR_HUNG = 0x00000005
  2063. SHTDN_REASON_MINOR_UNSTABLE = 0x00000006
  2064. SHTDN_REASON_MINOR_DISK = 0x00000007
  2065. SHTDN_REASON_MINOR_PROCESSOR = 0x00000008
  2066. SHTDN_REASON_MINOR_NETWORKCARD = 0x00000009
  2067. SHTDN_REASON_MINOR_POWER_SUPPLY = 0x0000000a
  2068. SHTDN_REASON_MINOR_CORDUNPLUGGED = 0x0000000b
  2069. SHTDN_REASON_MINOR_ENVIRONMENT = 0x0000000c
  2070. SHTDN_REASON_MINOR_HARDWARE_DRIVER = 0x0000000d
  2071. SHTDN_REASON_MINOR_OTHERDRIVER = 0x0000000e
  2072. SHTDN_REASON_MINOR_BLUESCREEN = 0x0000000F
  2073. SHTDN_REASON_MINOR_SERVICEPACK = 0x00000010
  2074. SHTDN_REASON_MINOR_HOTFIX = 0x00000011
  2075. SHTDN_REASON_MINOR_SECURITYFIX = 0x00000012
  2076. SHTDN_REASON_MINOR_SECURITY = 0x00000013
  2077. SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = 0x00000014
  2078. SHTDN_REASON_MINOR_WMI = 0x00000015
  2079. SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL = 0x00000016
  2080. SHTDN_REASON_MINOR_HOTFIX_UNINSTALL = 0x00000017
  2081. SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL = 0x00000018
  2082. SHTDN_REASON_MINOR_MMC = 0x00000019
  2083. SHTDN_REASON_MINOR_SYSTEMRESTORE = 0x0000001a
  2084. SHTDN_REASON_MINOR_TERMSRV = 0x00000020
  2085. SHTDN_REASON_MINOR_DC_PROMOTION = 0x00000021
  2086. SHTDN_REASON_MINOR_DC_DEMOTION = 0x00000022
  2087. SHTDN_REASON_UNKNOWN = SHTDN_REASON_MINOR_NONE
  2088. SHTDN_REASON_LEGACY_API = SHTDN_REASON_MAJOR_LEGACY_API | SHTDN_REASON_FLAG_PLANNED
  2089. SHTDN_REASON_VALID_BIT_MASK = 0xc0ffffff
  2090. SHUTDOWN_NORETRY = 0x1
  2091. )
  2092. // Flags used for GetModuleHandleEx
  2093. const (
  2094. GET_MODULE_HANDLE_EX_FLAG_PIN = 1
  2095. GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2
  2096. GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 4
  2097. )
  2098. // MUI function flag values
  2099. const (
  2100. MUI_LANGUAGE_ID = 0x4
  2101. MUI_LANGUAGE_NAME = 0x8
  2102. MUI_MERGE_SYSTEM_FALLBACK = 0x10
  2103. MUI_MERGE_USER_FALLBACK = 0x20
  2104. MUI_UI_FALLBACK = MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK
  2105. MUI_THREAD_LANGUAGES = 0x40
  2106. MUI_CONSOLE_FILTER = 0x100
  2107. MUI_COMPLEX_SCRIPT_FILTER = 0x200
  2108. MUI_RESET_FILTERS = 0x001
  2109. MUI_USER_PREFERRED_UI_LANGUAGES = 0x10
  2110. MUI_USE_INSTALLED_LANGUAGES = 0x20
  2111. MUI_USE_SEARCH_ALL_LANGUAGES = 0x40
  2112. MUI_LANG_NEUTRAL_PE_FILE = 0x100
  2113. MUI_NON_LANG_NEUTRAL_FILE = 0x200
  2114. MUI_MACHINE_LANGUAGE_SETTINGS = 0x400
  2115. MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL = 0x001
  2116. MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN = 0x002
  2117. MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI = 0x004
  2118. MUI_QUERY_TYPE = 0x001
  2119. MUI_QUERY_CHECKSUM = 0x002
  2120. MUI_QUERY_LANGUAGE_NAME = 0x004
  2121. MUI_QUERY_RESOURCE_TYPES = 0x008
  2122. MUI_FILEINFO_VERSION = 0x001
  2123. MUI_FULL_LANGUAGE = 0x01
  2124. MUI_PARTIAL_LANGUAGE = 0x02
  2125. MUI_LIP_LANGUAGE = 0x04
  2126. MUI_LANGUAGE_INSTALLED = 0x20
  2127. MUI_LANGUAGE_LICENSED = 0x40
  2128. )
  2129. // FILE_INFO_BY_HANDLE_CLASS constants for SetFileInformationByHandle/GetFileInformationByHandleEx
  2130. const (
  2131. FileBasicInfo = 0
  2132. FileStandardInfo = 1
  2133. FileNameInfo = 2
  2134. FileRenameInfo = 3
  2135. FileDispositionInfo = 4
  2136. FileAllocationInfo = 5
  2137. FileEndOfFileInfo = 6
  2138. FileStreamInfo = 7
  2139. FileCompressionInfo = 8
  2140. FileAttributeTagInfo = 9
  2141. FileIdBothDirectoryInfo = 10
  2142. FileIdBothDirectoryRestartInfo = 11
  2143. FileIoPriorityHintInfo = 12
  2144. FileRemoteProtocolInfo = 13
  2145. FileFullDirectoryInfo = 14
  2146. FileFullDirectoryRestartInfo = 15
  2147. FileStorageInfo = 16
  2148. FileAlignmentInfo = 17
  2149. FileIdInfo = 18
  2150. FileIdExtdDirectoryInfo = 19
  2151. FileIdExtdDirectoryRestartInfo = 20
  2152. FileDispositionInfoEx = 21
  2153. FileRenameInfoEx = 22
  2154. FileCaseSensitiveInfo = 23
  2155. FileNormalizedNameInfo = 24
  2156. )
  2157. // LoadLibrary flags for determining from where to search for a DLL
  2158. const (
  2159. DONT_RESOLVE_DLL_REFERENCES = 0x1
  2160. LOAD_LIBRARY_AS_DATAFILE = 0x2
  2161. LOAD_WITH_ALTERED_SEARCH_PATH = 0x8
  2162. LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x10
  2163. LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x20
  2164. LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x40
  2165. LOAD_LIBRARY_REQUIRE_SIGNED_TARGET = 0x80
  2166. LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x100
  2167. LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x200
  2168. LOAD_LIBRARY_SEARCH_USER_DIRS = 0x400
  2169. LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x800
  2170. LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x1000
  2171. LOAD_LIBRARY_SAFE_CURRENT_DIRS = 0x00002000
  2172. LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER = 0x00004000
  2173. LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY = 0x00008000
  2174. )
  2175. // RegNotifyChangeKeyValue notifyFilter flags.
  2176. const (
  2177. // REG_NOTIFY_CHANGE_NAME notifies the caller if a subkey is added or deleted.
  2178. REG_NOTIFY_CHANGE_NAME = 0x00000001
  2179. // REG_NOTIFY_CHANGE_ATTRIBUTES notifies the caller of changes to the attributes of the key, such as the security descriptor information.
  2180. REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002
  2181. // REG_NOTIFY_CHANGE_LAST_SET notifies the caller of changes to a value of the key. This can include adding or deleting a value, or changing an existing value.
  2182. REG_NOTIFY_CHANGE_LAST_SET = 0x00000004
  2183. // REG_NOTIFY_CHANGE_SECURITY notifies the caller of changes to the security descriptor of the key.
  2184. REG_NOTIFY_CHANGE_SECURITY = 0x00000008
  2185. // REG_NOTIFY_THREAD_AGNOSTIC indicates that the lifetime of the registration must not be tied to the lifetime of the thread issuing the RegNotifyChangeKeyValue call. Note: This flag value is only supported in Windows 8 and later.
  2186. REG_NOTIFY_THREAD_AGNOSTIC = 0x10000000
  2187. )
  2188. type CommTimeouts struct {
  2189. ReadIntervalTimeout uint32
  2190. ReadTotalTimeoutMultiplier uint32
  2191. ReadTotalTimeoutConstant uint32
  2192. WriteTotalTimeoutMultiplier uint32
  2193. WriteTotalTimeoutConstant uint32
  2194. }
  2195. // NTUnicodeString is a UTF-16 string for NT native APIs, corresponding to UNICODE_STRING.
  2196. type NTUnicodeString struct {
  2197. Length uint16
  2198. MaximumLength uint16
  2199. Buffer *uint16
  2200. }
  2201. // NTString is an ANSI string for NT native APIs, corresponding to STRING.
  2202. type NTString struct {
  2203. Length uint16
  2204. MaximumLength uint16
  2205. Buffer *byte
  2206. }
  2207. type LIST_ENTRY struct {
  2208. Flink *LIST_ENTRY
  2209. Blink *LIST_ENTRY
  2210. }
  2211. type RUNTIME_FUNCTION struct {
  2212. BeginAddress uint32
  2213. EndAddress uint32
  2214. UnwindData uint32
  2215. }
  2216. type LDR_DATA_TABLE_ENTRY struct {
  2217. reserved1 [2]uintptr
  2218. InMemoryOrderLinks LIST_ENTRY
  2219. reserved2 [2]uintptr
  2220. DllBase uintptr
  2221. reserved3 [2]uintptr
  2222. FullDllName NTUnicodeString
  2223. reserved4 [8]byte
  2224. reserved5 [3]uintptr
  2225. reserved6 uintptr
  2226. TimeDateStamp uint32
  2227. }
  2228. type PEB_LDR_DATA struct {
  2229. reserved1 [8]byte
  2230. reserved2 [3]uintptr
  2231. InMemoryOrderModuleList LIST_ENTRY
  2232. }
  2233. type CURDIR struct {
  2234. DosPath NTUnicodeString
  2235. Handle Handle
  2236. }
  2237. type RTL_DRIVE_LETTER_CURDIR struct {
  2238. Flags uint16
  2239. Length uint16
  2240. TimeStamp uint32
  2241. DosPath NTString
  2242. }
  2243. type RTL_USER_PROCESS_PARAMETERS struct {
  2244. MaximumLength, Length uint32
  2245. Flags, DebugFlags uint32
  2246. ConsoleHandle Handle
  2247. ConsoleFlags uint32
  2248. StandardInput, StandardOutput, StandardError Handle
  2249. CurrentDirectory CURDIR
  2250. DllPath NTUnicodeString
  2251. ImagePathName NTUnicodeString
  2252. CommandLine NTUnicodeString
  2253. Environment unsafe.Pointer
  2254. StartingX, StartingY, CountX, CountY, CountCharsX, CountCharsY, FillAttribute uint32
  2255. WindowFlags, ShowWindowFlags uint32
  2256. WindowTitle, DesktopInfo, ShellInfo, RuntimeData NTUnicodeString
  2257. CurrentDirectories [32]RTL_DRIVE_LETTER_CURDIR
  2258. EnvironmentSize, EnvironmentVersion uintptr
  2259. PackageDependencyData unsafe.Pointer
  2260. ProcessGroupId uint32
  2261. LoaderThreads uint32
  2262. RedirectionDllName NTUnicodeString
  2263. HeapPartitionName NTUnicodeString
  2264. DefaultThreadpoolCpuSetMasks uintptr
  2265. DefaultThreadpoolCpuSetMaskCount uint32
  2266. }
  2267. type PEB struct {
  2268. reserved1 [2]byte
  2269. BeingDebugged byte
  2270. BitField byte
  2271. reserved3 uintptr
  2272. ImageBaseAddress uintptr
  2273. Ldr *PEB_LDR_DATA
  2274. ProcessParameters *RTL_USER_PROCESS_PARAMETERS
  2275. reserved4 [3]uintptr
  2276. AtlThunkSListPtr uintptr
  2277. reserved5 uintptr
  2278. reserved6 uint32
  2279. reserved7 uintptr
  2280. reserved8 uint32
  2281. AtlThunkSListPtr32 uint32
  2282. reserved9 [45]uintptr
  2283. reserved10 [96]byte
  2284. PostProcessInitRoutine uintptr
  2285. reserved11 [128]byte
  2286. reserved12 [1]uintptr
  2287. SessionId uint32
  2288. }
  2289. type OBJECT_ATTRIBUTES struct {
  2290. Length uint32
  2291. RootDirectory Handle
  2292. ObjectName *NTUnicodeString
  2293. Attributes uint32
  2294. SecurityDescriptor *SECURITY_DESCRIPTOR
  2295. SecurityQoS *SECURITY_QUALITY_OF_SERVICE
  2296. }
  2297. // Values for the Attributes member of OBJECT_ATTRIBUTES.
  2298. const (
  2299. OBJ_INHERIT = 0x00000002
  2300. OBJ_PERMANENT = 0x00000010
  2301. OBJ_EXCLUSIVE = 0x00000020
  2302. OBJ_CASE_INSENSITIVE = 0x00000040
  2303. OBJ_OPENIF = 0x00000080
  2304. OBJ_OPENLINK = 0x00000100
  2305. OBJ_KERNEL_HANDLE = 0x00000200
  2306. OBJ_FORCE_ACCESS_CHECK = 0x00000400
  2307. OBJ_IGNORE_IMPERSONATED_DEVICEMAP = 0x00000800
  2308. OBJ_DONT_REPARSE = 0x00001000
  2309. OBJ_VALID_ATTRIBUTES = 0x00001FF2
  2310. )
  2311. type IO_STATUS_BLOCK struct {
  2312. Status NTStatus
  2313. Information uintptr
  2314. }
  2315. type RTLP_CURDIR_REF struct {
  2316. RefCount int32
  2317. Handle Handle
  2318. }
  2319. type RTL_RELATIVE_NAME struct {
  2320. RelativeName NTUnicodeString
  2321. ContainingDirectory Handle
  2322. CurDirRef *RTLP_CURDIR_REF
  2323. }
  2324. const (
  2325. // CreateDisposition flags for NtCreateFile and NtCreateNamedPipeFile.
  2326. FILE_SUPERSEDE = 0x00000000
  2327. FILE_OPEN = 0x00000001
  2328. FILE_CREATE = 0x00000002
  2329. FILE_OPEN_IF = 0x00000003
  2330. FILE_OVERWRITE = 0x00000004
  2331. FILE_OVERWRITE_IF = 0x00000005
  2332. FILE_MAXIMUM_DISPOSITION = 0x00000005
  2333. // CreateOptions flags for NtCreateFile and NtCreateNamedPipeFile.
  2334. FILE_DIRECTORY_FILE = 0x00000001
  2335. FILE_WRITE_THROUGH = 0x00000002
  2336. FILE_SEQUENTIAL_ONLY = 0x00000004
  2337. FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008
  2338. FILE_SYNCHRONOUS_IO_ALERT = 0x00000010
  2339. FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020
  2340. FILE_NON_DIRECTORY_FILE = 0x00000040
  2341. FILE_CREATE_TREE_CONNECTION = 0x00000080
  2342. FILE_COMPLETE_IF_OPLOCKED = 0x00000100
  2343. FILE_NO_EA_KNOWLEDGE = 0x00000200
  2344. FILE_OPEN_REMOTE_INSTANCE = 0x00000400
  2345. FILE_RANDOM_ACCESS = 0x00000800
  2346. FILE_DELETE_ON_CLOSE = 0x00001000
  2347. FILE_OPEN_BY_FILE_ID = 0x00002000
  2348. FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000
  2349. FILE_NO_COMPRESSION = 0x00008000
  2350. FILE_OPEN_REQUIRING_OPLOCK = 0x00010000
  2351. FILE_DISALLOW_EXCLUSIVE = 0x00020000
  2352. FILE_RESERVE_OPFILTER = 0x00100000
  2353. FILE_OPEN_REPARSE_POINT = 0x00200000
  2354. FILE_OPEN_NO_RECALL = 0x00400000
  2355. FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
  2356. // Parameter constants for NtCreateNamedPipeFile.
  2357. FILE_PIPE_BYTE_STREAM_TYPE = 0x00000000
  2358. FILE_PIPE_MESSAGE_TYPE = 0x00000001
  2359. FILE_PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000
  2360. FILE_PIPE_REJECT_REMOTE_CLIENTS = 0x00000002
  2361. FILE_PIPE_TYPE_VALID_MASK = 0x00000003
  2362. FILE_PIPE_BYTE_STREAM_MODE = 0x00000000
  2363. FILE_PIPE_MESSAGE_MODE = 0x00000001
  2364. FILE_PIPE_QUEUE_OPERATION = 0x00000000
  2365. FILE_PIPE_COMPLETE_OPERATION = 0x00000001
  2366. FILE_PIPE_INBOUND = 0x00000000
  2367. FILE_PIPE_OUTBOUND = 0x00000001
  2368. FILE_PIPE_FULL_DUPLEX = 0x00000002
  2369. FILE_PIPE_DISCONNECTED_STATE = 0x00000001
  2370. FILE_PIPE_LISTENING_STATE = 0x00000002
  2371. FILE_PIPE_CONNECTED_STATE = 0x00000003
  2372. FILE_PIPE_CLOSING_STATE = 0x00000004
  2373. FILE_PIPE_CLIENT_END = 0x00000000
  2374. FILE_PIPE_SERVER_END = 0x00000001
  2375. )
  2376. const (
  2377. // FileInformationClass for NtSetInformationFile
  2378. FileBasicInformation = 4
  2379. FileRenameInformation = 10
  2380. FileDispositionInformation = 13
  2381. FilePositionInformation = 14
  2382. FileEndOfFileInformation = 20
  2383. FileValidDataLengthInformation = 39
  2384. FileShortNameInformation = 40
  2385. FileIoPriorityHintInformation = 43
  2386. FileReplaceCompletionInformation = 61
  2387. FileDispositionInformationEx = 64
  2388. FileCaseSensitiveInformation = 71
  2389. FileLinkInformation = 72
  2390. FileCaseSensitiveInformationForceAccessCheck = 75
  2391. FileKnownFolderInformation = 76
  2392. // Flags for FILE_RENAME_INFORMATION
  2393. FILE_RENAME_REPLACE_IF_EXISTS = 0x00000001
  2394. FILE_RENAME_POSIX_SEMANTICS = 0x00000002
  2395. FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE = 0x00000004
  2396. FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008
  2397. FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE = 0x00000010
  2398. FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE = 0x00000020
  2399. FILE_RENAME_PRESERVE_AVAILABLE_SPACE = 0x00000030
  2400. FILE_RENAME_IGNORE_READONLY_ATTRIBUTE = 0x00000040
  2401. FILE_RENAME_FORCE_RESIZE_TARGET_SR = 0x00000080
  2402. FILE_RENAME_FORCE_RESIZE_SOURCE_SR = 0x00000100
  2403. FILE_RENAME_FORCE_RESIZE_SR = 0x00000180
  2404. // Flags for FILE_DISPOSITION_INFORMATION_EX
  2405. FILE_DISPOSITION_DO_NOT_DELETE = 0x00000000
  2406. FILE_DISPOSITION_DELETE = 0x00000001
  2407. FILE_DISPOSITION_POSIX_SEMANTICS = 0x00000002
  2408. FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK = 0x00000004
  2409. FILE_DISPOSITION_ON_CLOSE = 0x00000008
  2410. FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE = 0x00000010
  2411. // Flags for FILE_CASE_SENSITIVE_INFORMATION
  2412. FILE_CS_FLAG_CASE_SENSITIVE_DIR = 0x00000001
  2413. // Flags for FILE_LINK_INFORMATION
  2414. FILE_LINK_REPLACE_IF_EXISTS = 0x00000001
  2415. FILE_LINK_POSIX_SEMANTICS = 0x00000002
  2416. FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008
  2417. FILE_LINK_NO_INCREASE_AVAILABLE_SPACE = 0x00000010
  2418. FILE_LINK_NO_DECREASE_AVAILABLE_SPACE = 0x00000020
  2419. FILE_LINK_PRESERVE_AVAILABLE_SPACE = 0x00000030
  2420. FILE_LINK_IGNORE_READONLY_ATTRIBUTE = 0x00000040
  2421. FILE_LINK_FORCE_RESIZE_TARGET_SR = 0x00000080
  2422. FILE_LINK_FORCE_RESIZE_SOURCE_SR = 0x00000100
  2423. FILE_LINK_FORCE_RESIZE_SR = 0x00000180
  2424. )
  2425. // ProcessInformationClasses for NtQueryInformationProcess and NtSetInformationProcess.
  2426. const (
  2427. ProcessBasicInformation = iota
  2428. ProcessQuotaLimits
  2429. ProcessIoCounters
  2430. ProcessVmCounters
  2431. ProcessTimes
  2432. ProcessBasePriority
  2433. ProcessRaisePriority
  2434. ProcessDebugPort
  2435. ProcessExceptionPort
  2436. ProcessAccessToken
  2437. ProcessLdtInformation
  2438. ProcessLdtSize
  2439. ProcessDefaultHardErrorMode
  2440. ProcessIoPortHandlers
  2441. ProcessPooledUsageAndLimits
  2442. ProcessWorkingSetWatch
  2443. ProcessUserModeIOPL
  2444. ProcessEnableAlignmentFaultFixup
  2445. ProcessPriorityClass
  2446. ProcessWx86Information
  2447. ProcessHandleCount
  2448. ProcessAffinityMask
  2449. ProcessPriorityBoost
  2450. ProcessDeviceMap
  2451. ProcessSessionInformation
  2452. ProcessForegroundInformation
  2453. ProcessWow64Information
  2454. ProcessImageFileName
  2455. ProcessLUIDDeviceMapsEnabled
  2456. ProcessBreakOnTermination
  2457. ProcessDebugObjectHandle
  2458. ProcessDebugFlags
  2459. ProcessHandleTracing
  2460. ProcessIoPriority
  2461. ProcessExecuteFlags
  2462. ProcessTlsInformation
  2463. ProcessCookie
  2464. ProcessImageInformation
  2465. ProcessCycleTime
  2466. ProcessPagePriority
  2467. ProcessInstrumentationCallback
  2468. ProcessThreadStackAllocation
  2469. ProcessWorkingSetWatchEx
  2470. ProcessImageFileNameWin32
  2471. ProcessImageFileMapping
  2472. ProcessAffinityUpdateMode
  2473. ProcessMemoryAllocationMode
  2474. ProcessGroupInformation
  2475. ProcessTokenVirtualizationEnabled
  2476. ProcessConsoleHostProcess
  2477. ProcessWindowInformation
  2478. ProcessHandleInformation
  2479. ProcessMitigationPolicy
  2480. ProcessDynamicFunctionTableInformation
  2481. ProcessHandleCheckingMode
  2482. ProcessKeepAliveCount
  2483. ProcessRevokeFileHandles
  2484. ProcessWorkingSetControl
  2485. ProcessHandleTable
  2486. ProcessCheckStackExtentsMode
  2487. ProcessCommandLineInformation
  2488. ProcessProtectionInformation
  2489. ProcessMemoryExhaustion
  2490. ProcessFaultInformation
  2491. ProcessTelemetryIdInformation
  2492. ProcessCommitReleaseInformation
  2493. ProcessDefaultCpuSetsInformation
  2494. ProcessAllowedCpuSetsInformation
  2495. ProcessSubsystemProcess
  2496. ProcessJobMemoryInformation
  2497. ProcessInPrivate
  2498. ProcessRaiseUMExceptionOnInvalidHandleClose
  2499. ProcessIumChallengeResponse
  2500. ProcessChildProcessInformation
  2501. ProcessHighGraphicsPriorityInformation
  2502. ProcessSubsystemInformation
  2503. ProcessEnergyValues
  2504. ProcessActivityThrottleState
  2505. ProcessActivityThrottlePolicy
  2506. ProcessWin32kSyscallFilterInformation
  2507. ProcessDisableSystemAllowedCpuSets
  2508. ProcessWakeInformation
  2509. ProcessEnergyTrackingState
  2510. ProcessManageWritesToExecutableMemory
  2511. ProcessCaptureTrustletLiveDump
  2512. ProcessTelemetryCoverage
  2513. ProcessEnclaveInformation
  2514. ProcessEnableReadWriteVmLogging
  2515. ProcessUptimeInformation
  2516. ProcessImageSection
  2517. ProcessDebugAuthInformation
  2518. ProcessSystemResourceManagement
  2519. ProcessSequenceNumber
  2520. ProcessLoaderDetour
  2521. ProcessSecurityDomainInformation
  2522. ProcessCombineSecurityDomainsInformation
  2523. ProcessEnableLogging
  2524. ProcessLeapSecondInformation
  2525. ProcessFiberShadowStackAllocation
  2526. ProcessFreeFiberShadowStackAllocation
  2527. ProcessAltSystemCallInformation
  2528. ProcessDynamicEHContinuationTargets
  2529. ProcessDynamicEnforcedCetCompatibleRanges
  2530. )
  2531. type PROCESS_BASIC_INFORMATION struct {
  2532. ExitStatus NTStatus
  2533. PebBaseAddress *PEB
  2534. AffinityMask uintptr
  2535. BasePriority int32
  2536. UniqueProcessId uintptr
  2537. InheritedFromUniqueProcessId uintptr
  2538. }
  2539. type SYSTEM_PROCESS_INFORMATION struct {
  2540. NextEntryOffset uint32
  2541. NumberOfThreads uint32
  2542. WorkingSetPrivateSize int64
  2543. HardFaultCount uint32
  2544. NumberOfThreadsHighWatermark uint32
  2545. CycleTime uint64
  2546. CreateTime int64
  2547. UserTime int64
  2548. KernelTime int64
  2549. ImageName NTUnicodeString
  2550. BasePriority int32
  2551. UniqueProcessID uintptr
  2552. InheritedFromUniqueProcessID uintptr
  2553. HandleCount uint32
  2554. SessionID uint32
  2555. UniqueProcessKey *uint32
  2556. PeakVirtualSize uintptr
  2557. VirtualSize uintptr
  2558. PageFaultCount uint32
  2559. PeakWorkingSetSize uintptr
  2560. WorkingSetSize uintptr
  2561. QuotaPeakPagedPoolUsage uintptr
  2562. QuotaPagedPoolUsage uintptr
  2563. QuotaPeakNonPagedPoolUsage uintptr
  2564. QuotaNonPagedPoolUsage uintptr
  2565. PagefileUsage uintptr
  2566. PeakPagefileUsage uintptr
  2567. PrivatePageCount uintptr
  2568. ReadOperationCount int64
  2569. WriteOperationCount int64
  2570. OtherOperationCount int64
  2571. ReadTransferCount int64
  2572. WriteTransferCount int64
  2573. OtherTransferCount int64
  2574. }
  2575. // SystemInformationClasses for NtQuerySystemInformation and NtSetSystemInformation
  2576. const (
  2577. SystemBasicInformation = iota
  2578. SystemProcessorInformation
  2579. SystemPerformanceInformation
  2580. SystemTimeOfDayInformation
  2581. SystemPathInformation
  2582. SystemProcessInformation
  2583. SystemCallCountInformation
  2584. SystemDeviceInformation
  2585. SystemProcessorPerformanceInformation
  2586. SystemFlagsInformation
  2587. SystemCallTimeInformation
  2588. SystemModuleInformation
  2589. SystemLocksInformation
  2590. SystemStackTraceInformation
  2591. SystemPagedPoolInformation
  2592. SystemNonPagedPoolInformation
  2593. SystemHandleInformation
  2594. SystemObjectInformation
  2595. SystemPageFileInformation
  2596. SystemVdmInstemulInformation
  2597. SystemVdmBopInformation
  2598. SystemFileCacheInformation
  2599. SystemPoolTagInformation
  2600. SystemInterruptInformation
  2601. SystemDpcBehaviorInformation
  2602. SystemFullMemoryInformation
  2603. SystemLoadGdiDriverInformation
  2604. SystemUnloadGdiDriverInformation
  2605. SystemTimeAdjustmentInformation
  2606. SystemSummaryMemoryInformation
  2607. SystemMirrorMemoryInformation
  2608. SystemPerformanceTraceInformation
  2609. systemObsolete0
  2610. SystemExceptionInformation
  2611. SystemCrashDumpStateInformation
  2612. SystemKernelDebuggerInformation
  2613. SystemContextSwitchInformation
  2614. SystemRegistryQuotaInformation
  2615. SystemExtendServiceTableInformation
  2616. SystemPrioritySeperation
  2617. SystemVerifierAddDriverInformation
  2618. SystemVerifierRemoveDriverInformation
  2619. SystemProcessorIdleInformation
  2620. SystemLegacyDriverInformation
  2621. SystemCurrentTimeZoneInformation
  2622. SystemLookasideInformation
  2623. SystemTimeSlipNotification
  2624. SystemSessionCreate
  2625. SystemSessionDetach
  2626. SystemSessionInformation
  2627. SystemRangeStartInformation
  2628. SystemVerifierInformation
  2629. SystemVerifierThunkExtend
  2630. SystemSessionProcessInformation
  2631. SystemLoadGdiDriverInSystemSpace
  2632. SystemNumaProcessorMap
  2633. SystemPrefetcherInformation
  2634. SystemExtendedProcessInformation
  2635. SystemRecommendedSharedDataAlignment
  2636. SystemComPlusPackage
  2637. SystemNumaAvailableMemory
  2638. SystemProcessorPowerInformation
  2639. SystemEmulationBasicInformation
  2640. SystemEmulationProcessorInformation
  2641. SystemExtendedHandleInformation
  2642. SystemLostDelayedWriteInformation
  2643. SystemBigPoolInformation
  2644. SystemSessionPoolTagInformation
  2645. SystemSessionMappedViewInformation
  2646. SystemHotpatchInformation
  2647. SystemObjectSecurityMode
  2648. SystemWatchdogTimerHandler
  2649. SystemWatchdogTimerInformation
  2650. SystemLogicalProcessorInformation
  2651. SystemWow64SharedInformationObsolete
  2652. SystemRegisterFirmwareTableInformationHandler
  2653. SystemFirmwareTableInformation
  2654. SystemModuleInformationEx
  2655. SystemVerifierTriageInformation
  2656. SystemSuperfetchInformation
  2657. SystemMemoryListInformation
  2658. SystemFileCacheInformationEx
  2659. SystemThreadPriorityClientIdInformation
  2660. SystemProcessorIdleCycleTimeInformation
  2661. SystemVerifierCancellationInformation
  2662. SystemProcessorPowerInformationEx
  2663. SystemRefTraceInformation
  2664. SystemSpecialPoolInformation
  2665. SystemProcessIdInformation
  2666. SystemErrorPortInformation
  2667. SystemBootEnvironmentInformation
  2668. SystemHypervisorInformation
  2669. SystemVerifierInformationEx
  2670. SystemTimeZoneInformation
  2671. SystemImageFileExecutionOptionsInformation
  2672. SystemCoverageInformation
  2673. SystemPrefetchPatchInformation
  2674. SystemVerifierFaultsInformation
  2675. SystemSystemPartitionInformation
  2676. SystemSystemDiskInformation
  2677. SystemProcessorPerformanceDistribution
  2678. SystemNumaProximityNodeInformation
  2679. SystemDynamicTimeZoneInformation
  2680. SystemCodeIntegrityInformation
  2681. SystemProcessorMicrocodeUpdateInformation
  2682. SystemProcessorBrandString
  2683. SystemVirtualAddressInformation
  2684. SystemLogicalProcessorAndGroupInformation
  2685. SystemProcessorCycleTimeInformation
  2686. SystemStoreInformation
  2687. SystemRegistryAppendString
  2688. SystemAitSamplingValue
  2689. SystemVhdBootInformation
  2690. SystemCpuQuotaInformation
  2691. SystemNativeBasicInformation
  2692. systemSpare1
  2693. SystemLowPriorityIoInformation
  2694. SystemTpmBootEntropyInformation
  2695. SystemVerifierCountersInformation
  2696. SystemPagedPoolInformationEx
  2697. SystemSystemPtesInformationEx
  2698. SystemNodeDistanceInformation
  2699. SystemAcpiAuditInformation
  2700. SystemBasicPerformanceInformation
  2701. SystemQueryPerformanceCounterInformation
  2702. SystemSessionBigPoolInformation
  2703. SystemBootGraphicsInformation
  2704. SystemScrubPhysicalMemoryInformation
  2705. SystemBadPageInformation
  2706. SystemProcessorProfileControlArea
  2707. SystemCombinePhysicalMemoryInformation
  2708. SystemEntropyInterruptTimingCallback
  2709. SystemConsoleInformation
  2710. SystemPlatformBinaryInformation
  2711. SystemThrottleNotificationInformation
  2712. SystemHypervisorProcessorCountInformation
  2713. SystemDeviceDataInformation
  2714. SystemDeviceDataEnumerationInformation
  2715. SystemMemoryTopologyInformation
  2716. SystemMemoryChannelInformation
  2717. SystemBootLogoInformation
  2718. SystemProcessorPerformanceInformationEx
  2719. systemSpare0
  2720. SystemSecureBootPolicyInformation
  2721. SystemPageFileInformationEx
  2722. SystemSecureBootInformation
  2723. SystemEntropyInterruptTimingRawInformation
  2724. SystemPortableWorkspaceEfiLauncherInformation
  2725. SystemFullProcessInformation
  2726. SystemKernelDebuggerInformationEx
  2727. SystemBootMetadataInformation
  2728. SystemSoftRebootInformation
  2729. SystemElamCertificateInformation
  2730. SystemOfflineDumpConfigInformation
  2731. SystemProcessorFeaturesInformation
  2732. SystemRegistryReconciliationInformation
  2733. SystemEdidInformation
  2734. SystemManufacturingInformation
  2735. SystemEnergyEstimationConfigInformation
  2736. SystemHypervisorDetailInformation
  2737. SystemProcessorCycleStatsInformation
  2738. SystemVmGenerationCountInformation
  2739. SystemTrustedPlatformModuleInformation
  2740. SystemKernelDebuggerFlags
  2741. SystemCodeIntegrityPolicyInformation
  2742. SystemIsolatedUserModeInformation
  2743. SystemHardwareSecurityTestInterfaceResultsInformation
  2744. SystemSingleModuleInformation
  2745. SystemAllowedCpuSetsInformation
  2746. SystemDmaProtectionInformation
  2747. SystemInterruptCpuSetsInformation
  2748. SystemSecureBootPolicyFullInformation
  2749. SystemCodeIntegrityPolicyFullInformation
  2750. SystemAffinitizedInterruptProcessorInformation
  2751. SystemRootSiloInformation
  2752. )
  2753. type RTL_PROCESS_MODULE_INFORMATION struct {
  2754. Section Handle
  2755. MappedBase uintptr
  2756. ImageBase uintptr
  2757. ImageSize uint32
  2758. Flags uint32
  2759. LoadOrderIndex uint16
  2760. InitOrderIndex uint16
  2761. LoadCount uint16
  2762. OffsetToFileName uint16
  2763. FullPathName [256]byte
  2764. }
  2765. type RTL_PROCESS_MODULES struct {
  2766. NumberOfModules uint32
  2767. Modules [1]RTL_PROCESS_MODULE_INFORMATION
  2768. }
  2769. // Constants for LocalAlloc flags.
  2770. const (
  2771. LMEM_FIXED = 0x0
  2772. LMEM_MOVEABLE = 0x2
  2773. LMEM_NOCOMPACT = 0x10
  2774. LMEM_NODISCARD = 0x20
  2775. LMEM_ZEROINIT = 0x40
  2776. LMEM_MODIFY = 0x80
  2777. LMEM_DISCARDABLE = 0xf00
  2778. LMEM_VALID_FLAGS = 0xf72
  2779. LMEM_INVALID_HANDLE = 0x8000
  2780. LHND = LMEM_MOVEABLE | LMEM_ZEROINIT
  2781. LPTR = LMEM_FIXED | LMEM_ZEROINIT
  2782. NONZEROLHND = LMEM_MOVEABLE
  2783. NONZEROLPTR = LMEM_FIXED
  2784. )
  2785. // Constants for the CreateNamedPipe-family of functions.
  2786. const (
  2787. PIPE_ACCESS_INBOUND = 0x1
  2788. PIPE_ACCESS_OUTBOUND = 0x2
  2789. PIPE_ACCESS_DUPLEX = 0x3
  2790. PIPE_CLIENT_END = 0x0
  2791. PIPE_SERVER_END = 0x1
  2792. PIPE_WAIT = 0x0
  2793. PIPE_NOWAIT = 0x1
  2794. PIPE_READMODE_BYTE = 0x0
  2795. PIPE_READMODE_MESSAGE = 0x2
  2796. PIPE_TYPE_BYTE = 0x0
  2797. PIPE_TYPE_MESSAGE = 0x4
  2798. PIPE_ACCEPT_REMOTE_CLIENTS = 0x0
  2799. PIPE_REJECT_REMOTE_CLIENTS = 0x8
  2800. PIPE_UNLIMITED_INSTANCES = 255
  2801. )
  2802. // Constants for security attributes when opening named pipes.
  2803. const (
  2804. SECURITY_ANONYMOUS = SecurityAnonymous << 16
  2805. SECURITY_IDENTIFICATION = SecurityIdentification << 16
  2806. SECURITY_IMPERSONATION = SecurityImpersonation << 16
  2807. SECURITY_DELEGATION = SecurityDelegation << 16
  2808. SECURITY_CONTEXT_TRACKING = 0x40000
  2809. SECURITY_EFFECTIVE_ONLY = 0x80000
  2810. SECURITY_SQOS_PRESENT = 0x100000
  2811. SECURITY_VALID_SQOS_FLAGS = 0x1f0000
  2812. )
  2813. // ResourceID represents a 16-bit resource identifier, traditionally created with the MAKEINTRESOURCE macro.
  2814. type ResourceID uint16
  2815. // ResourceIDOrString must be either a ResourceID, to specify a resource or resource type by ID,
  2816. // or a string, to specify a resource or resource type by name.
  2817. type ResourceIDOrString interface{}
  2818. // Predefined resource names and types.
  2819. var (
  2820. // Predefined names.
  2821. CREATEPROCESS_MANIFEST_RESOURCE_ID ResourceID = 1
  2822. ISOLATIONAWARE_MANIFEST_RESOURCE_ID ResourceID = 2
  2823. ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID ResourceID = 3
  2824. ISOLATIONPOLICY_MANIFEST_RESOURCE_ID ResourceID = 4
  2825. ISOLATIONPOLICY_BROWSER_MANIFEST_RESOURCE_ID ResourceID = 5
  2826. MINIMUM_RESERVED_MANIFEST_RESOURCE_ID ResourceID = 1 // inclusive
  2827. MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID ResourceID = 16 // inclusive
  2828. // Predefined types.
  2829. RT_CURSOR ResourceID = 1
  2830. RT_BITMAP ResourceID = 2
  2831. RT_ICON ResourceID = 3
  2832. RT_MENU ResourceID = 4
  2833. RT_DIALOG ResourceID = 5
  2834. RT_STRING ResourceID = 6
  2835. RT_FONTDIR ResourceID = 7
  2836. RT_FONT ResourceID = 8
  2837. RT_ACCELERATOR ResourceID = 9
  2838. RT_RCDATA ResourceID = 10
  2839. RT_MESSAGETABLE ResourceID = 11
  2840. RT_GROUP_CURSOR ResourceID = 12
  2841. RT_GROUP_ICON ResourceID = 14
  2842. RT_VERSION ResourceID = 16
  2843. RT_DLGINCLUDE ResourceID = 17
  2844. RT_PLUGPLAY ResourceID = 19
  2845. RT_VXD ResourceID = 20
  2846. RT_ANICURSOR ResourceID = 21
  2847. RT_ANIICON ResourceID = 22
  2848. RT_HTML ResourceID = 23
  2849. RT_MANIFEST ResourceID = 24
  2850. )
  2851. type VS_FIXEDFILEINFO struct {
  2852. Signature uint32
  2853. StrucVersion uint32
  2854. FileVersionMS uint32
  2855. FileVersionLS uint32
  2856. ProductVersionMS uint32
  2857. ProductVersionLS uint32
  2858. FileFlagsMask uint32
  2859. FileFlags uint32
  2860. FileOS uint32
  2861. FileType uint32
  2862. FileSubtype uint32
  2863. FileDateMS uint32
  2864. FileDateLS uint32
  2865. }
  2866. type COAUTHIDENTITY struct {
  2867. User *uint16
  2868. UserLength uint32
  2869. Domain *uint16
  2870. DomainLength uint32
  2871. Password *uint16
  2872. PasswordLength uint32
  2873. Flags uint32
  2874. }
  2875. type COAUTHINFO struct {
  2876. AuthnSvc uint32
  2877. AuthzSvc uint32
  2878. ServerPrincName *uint16
  2879. AuthnLevel uint32
  2880. ImpersonationLevel uint32
  2881. AuthIdentityData *COAUTHIDENTITY
  2882. Capabilities uint32
  2883. }
  2884. type COSERVERINFO struct {
  2885. Reserved1 uint32
  2886. Aame *uint16
  2887. AuthInfo *COAUTHINFO
  2888. Reserved2 uint32
  2889. }
  2890. type BIND_OPTS3 struct {
  2891. CbStruct uint32
  2892. Flags uint32
  2893. Mode uint32
  2894. TickCountDeadline uint32
  2895. TrackFlags uint32
  2896. ClassContext uint32
  2897. Locale uint32
  2898. ServerInfo *COSERVERINFO
  2899. Hwnd HWND
  2900. }
  2901. const (
  2902. CLSCTX_INPROC_SERVER = 0x1
  2903. CLSCTX_INPROC_HANDLER = 0x2
  2904. CLSCTX_LOCAL_SERVER = 0x4
  2905. CLSCTX_INPROC_SERVER16 = 0x8
  2906. CLSCTX_REMOTE_SERVER = 0x10
  2907. CLSCTX_INPROC_HANDLER16 = 0x20
  2908. CLSCTX_RESERVED1 = 0x40
  2909. CLSCTX_RESERVED2 = 0x80
  2910. CLSCTX_RESERVED3 = 0x100
  2911. CLSCTX_RESERVED4 = 0x200
  2912. CLSCTX_NO_CODE_DOWNLOAD = 0x400
  2913. CLSCTX_RESERVED5 = 0x800
  2914. CLSCTX_NO_CUSTOM_MARSHAL = 0x1000
  2915. CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000
  2916. CLSCTX_NO_FAILURE_LOG = 0x4000
  2917. CLSCTX_DISABLE_AAA = 0x8000
  2918. CLSCTX_ENABLE_AAA = 0x10000
  2919. CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000
  2920. CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000
  2921. CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
  2922. CLSCTX_ENABLE_CLOAKING = 0x100000
  2923. CLSCTX_APPCONTAINER = 0x400000
  2924. CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000
  2925. CLSCTX_PS_DLL = 0x80000000
  2926. COINIT_MULTITHREADED = 0x0
  2927. COINIT_APARTMENTTHREADED = 0x2
  2928. COINIT_DISABLE_OLE1DDE = 0x4
  2929. COINIT_SPEED_OVER_MEMORY = 0x8
  2930. )
  2931. // Flag for QueryFullProcessImageName.
  2932. const PROCESS_NAME_NATIVE = 1
  2933. type ModuleInfo struct {
  2934. BaseOfDll uintptr
  2935. SizeOfImage uint32
  2936. EntryPoint uintptr
  2937. }
  2938. const ALL_PROCESSOR_GROUPS = 0xFFFF
  2939. type Rect struct {
  2940. Left int32
  2941. Top int32
  2942. Right int32
  2943. Bottom int32
  2944. }
  2945. type GUIThreadInfo struct {
  2946. Size uint32
  2947. Flags uint32
  2948. Active HWND
  2949. Focus HWND
  2950. Capture HWND
  2951. MenuOwner HWND
  2952. MoveSize HWND
  2953. CaretHandle HWND
  2954. CaretRect Rect
  2955. }
  2956. const (
  2957. DWMWA_NCRENDERING_ENABLED = 1
  2958. DWMWA_NCRENDERING_POLICY = 2
  2959. DWMWA_TRANSITIONS_FORCEDISABLED = 3
  2960. DWMWA_ALLOW_NCPAINT = 4
  2961. DWMWA_CAPTION_BUTTON_BOUNDS = 5
  2962. DWMWA_NONCLIENT_RTL_LAYOUT = 6
  2963. DWMWA_FORCE_ICONIC_REPRESENTATION = 7
  2964. DWMWA_FLIP3D_POLICY = 8
  2965. DWMWA_EXTENDED_FRAME_BOUNDS = 9
  2966. DWMWA_HAS_ICONIC_BITMAP = 10
  2967. DWMWA_DISALLOW_PEEK = 11
  2968. DWMWA_EXCLUDED_FROM_PEEK = 12
  2969. DWMWA_CLOAK = 13
  2970. DWMWA_CLOAKED = 14
  2971. DWMWA_FREEZE_REPRESENTATION = 15
  2972. DWMWA_PASSIVE_UPDATE_MODE = 16
  2973. DWMWA_USE_HOSTBACKDROPBRUSH = 17
  2974. DWMWA_USE_IMMERSIVE_DARK_MODE = 20
  2975. DWMWA_WINDOW_CORNER_PREFERENCE = 33
  2976. DWMWA_BORDER_COLOR = 34
  2977. DWMWA_CAPTION_COLOR = 35
  2978. DWMWA_TEXT_COLOR = 36
  2979. DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37
  2980. )
  2981. type WSAQUERYSET struct {
  2982. Size uint32
  2983. ServiceInstanceName *uint16
  2984. ServiceClassId *GUID
  2985. Version *WSAVersion
  2986. Comment *uint16
  2987. NameSpace uint32
  2988. NSProviderId *GUID
  2989. Context *uint16
  2990. NumberOfProtocols uint32
  2991. AfpProtocols *AFProtocols
  2992. QueryString *uint16
  2993. NumberOfCsAddrs uint32
  2994. SaBuffer *CSAddrInfo
  2995. OutputFlags uint32
  2996. Blob *BLOB
  2997. }
  2998. type WSAVersion struct {
  2999. Version uint32
  3000. EnumerationOfComparison int32
  3001. }
  3002. type AFProtocols struct {
  3003. AddressFamily int32
  3004. Protocol int32
  3005. }
  3006. type CSAddrInfo struct {
  3007. LocalAddr SocketAddress
  3008. RemoteAddr SocketAddress
  3009. SocketType int32
  3010. Protocol int32
  3011. }
  3012. type BLOB struct {
  3013. Size uint32
  3014. BlobData *byte
  3015. }