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.
 
 

3216 lines
99 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. type DNSSRVData struct {
  1116. Target *uint16
  1117. Priority uint16
  1118. Weight uint16
  1119. Port uint16
  1120. Pad uint16
  1121. }
  1122. type DNSPTRData struct {
  1123. Host *uint16
  1124. }
  1125. type DNSMXData struct {
  1126. NameExchange *uint16
  1127. Preference uint16
  1128. Pad uint16
  1129. }
  1130. type DNSTXTData struct {
  1131. StringCount uint16
  1132. StringArray [1]*uint16
  1133. }
  1134. type DNSRecord struct {
  1135. Next *DNSRecord
  1136. Name *uint16
  1137. Type uint16
  1138. Length uint16
  1139. Dw uint32
  1140. Ttl uint32
  1141. Reserved uint32
  1142. Data [40]byte
  1143. }
  1144. const (
  1145. TF_DISCONNECT = 1
  1146. TF_REUSE_SOCKET = 2
  1147. TF_WRITE_BEHIND = 4
  1148. TF_USE_DEFAULT_WORKER = 0
  1149. TF_USE_SYSTEM_THREAD = 16
  1150. TF_USE_KERNEL_APC = 32
  1151. )
  1152. type TransmitFileBuffers struct {
  1153. Head uintptr
  1154. HeadLength uint32
  1155. Tail uintptr
  1156. TailLength uint32
  1157. }
  1158. const (
  1159. IFF_UP = 1
  1160. IFF_BROADCAST = 2
  1161. IFF_LOOPBACK = 4
  1162. IFF_POINTTOPOINT = 8
  1163. IFF_MULTICAST = 16
  1164. )
  1165. const SIO_GET_INTERFACE_LIST = 0x4004747F
  1166. // TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old.
  1167. // will be fixed to change variable type as suitable.
  1168. type SockaddrGen [24]byte
  1169. type InterfaceInfo struct {
  1170. Flags uint32
  1171. Address SockaddrGen
  1172. BroadcastAddress SockaddrGen
  1173. Netmask SockaddrGen
  1174. }
  1175. type IpAddressString struct {
  1176. String [16]byte
  1177. }
  1178. type IpMaskString IpAddressString
  1179. type IpAddrString struct {
  1180. Next *IpAddrString
  1181. IpAddress IpAddressString
  1182. IpMask IpMaskString
  1183. Context uint32
  1184. }
  1185. const MAX_ADAPTER_NAME_LENGTH = 256
  1186. const MAX_ADAPTER_DESCRIPTION_LENGTH = 128
  1187. const MAX_ADAPTER_ADDRESS_LENGTH = 8
  1188. type IpAdapterInfo struct {
  1189. Next *IpAdapterInfo
  1190. ComboIndex uint32
  1191. AdapterName [MAX_ADAPTER_NAME_LENGTH + 4]byte
  1192. Description [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte
  1193. AddressLength uint32
  1194. Address [MAX_ADAPTER_ADDRESS_LENGTH]byte
  1195. Index uint32
  1196. Type uint32
  1197. DhcpEnabled uint32
  1198. CurrentIpAddress *IpAddrString
  1199. IpAddressList IpAddrString
  1200. GatewayList IpAddrString
  1201. DhcpServer IpAddrString
  1202. HaveWins bool
  1203. PrimaryWinsServer IpAddrString
  1204. SecondaryWinsServer IpAddrString
  1205. LeaseObtained int64
  1206. LeaseExpires int64
  1207. }
  1208. const MAXLEN_PHYSADDR = 8
  1209. const MAX_INTERFACE_NAME_LEN = 256
  1210. const MAXLEN_IFDESCR = 256
  1211. type MibIfRow struct {
  1212. Name [MAX_INTERFACE_NAME_LEN]uint16
  1213. Index uint32
  1214. Type uint32
  1215. Mtu uint32
  1216. Speed uint32
  1217. PhysAddrLen uint32
  1218. PhysAddr [MAXLEN_PHYSADDR]byte
  1219. AdminStatus uint32
  1220. OperStatus uint32
  1221. LastChange uint32
  1222. InOctets uint32
  1223. InUcastPkts uint32
  1224. InNUcastPkts uint32
  1225. InDiscards uint32
  1226. InErrors uint32
  1227. InUnknownProtos uint32
  1228. OutOctets uint32
  1229. OutUcastPkts uint32
  1230. OutNUcastPkts uint32
  1231. OutDiscards uint32
  1232. OutErrors uint32
  1233. OutQLen uint32
  1234. DescrLen uint32
  1235. Descr [MAXLEN_IFDESCR]byte
  1236. }
  1237. type CertInfo struct {
  1238. Version uint32
  1239. SerialNumber CryptIntegerBlob
  1240. SignatureAlgorithm CryptAlgorithmIdentifier
  1241. Issuer CertNameBlob
  1242. NotBefore Filetime
  1243. NotAfter Filetime
  1244. Subject CertNameBlob
  1245. SubjectPublicKeyInfo CertPublicKeyInfo
  1246. IssuerUniqueId CryptBitBlob
  1247. SubjectUniqueId CryptBitBlob
  1248. CountExtensions uint32
  1249. Extensions *CertExtension
  1250. }
  1251. type CertExtension struct {
  1252. ObjId *byte
  1253. Critical int32
  1254. Value CryptObjidBlob
  1255. }
  1256. type CryptAlgorithmIdentifier struct {
  1257. ObjId *byte
  1258. Parameters CryptObjidBlob
  1259. }
  1260. type CertPublicKeyInfo struct {
  1261. Algorithm CryptAlgorithmIdentifier
  1262. PublicKey CryptBitBlob
  1263. }
  1264. type DataBlob struct {
  1265. Size uint32
  1266. Data *byte
  1267. }
  1268. type CryptIntegerBlob DataBlob
  1269. type CryptUintBlob DataBlob
  1270. type CryptObjidBlob DataBlob
  1271. type CertNameBlob DataBlob
  1272. type CertRdnValueBlob DataBlob
  1273. type CertBlob DataBlob
  1274. type CrlBlob DataBlob
  1275. type CryptDataBlob DataBlob
  1276. type CryptHashBlob DataBlob
  1277. type CryptDigestBlob DataBlob
  1278. type CryptDerBlob DataBlob
  1279. type CryptAttrBlob DataBlob
  1280. type CryptBitBlob struct {
  1281. Size uint32
  1282. Data *byte
  1283. UnusedBits uint32
  1284. }
  1285. type CertContext struct {
  1286. EncodingType uint32
  1287. EncodedCert *byte
  1288. Length uint32
  1289. CertInfo *CertInfo
  1290. Store Handle
  1291. }
  1292. type CertChainContext struct {
  1293. Size uint32
  1294. TrustStatus CertTrustStatus
  1295. ChainCount uint32
  1296. Chains **CertSimpleChain
  1297. LowerQualityChainCount uint32
  1298. LowerQualityChains **CertChainContext
  1299. HasRevocationFreshnessTime uint32
  1300. RevocationFreshnessTime uint32
  1301. }
  1302. type CertTrustListInfo struct {
  1303. // Not implemented
  1304. }
  1305. type CertSimpleChain struct {
  1306. Size uint32
  1307. TrustStatus CertTrustStatus
  1308. NumElements uint32
  1309. Elements **CertChainElement
  1310. TrustListInfo *CertTrustListInfo
  1311. HasRevocationFreshnessTime uint32
  1312. RevocationFreshnessTime uint32
  1313. }
  1314. type CertChainElement struct {
  1315. Size uint32
  1316. CertContext *CertContext
  1317. TrustStatus CertTrustStatus
  1318. RevocationInfo *CertRevocationInfo
  1319. IssuanceUsage *CertEnhKeyUsage
  1320. ApplicationUsage *CertEnhKeyUsage
  1321. ExtendedErrorInfo *uint16
  1322. }
  1323. type CertRevocationCrlInfo struct {
  1324. // Not implemented
  1325. }
  1326. type CertRevocationInfo struct {
  1327. Size uint32
  1328. RevocationResult uint32
  1329. RevocationOid *byte
  1330. OidSpecificInfo Pointer
  1331. HasFreshnessTime uint32
  1332. FreshnessTime uint32
  1333. CrlInfo *CertRevocationCrlInfo
  1334. }
  1335. type CertTrustStatus struct {
  1336. ErrorStatus uint32
  1337. InfoStatus uint32
  1338. }
  1339. type CertUsageMatch struct {
  1340. Type uint32
  1341. Usage CertEnhKeyUsage
  1342. }
  1343. type CertEnhKeyUsage struct {
  1344. Length uint32
  1345. UsageIdentifiers **byte
  1346. }
  1347. type CertChainPara struct {
  1348. Size uint32
  1349. RequestedUsage CertUsageMatch
  1350. RequstedIssuancePolicy CertUsageMatch
  1351. URLRetrievalTimeout uint32
  1352. CheckRevocationFreshnessTime uint32
  1353. RevocationFreshnessTime uint32
  1354. CacheResync *Filetime
  1355. }
  1356. type CertChainPolicyPara struct {
  1357. Size uint32
  1358. Flags uint32
  1359. ExtraPolicyPara Pointer
  1360. }
  1361. type SSLExtraCertChainPolicyPara struct {
  1362. Size uint32
  1363. AuthType uint32
  1364. Checks uint32
  1365. ServerName *uint16
  1366. }
  1367. type CertChainPolicyStatus struct {
  1368. Size uint32
  1369. Error uint32
  1370. ChainIndex uint32
  1371. ElementIndex uint32
  1372. ExtraPolicyStatus Pointer
  1373. }
  1374. type CertPolicyInfo struct {
  1375. Identifier *byte
  1376. CountQualifiers uint32
  1377. Qualifiers *CertPolicyQualifierInfo
  1378. }
  1379. type CertPoliciesInfo struct {
  1380. Count uint32
  1381. PolicyInfos *CertPolicyInfo
  1382. }
  1383. type CertPolicyQualifierInfo struct {
  1384. // Not implemented
  1385. }
  1386. type CertStrongSignPara struct {
  1387. Size uint32
  1388. InfoChoice uint32
  1389. InfoOrSerializedInfoOrOID unsafe.Pointer
  1390. }
  1391. type CryptProtectPromptStruct struct {
  1392. Size uint32
  1393. PromptFlags uint32
  1394. App HWND
  1395. Prompt *uint16
  1396. }
  1397. type CertChainFindByIssuerPara struct {
  1398. Size uint32
  1399. UsageIdentifier *byte
  1400. KeySpec uint32
  1401. AcquirePrivateKeyFlags uint32
  1402. IssuerCount uint32
  1403. Issuer Pointer
  1404. FindCallback Pointer
  1405. FindArg Pointer
  1406. IssuerChainIndex *uint32
  1407. IssuerElementIndex *uint32
  1408. }
  1409. type WinTrustData struct {
  1410. Size uint32
  1411. PolicyCallbackData uintptr
  1412. SIPClientData uintptr
  1413. UIChoice uint32
  1414. RevocationChecks uint32
  1415. UnionChoice uint32
  1416. FileOrCatalogOrBlobOrSgnrOrCert unsafe.Pointer
  1417. StateAction uint32
  1418. StateData Handle
  1419. URLReference *uint16
  1420. ProvFlags uint32
  1421. UIContext uint32
  1422. SignatureSettings *WinTrustSignatureSettings
  1423. }
  1424. type WinTrustFileInfo struct {
  1425. Size uint32
  1426. FilePath *uint16
  1427. File Handle
  1428. KnownSubject *GUID
  1429. }
  1430. type WinTrustSignatureSettings struct {
  1431. Size uint32
  1432. Index uint32
  1433. Flags uint32
  1434. SecondarySigs uint32
  1435. VerifiedSigIndex uint32
  1436. CryptoPolicy *CertStrongSignPara
  1437. }
  1438. const (
  1439. // do not reorder
  1440. HKEY_CLASSES_ROOT = 0x80000000 + iota
  1441. HKEY_CURRENT_USER
  1442. HKEY_LOCAL_MACHINE
  1443. HKEY_USERS
  1444. HKEY_PERFORMANCE_DATA
  1445. HKEY_CURRENT_CONFIG
  1446. HKEY_DYN_DATA
  1447. KEY_QUERY_VALUE = 1
  1448. KEY_SET_VALUE = 2
  1449. KEY_CREATE_SUB_KEY = 4
  1450. KEY_ENUMERATE_SUB_KEYS = 8
  1451. KEY_NOTIFY = 16
  1452. KEY_CREATE_LINK = 32
  1453. KEY_WRITE = 0x20006
  1454. KEY_EXECUTE = 0x20019
  1455. KEY_READ = 0x20019
  1456. KEY_WOW64_64KEY = 0x0100
  1457. KEY_WOW64_32KEY = 0x0200
  1458. KEY_ALL_ACCESS = 0xf003f
  1459. )
  1460. const (
  1461. // do not reorder
  1462. REG_NONE = iota
  1463. REG_SZ
  1464. REG_EXPAND_SZ
  1465. REG_BINARY
  1466. REG_DWORD_LITTLE_ENDIAN
  1467. REG_DWORD_BIG_ENDIAN
  1468. REG_LINK
  1469. REG_MULTI_SZ
  1470. REG_RESOURCE_LIST
  1471. REG_FULL_RESOURCE_DESCRIPTOR
  1472. REG_RESOURCE_REQUIREMENTS_LIST
  1473. REG_QWORD_LITTLE_ENDIAN
  1474. REG_DWORD = REG_DWORD_LITTLE_ENDIAN
  1475. REG_QWORD = REG_QWORD_LITTLE_ENDIAN
  1476. )
  1477. const (
  1478. EVENT_MODIFY_STATE = 0x0002
  1479. EVENT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1480. MUTANT_QUERY_STATE = 0x0001
  1481. MUTANT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE
  1482. SEMAPHORE_MODIFY_STATE = 0x0002
  1483. SEMAPHORE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
  1484. TIMER_QUERY_STATE = 0x0001
  1485. TIMER_MODIFY_STATE = 0x0002
  1486. TIMER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE | TIMER_MODIFY_STATE
  1487. MUTEX_MODIFY_STATE = MUTANT_QUERY_STATE
  1488. MUTEX_ALL_ACCESS = MUTANT_ALL_ACCESS
  1489. CREATE_EVENT_MANUAL_RESET = 0x1
  1490. CREATE_EVENT_INITIAL_SET = 0x2
  1491. CREATE_MUTEX_INITIAL_OWNER = 0x1
  1492. )
  1493. type AddrinfoW struct {
  1494. Flags int32
  1495. Family int32
  1496. Socktype int32
  1497. Protocol int32
  1498. Addrlen uintptr
  1499. Canonname *uint16
  1500. Addr uintptr
  1501. Next *AddrinfoW
  1502. }
  1503. const (
  1504. AI_PASSIVE = 1
  1505. AI_CANONNAME = 2
  1506. AI_NUMERICHOST = 4
  1507. )
  1508. type GUID struct {
  1509. Data1 uint32
  1510. Data2 uint16
  1511. Data3 uint16
  1512. Data4 [8]byte
  1513. }
  1514. var WSAID_CONNECTEX = GUID{
  1515. 0x25a207b9,
  1516. 0xddf3,
  1517. 0x4660,
  1518. [8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e},
  1519. }
  1520. var WSAID_WSASENDMSG = GUID{
  1521. 0xa441e712,
  1522. 0x754f,
  1523. 0x43ca,
  1524. [8]byte{0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d},
  1525. }
  1526. var WSAID_WSARECVMSG = GUID{
  1527. 0xf689d7c8,
  1528. 0x6f1f,
  1529. 0x436b,
  1530. [8]byte{0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22},
  1531. }
  1532. const (
  1533. FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
  1534. FILE_SKIP_SET_EVENT_ON_HANDLE = 2
  1535. )
  1536. const (
  1537. WSAPROTOCOL_LEN = 255
  1538. MAX_PROTOCOL_CHAIN = 7
  1539. BASE_PROTOCOL = 1
  1540. LAYERED_PROTOCOL = 0
  1541. XP1_CONNECTIONLESS = 0x00000001
  1542. XP1_GUARANTEED_DELIVERY = 0x00000002
  1543. XP1_GUARANTEED_ORDER = 0x00000004
  1544. XP1_MESSAGE_ORIENTED = 0x00000008
  1545. XP1_PSEUDO_STREAM = 0x00000010
  1546. XP1_GRACEFUL_CLOSE = 0x00000020
  1547. XP1_EXPEDITED_DATA = 0x00000040
  1548. XP1_CONNECT_DATA = 0x00000080
  1549. XP1_DISCONNECT_DATA = 0x00000100
  1550. XP1_SUPPORT_BROADCAST = 0x00000200
  1551. XP1_SUPPORT_MULTIPOINT = 0x00000400
  1552. XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800
  1553. XP1_MULTIPOINT_DATA_PLANE = 0x00001000
  1554. XP1_QOS_SUPPORTED = 0x00002000
  1555. XP1_UNI_SEND = 0x00008000
  1556. XP1_UNI_RECV = 0x00010000
  1557. XP1_IFS_HANDLES = 0x00020000
  1558. XP1_PARTIAL_MESSAGE = 0x00040000
  1559. XP1_SAN_SUPPORT_SDP = 0x00080000
  1560. PFL_MULTIPLE_PROTO_ENTRIES = 0x00000001
  1561. PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002
  1562. PFL_HIDDEN = 0x00000004
  1563. PFL_MATCHES_PROTOCOL_ZERO = 0x00000008
  1564. PFL_NETWORKDIRECT_PROVIDER = 0x00000010
  1565. )
  1566. type WSAProtocolInfo struct {
  1567. ServiceFlags1 uint32
  1568. ServiceFlags2 uint32
  1569. ServiceFlags3 uint32
  1570. ServiceFlags4 uint32
  1571. ProviderFlags uint32
  1572. ProviderId GUID
  1573. CatalogEntryId uint32
  1574. ProtocolChain WSAProtocolChain
  1575. Version int32
  1576. AddressFamily int32
  1577. MaxSockAddr int32
  1578. MinSockAddr int32
  1579. SocketType int32
  1580. Protocol int32
  1581. ProtocolMaxOffset int32
  1582. NetworkByteOrder int32
  1583. SecurityScheme int32
  1584. MessageSize uint32
  1585. ProviderReserved uint32
  1586. ProtocolName [WSAPROTOCOL_LEN + 1]uint16
  1587. }
  1588. type WSAProtocolChain struct {
  1589. ChainLen int32
  1590. ChainEntries [MAX_PROTOCOL_CHAIN]uint32
  1591. }
  1592. type TCPKeepalive struct {
  1593. OnOff uint32
  1594. Time uint32
  1595. Interval uint32
  1596. }
  1597. type symbolicLinkReparseBuffer struct {
  1598. SubstituteNameOffset uint16
  1599. SubstituteNameLength uint16
  1600. PrintNameOffset uint16
  1601. PrintNameLength uint16
  1602. Flags uint32
  1603. PathBuffer [1]uint16
  1604. }
  1605. type mountPointReparseBuffer struct {
  1606. SubstituteNameOffset uint16
  1607. SubstituteNameLength uint16
  1608. PrintNameOffset uint16
  1609. PrintNameLength uint16
  1610. PathBuffer [1]uint16
  1611. }
  1612. type reparseDataBuffer struct {
  1613. ReparseTag uint32
  1614. ReparseDataLength uint16
  1615. Reserved uint16
  1616. // GenericReparseBuffer
  1617. reparseBuffer byte
  1618. }
  1619. const (
  1620. FSCTL_CREATE_OR_GET_OBJECT_ID = 0x0900C0
  1621. FSCTL_DELETE_OBJECT_ID = 0x0900A0
  1622. FSCTL_DELETE_REPARSE_POINT = 0x0900AC
  1623. FSCTL_DUPLICATE_EXTENTS_TO_FILE = 0x098344
  1624. FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX = 0x0983E8
  1625. FSCTL_FILESYSTEM_GET_STATISTICS = 0x090060
  1626. FSCTL_FILE_LEVEL_TRIM = 0x098208
  1627. FSCTL_FIND_FILES_BY_SID = 0x09008F
  1628. FSCTL_GET_COMPRESSION = 0x09003C
  1629. FSCTL_GET_INTEGRITY_INFORMATION = 0x09027C
  1630. FSCTL_GET_NTFS_VOLUME_DATA = 0x090064
  1631. FSCTL_GET_REFS_VOLUME_DATA = 0x0902D8
  1632. FSCTL_GET_OBJECT_ID = 0x09009C
  1633. FSCTL_GET_REPARSE_POINT = 0x0900A8
  1634. FSCTL_GET_RETRIEVAL_POINTER_COUNT = 0x09042B
  1635. FSCTL_GET_RETRIEVAL_POINTERS = 0x090073
  1636. FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT = 0x0903D3
  1637. FSCTL_IS_PATHNAME_VALID = 0x09002C
  1638. FSCTL_LMR_SET_LINK_TRACKING_INFORMATION = 0x1400EC
  1639. FSCTL_MARK_HANDLE = 0x0900FC
  1640. FSCTL_OFFLOAD_READ = 0x094264
  1641. FSCTL_OFFLOAD_WRITE = 0x098268
  1642. FSCTL_PIPE_PEEK = 0x11400C
  1643. FSCTL_PIPE_TRANSCEIVE = 0x11C017
  1644. FSCTL_PIPE_WAIT = 0x110018
  1645. FSCTL_QUERY_ALLOCATED_RANGES = 0x0940CF
  1646. FSCTL_QUERY_FAT_BPB = 0x090058
  1647. FSCTL_QUERY_FILE_REGIONS = 0x090284
  1648. FSCTL_QUERY_ON_DISK_VOLUME_INFO = 0x09013C
  1649. FSCTL_QUERY_SPARING_INFO = 0x090138
  1650. FSCTL_READ_FILE_USN_DATA = 0x0900EB
  1651. FSCTL_RECALL_FILE = 0x090117
  1652. FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT = 0x090440
  1653. FSCTL_SET_COMPRESSION = 0x09C040
  1654. FSCTL_SET_DEFECT_MANAGEMENT = 0x098134
  1655. FSCTL_SET_ENCRYPTION = 0x0900D7
  1656. FSCTL_SET_INTEGRITY_INFORMATION = 0x09C280
  1657. FSCTL_SET_INTEGRITY_INFORMATION_EX = 0x090380
  1658. FSCTL_SET_OBJECT_ID = 0x090098
  1659. FSCTL_SET_OBJECT_ID_EXTENDED = 0x0900BC
  1660. FSCTL_SET_REPARSE_POINT = 0x0900A4
  1661. FSCTL_SET_SPARSE = 0x0900C4
  1662. FSCTL_SET_ZERO_DATA = 0x0980C8
  1663. FSCTL_SET_ZERO_ON_DEALLOCATION = 0x090194
  1664. FSCTL_SIS_COPYFILE = 0x090100
  1665. FSCTL_WRITE_USN_CLOSE_RECORD = 0x0900EF
  1666. MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
  1667. IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
  1668. IO_REPARSE_TAG_SYMLINK = 0xA000000C
  1669. SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
  1670. )
  1671. const (
  1672. ComputerNameNetBIOS = 0
  1673. ComputerNameDnsHostname = 1
  1674. ComputerNameDnsDomain = 2
  1675. ComputerNameDnsFullyQualified = 3
  1676. ComputerNamePhysicalNetBIOS = 4
  1677. ComputerNamePhysicalDnsHostname = 5
  1678. ComputerNamePhysicalDnsDomain = 6
  1679. ComputerNamePhysicalDnsFullyQualified = 7
  1680. ComputerNameMax = 8
  1681. )
  1682. // For MessageBox()
  1683. const (
  1684. MB_OK = 0x00000000
  1685. MB_OKCANCEL = 0x00000001
  1686. MB_ABORTRETRYIGNORE = 0x00000002
  1687. MB_YESNOCANCEL = 0x00000003
  1688. MB_YESNO = 0x00000004
  1689. MB_RETRYCANCEL = 0x00000005
  1690. MB_CANCELTRYCONTINUE = 0x00000006
  1691. MB_ICONHAND = 0x00000010
  1692. MB_ICONQUESTION = 0x00000020
  1693. MB_ICONEXCLAMATION = 0x00000030
  1694. MB_ICONASTERISK = 0x00000040
  1695. MB_USERICON = 0x00000080
  1696. MB_ICONWARNING = MB_ICONEXCLAMATION
  1697. MB_ICONERROR = MB_ICONHAND
  1698. MB_ICONINFORMATION = MB_ICONASTERISK
  1699. MB_ICONSTOP = MB_ICONHAND
  1700. MB_DEFBUTTON1 = 0x00000000
  1701. MB_DEFBUTTON2 = 0x00000100
  1702. MB_DEFBUTTON3 = 0x00000200
  1703. MB_DEFBUTTON4 = 0x00000300
  1704. MB_APPLMODAL = 0x00000000
  1705. MB_SYSTEMMODAL = 0x00001000
  1706. MB_TASKMODAL = 0x00002000
  1707. MB_HELP = 0x00004000
  1708. MB_NOFOCUS = 0x00008000
  1709. MB_SETFOREGROUND = 0x00010000
  1710. MB_DEFAULT_DESKTOP_ONLY = 0x00020000
  1711. MB_TOPMOST = 0x00040000
  1712. MB_RIGHT = 0x00080000
  1713. MB_RTLREADING = 0x00100000
  1714. MB_SERVICE_NOTIFICATION = 0x00200000
  1715. )
  1716. const (
  1717. MOVEFILE_REPLACE_EXISTING = 0x1
  1718. MOVEFILE_COPY_ALLOWED = 0x2
  1719. MOVEFILE_DELAY_UNTIL_REBOOT = 0x4
  1720. MOVEFILE_WRITE_THROUGH = 0x8
  1721. MOVEFILE_CREATE_HARDLINK = 0x10
  1722. MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20
  1723. )
  1724. const GAA_FLAG_INCLUDE_PREFIX = 0x00000010
  1725. const (
  1726. IF_TYPE_OTHER = 1
  1727. IF_TYPE_ETHERNET_CSMACD = 6
  1728. IF_TYPE_ISO88025_TOKENRING = 9
  1729. IF_TYPE_PPP = 23
  1730. IF_TYPE_SOFTWARE_LOOPBACK = 24
  1731. IF_TYPE_ATM = 37
  1732. IF_TYPE_IEEE80211 = 71
  1733. IF_TYPE_TUNNEL = 131
  1734. IF_TYPE_IEEE1394 = 144
  1735. )
  1736. type SocketAddress struct {
  1737. Sockaddr *syscall.RawSockaddrAny
  1738. SockaddrLength int32
  1739. }
  1740. // IP returns an IPv4 or IPv6 address, or nil if the underlying SocketAddress is neither.
  1741. func (addr *SocketAddress) IP() net.IP {
  1742. if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet4{}) && addr.Sockaddr.Addr.Family == AF_INET {
  1743. return (*RawSockaddrInet4)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  1744. } else if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet6{}) && addr.Sockaddr.Addr.Family == AF_INET6 {
  1745. return (*RawSockaddrInet6)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
  1746. }
  1747. return nil
  1748. }
  1749. type IpAdapterUnicastAddress struct {
  1750. Length uint32
  1751. Flags uint32
  1752. Next *IpAdapterUnicastAddress
  1753. Address SocketAddress
  1754. PrefixOrigin int32
  1755. SuffixOrigin int32
  1756. DadState int32
  1757. ValidLifetime uint32
  1758. PreferredLifetime uint32
  1759. LeaseLifetime uint32
  1760. OnLinkPrefixLength uint8
  1761. }
  1762. type IpAdapterAnycastAddress struct {
  1763. Length uint32
  1764. Flags uint32
  1765. Next *IpAdapterAnycastAddress
  1766. Address SocketAddress
  1767. }
  1768. type IpAdapterMulticastAddress struct {
  1769. Length uint32
  1770. Flags uint32
  1771. Next *IpAdapterMulticastAddress
  1772. Address SocketAddress
  1773. }
  1774. type IpAdapterDnsServerAdapter struct {
  1775. Length uint32
  1776. Reserved uint32
  1777. Next *IpAdapterDnsServerAdapter
  1778. Address SocketAddress
  1779. }
  1780. type IpAdapterPrefix struct {
  1781. Length uint32
  1782. Flags uint32
  1783. Next *IpAdapterPrefix
  1784. Address SocketAddress
  1785. PrefixLength uint32
  1786. }
  1787. type IpAdapterAddresses struct {
  1788. Length uint32
  1789. IfIndex uint32
  1790. Next *IpAdapterAddresses
  1791. AdapterName *byte
  1792. FirstUnicastAddress *IpAdapterUnicastAddress
  1793. FirstAnycastAddress *IpAdapterAnycastAddress
  1794. FirstMulticastAddress *IpAdapterMulticastAddress
  1795. FirstDnsServerAddress *IpAdapterDnsServerAdapter
  1796. DnsSuffix *uint16
  1797. Description *uint16
  1798. FriendlyName *uint16
  1799. PhysicalAddress [syscall.MAX_ADAPTER_ADDRESS_LENGTH]byte
  1800. PhysicalAddressLength uint32
  1801. Flags uint32
  1802. Mtu uint32
  1803. IfType uint32
  1804. OperStatus uint32
  1805. Ipv6IfIndex uint32
  1806. ZoneIndices [16]uint32
  1807. FirstPrefix *IpAdapterPrefix
  1808. TransmitLinkSpeed uint64
  1809. ReceiveLinkSpeed uint64
  1810. FirstWinsServerAddress *IpAdapterWinsServerAddress
  1811. FirstGatewayAddress *IpAdapterGatewayAddress
  1812. Ipv4Metric uint32
  1813. Ipv6Metric uint32
  1814. Luid uint64
  1815. Dhcpv4Server SocketAddress
  1816. CompartmentId uint32
  1817. NetworkGuid GUID
  1818. ConnectionType uint32
  1819. TunnelType uint32
  1820. Dhcpv6Server SocketAddress
  1821. Dhcpv6ClientDuid [MAX_DHCPV6_DUID_LENGTH]byte
  1822. Dhcpv6ClientDuidLength uint32
  1823. Dhcpv6Iaid uint32
  1824. FirstDnsSuffix *IpAdapterDNSSuffix
  1825. }
  1826. type IpAdapterWinsServerAddress struct {
  1827. Length uint32
  1828. Reserved uint32
  1829. Next *IpAdapterWinsServerAddress
  1830. Address SocketAddress
  1831. }
  1832. type IpAdapterGatewayAddress struct {
  1833. Length uint32
  1834. Reserved uint32
  1835. Next *IpAdapterGatewayAddress
  1836. Address SocketAddress
  1837. }
  1838. type IpAdapterDNSSuffix struct {
  1839. Next *IpAdapterDNSSuffix
  1840. String [MAX_DNS_SUFFIX_STRING_LENGTH]uint16
  1841. }
  1842. const (
  1843. IfOperStatusUp = 1
  1844. IfOperStatusDown = 2
  1845. IfOperStatusTesting = 3
  1846. IfOperStatusUnknown = 4
  1847. IfOperStatusDormant = 5
  1848. IfOperStatusNotPresent = 6
  1849. IfOperStatusLowerLayerDown = 7
  1850. )
  1851. // Console related constants used for the mode parameter to SetConsoleMode. See
  1852. // https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
  1853. const (
  1854. ENABLE_PROCESSED_INPUT = 0x1
  1855. ENABLE_LINE_INPUT = 0x2
  1856. ENABLE_ECHO_INPUT = 0x4
  1857. ENABLE_WINDOW_INPUT = 0x8
  1858. ENABLE_MOUSE_INPUT = 0x10
  1859. ENABLE_INSERT_MODE = 0x20
  1860. ENABLE_QUICK_EDIT_MODE = 0x40
  1861. ENABLE_EXTENDED_FLAGS = 0x80
  1862. ENABLE_AUTO_POSITION = 0x100
  1863. ENABLE_VIRTUAL_TERMINAL_INPUT = 0x200
  1864. ENABLE_PROCESSED_OUTPUT = 0x1
  1865. ENABLE_WRAP_AT_EOL_OUTPUT = 0x2
  1866. ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
  1867. DISABLE_NEWLINE_AUTO_RETURN = 0x8
  1868. ENABLE_LVB_GRID_WORLDWIDE = 0x10
  1869. )
  1870. type Coord struct {
  1871. X int16
  1872. Y int16
  1873. }
  1874. type SmallRect struct {
  1875. Left int16
  1876. Top int16
  1877. Right int16
  1878. Bottom int16
  1879. }
  1880. // Used with GetConsoleScreenBuffer to retrieve information about a console
  1881. // screen buffer. See
  1882. // https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str
  1883. // for details.
  1884. type ConsoleScreenBufferInfo struct {
  1885. Size Coord
  1886. CursorPosition Coord
  1887. Attributes uint16
  1888. Window SmallRect
  1889. MaximumWindowSize Coord
  1890. }
  1891. const UNIX_PATH_MAX = 108 // defined in afunix.h
  1892. const (
  1893. // flags for JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags
  1894. JOB_OBJECT_LIMIT_ACTIVE_PROCESS = 0x00000008
  1895. JOB_OBJECT_LIMIT_AFFINITY = 0x00000010
  1896. JOB_OBJECT_LIMIT_BREAKAWAY_OK = 0x00000800
  1897. JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x00000400
  1898. JOB_OBJECT_LIMIT_JOB_MEMORY = 0x00000200
  1899. JOB_OBJECT_LIMIT_JOB_TIME = 0x00000004
  1900. JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x00002000
  1901. JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME = 0x00000040
  1902. JOB_OBJECT_LIMIT_PRIORITY_CLASS = 0x00000020
  1903. JOB_OBJECT_LIMIT_PROCESS_MEMORY = 0x00000100
  1904. JOB_OBJECT_LIMIT_PROCESS_TIME = 0x00000002
  1905. JOB_OBJECT_LIMIT_SCHEDULING_CLASS = 0x00000080
  1906. JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK = 0x00001000
  1907. JOB_OBJECT_LIMIT_SUBSET_AFFINITY = 0x00004000
  1908. JOB_OBJECT_LIMIT_WORKINGSET = 0x00000001
  1909. )
  1910. type IO_COUNTERS struct {
  1911. ReadOperationCount uint64
  1912. WriteOperationCount uint64
  1913. OtherOperationCount uint64
  1914. ReadTransferCount uint64
  1915. WriteTransferCount uint64
  1916. OtherTransferCount uint64
  1917. }
  1918. type JOBOBJECT_EXTENDED_LIMIT_INFORMATION struct {
  1919. BasicLimitInformation JOBOBJECT_BASIC_LIMIT_INFORMATION
  1920. IoInfo IO_COUNTERS
  1921. ProcessMemoryLimit uintptr
  1922. JobMemoryLimit uintptr
  1923. PeakProcessMemoryUsed uintptr
  1924. PeakJobMemoryUsed uintptr
  1925. }
  1926. const (
  1927. // UIRestrictionsClass
  1928. JOB_OBJECT_UILIMIT_DESKTOP = 0x00000040
  1929. JOB_OBJECT_UILIMIT_DISPLAYSETTINGS = 0x00000010
  1930. JOB_OBJECT_UILIMIT_EXITWINDOWS = 0x00000080
  1931. JOB_OBJECT_UILIMIT_GLOBALATOMS = 0x00000020
  1932. JOB_OBJECT_UILIMIT_HANDLES = 0x00000001
  1933. JOB_OBJECT_UILIMIT_READCLIPBOARD = 0x00000002
  1934. JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = 0x00000008
  1935. JOB_OBJECT_UILIMIT_WRITECLIPBOARD = 0x00000004
  1936. )
  1937. type JOBOBJECT_BASIC_UI_RESTRICTIONS struct {
  1938. UIRestrictionsClass uint32
  1939. }
  1940. const (
  1941. // JobObjectInformationClass
  1942. JobObjectAssociateCompletionPortInformation = 7
  1943. JobObjectBasicLimitInformation = 2
  1944. JobObjectBasicUIRestrictions = 4
  1945. JobObjectCpuRateControlInformation = 15
  1946. JobObjectEndOfJobTimeInformation = 6
  1947. JobObjectExtendedLimitInformation = 9
  1948. JobObjectGroupInformation = 11
  1949. JobObjectGroupInformationEx = 14
  1950. JobObjectLimitViolationInformation2 = 35
  1951. JobObjectNetRateControlInformation = 32
  1952. JobObjectNotificationLimitInformation = 12
  1953. JobObjectNotificationLimitInformation2 = 34
  1954. JobObjectSecurityLimitInformation = 5
  1955. )
  1956. const (
  1957. KF_FLAG_DEFAULT = 0x00000000
  1958. KF_FLAG_FORCE_APP_DATA_REDIRECTION = 0x00080000
  1959. KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET = 0x00040000
  1960. KF_FLAG_FORCE_PACKAGE_REDIRECTION = 0x00020000
  1961. KF_FLAG_NO_PACKAGE_REDIRECTION = 0x00010000
  1962. KF_FLAG_FORCE_APPCONTAINER_REDIRECTION = 0x00020000
  1963. KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000
  1964. KF_FLAG_CREATE = 0x00008000
  1965. KF_FLAG_DONT_VERIFY = 0x00004000
  1966. KF_FLAG_DONT_UNEXPAND = 0x00002000
  1967. KF_FLAG_NO_ALIAS = 0x00001000
  1968. KF_FLAG_INIT = 0x00000800
  1969. KF_FLAG_DEFAULT_PATH = 0x00000400
  1970. KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200
  1971. KF_FLAG_SIMPLE_IDLIST = 0x00000100
  1972. KF_FLAG_ALIAS_ONLY = 0x80000000
  1973. )
  1974. type OsVersionInfoEx struct {
  1975. osVersionInfoSize uint32
  1976. MajorVersion uint32
  1977. MinorVersion uint32
  1978. BuildNumber uint32
  1979. PlatformId uint32
  1980. CsdVersion [128]uint16
  1981. ServicePackMajor uint16
  1982. ServicePackMinor uint16
  1983. SuiteMask uint16
  1984. ProductType byte
  1985. _ byte
  1986. }
  1987. const (
  1988. EWX_LOGOFF = 0x00000000
  1989. EWX_SHUTDOWN = 0x00000001
  1990. EWX_REBOOT = 0x00000002
  1991. EWX_FORCE = 0x00000004
  1992. EWX_POWEROFF = 0x00000008
  1993. EWX_FORCEIFHUNG = 0x00000010
  1994. EWX_QUICKRESOLVE = 0x00000020
  1995. EWX_RESTARTAPPS = 0x00000040
  1996. EWX_HYBRID_SHUTDOWN = 0x00400000
  1997. EWX_BOOTOPTIONS = 0x01000000
  1998. SHTDN_REASON_FLAG_COMMENT_REQUIRED = 0x01000000
  1999. SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED = 0x02000000
  2000. SHTDN_REASON_FLAG_CLEAN_UI = 0x04000000
  2001. SHTDN_REASON_FLAG_DIRTY_UI = 0x08000000
  2002. SHTDN_REASON_FLAG_USER_DEFINED = 0x40000000
  2003. SHTDN_REASON_FLAG_PLANNED = 0x80000000
  2004. SHTDN_REASON_MAJOR_OTHER = 0x00000000
  2005. SHTDN_REASON_MAJOR_NONE = 0x00000000
  2006. SHTDN_REASON_MAJOR_HARDWARE = 0x00010000
  2007. SHTDN_REASON_MAJOR_OPERATINGSYSTEM = 0x00020000
  2008. SHTDN_REASON_MAJOR_SOFTWARE = 0x00030000
  2009. SHTDN_REASON_MAJOR_APPLICATION = 0x00040000
  2010. SHTDN_REASON_MAJOR_SYSTEM = 0x00050000
  2011. SHTDN_REASON_MAJOR_POWER = 0x00060000
  2012. SHTDN_REASON_MAJOR_LEGACY_API = 0x00070000
  2013. SHTDN_REASON_MINOR_OTHER = 0x00000000
  2014. SHTDN_REASON_MINOR_NONE = 0x000000ff
  2015. SHTDN_REASON_MINOR_MAINTENANCE = 0x00000001
  2016. SHTDN_REASON_MINOR_INSTALLATION = 0x00000002
  2017. SHTDN_REASON_MINOR_UPGRADE = 0x00000003
  2018. SHTDN_REASON_MINOR_RECONFIG = 0x00000004
  2019. SHTDN_REASON_MINOR_HUNG = 0x00000005
  2020. SHTDN_REASON_MINOR_UNSTABLE = 0x00000006
  2021. SHTDN_REASON_MINOR_DISK = 0x00000007
  2022. SHTDN_REASON_MINOR_PROCESSOR = 0x00000008
  2023. SHTDN_REASON_MINOR_NETWORKCARD = 0x00000009
  2024. SHTDN_REASON_MINOR_POWER_SUPPLY = 0x0000000a
  2025. SHTDN_REASON_MINOR_CORDUNPLUGGED = 0x0000000b
  2026. SHTDN_REASON_MINOR_ENVIRONMENT = 0x0000000c
  2027. SHTDN_REASON_MINOR_HARDWARE_DRIVER = 0x0000000d
  2028. SHTDN_REASON_MINOR_OTHERDRIVER = 0x0000000e
  2029. SHTDN_REASON_MINOR_BLUESCREEN = 0x0000000F
  2030. SHTDN_REASON_MINOR_SERVICEPACK = 0x00000010
  2031. SHTDN_REASON_MINOR_HOTFIX = 0x00000011
  2032. SHTDN_REASON_MINOR_SECURITYFIX = 0x00000012
  2033. SHTDN_REASON_MINOR_SECURITY = 0x00000013
  2034. SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = 0x00000014
  2035. SHTDN_REASON_MINOR_WMI = 0x00000015
  2036. SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL = 0x00000016
  2037. SHTDN_REASON_MINOR_HOTFIX_UNINSTALL = 0x00000017
  2038. SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL = 0x00000018
  2039. SHTDN_REASON_MINOR_MMC = 0x00000019
  2040. SHTDN_REASON_MINOR_SYSTEMRESTORE = 0x0000001a
  2041. SHTDN_REASON_MINOR_TERMSRV = 0x00000020
  2042. SHTDN_REASON_MINOR_DC_PROMOTION = 0x00000021
  2043. SHTDN_REASON_MINOR_DC_DEMOTION = 0x00000022
  2044. SHTDN_REASON_UNKNOWN = SHTDN_REASON_MINOR_NONE
  2045. SHTDN_REASON_LEGACY_API = SHTDN_REASON_MAJOR_LEGACY_API | SHTDN_REASON_FLAG_PLANNED
  2046. SHTDN_REASON_VALID_BIT_MASK = 0xc0ffffff
  2047. SHUTDOWN_NORETRY = 0x1
  2048. )
  2049. // Flags used for GetModuleHandleEx
  2050. const (
  2051. GET_MODULE_HANDLE_EX_FLAG_PIN = 1
  2052. GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2
  2053. GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 4
  2054. )
  2055. // MUI function flag values
  2056. const (
  2057. MUI_LANGUAGE_ID = 0x4
  2058. MUI_LANGUAGE_NAME = 0x8
  2059. MUI_MERGE_SYSTEM_FALLBACK = 0x10
  2060. MUI_MERGE_USER_FALLBACK = 0x20
  2061. MUI_UI_FALLBACK = MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK
  2062. MUI_THREAD_LANGUAGES = 0x40
  2063. MUI_CONSOLE_FILTER = 0x100
  2064. MUI_COMPLEX_SCRIPT_FILTER = 0x200
  2065. MUI_RESET_FILTERS = 0x001
  2066. MUI_USER_PREFERRED_UI_LANGUAGES = 0x10
  2067. MUI_USE_INSTALLED_LANGUAGES = 0x20
  2068. MUI_USE_SEARCH_ALL_LANGUAGES = 0x40
  2069. MUI_LANG_NEUTRAL_PE_FILE = 0x100
  2070. MUI_NON_LANG_NEUTRAL_FILE = 0x200
  2071. MUI_MACHINE_LANGUAGE_SETTINGS = 0x400
  2072. MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL = 0x001
  2073. MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN = 0x002
  2074. MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI = 0x004
  2075. MUI_QUERY_TYPE = 0x001
  2076. MUI_QUERY_CHECKSUM = 0x002
  2077. MUI_QUERY_LANGUAGE_NAME = 0x004
  2078. MUI_QUERY_RESOURCE_TYPES = 0x008
  2079. MUI_FILEINFO_VERSION = 0x001
  2080. MUI_FULL_LANGUAGE = 0x01
  2081. MUI_PARTIAL_LANGUAGE = 0x02
  2082. MUI_LIP_LANGUAGE = 0x04
  2083. MUI_LANGUAGE_INSTALLED = 0x20
  2084. MUI_LANGUAGE_LICENSED = 0x40
  2085. )
  2086. // FILE_INFO_BY_HANDLE_CLASS constants for SetFileInformationByHandle/GetFileInformationByHandleEx
  2087. const (
  2088. FileBasicInfo = 0
  2089. FileStandardInfo = 1
  2090. FileNameInfo = 2
  2091. FileRenameInfo = 3
  2092. FileDispositionInfo = 4
  2093. FileAllocationInfo = 5
  2094. FileEndOfFileInfo = 6
  2095. FileStreamInfo = 7
  2096. FileCompressionInfo = 8
  2097. FileAttributeTagInfo = 9
  2098. FileIdBothDirectoryInfo = 10
  2099. FileIdBothDirectoryRestartInfo = 11
  2100. FileIoPriorityHintInfo = 12
  2101. FileRemoteProtocolInfo = 13
  2102. FileFullDirectoryInfo = 14
  2103. FileFullDirectoryRestartInfo = 15
  2104. FileStorageInfo = 16
  2105. FileAlignmentInfo = 17
  2106. FileIdInfo = 18
  2107. FileIdExtdDirectoryInfo = 19
  2108. FileIdExtdDirectoryRestartInfo = 20
  2109. FileDispositionInfoEx = 21
  2110. FileRenameInfoEx = 22
  2111. FileCaseSensitiveInfo = 23
  2112. FileNormalizedNameInfo = 24
  2113. )
  2114. // LoadLibrary flags for determining from where to search for a DLL
  2115. const (
  2116. DONT_RESOLVE_DLL_REFERENCES = 0x1
  2117. LOAD_LIBRARY_AS_DATAFILE = 0x2
  2118. LOAD_WITH_ALTERED_SEARCH_PATH = 0x8
  2119. LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x10
  2120. LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x20
  2121. LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x40
  2122. LOAD_LIBRARY_REQUIRE_SIGNED_TARGET = 0x80
  2123. LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x100
  2124. LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x200
  2125. LOAD_LIBRARY_SEARCH_USER_DIRS = 0x400
  2126. LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x800
  2127. LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x1000
  2128. LOAD_LIBRARY_SAFE_CURRENT_DIRS = 0x00002000
  2129. LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER = 0x00004000
  2130. LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY = 0x00008000
  2131. )
  2132. // RegNotifyChangeKeyValue notifyFilter flags.
  2133. const (
  2134. // REG_NOTIFY_CHANGE_NAME notifies the caller if a subkey is added or deleted.
  2135. REG_NOTIFY_CHANGE_NAME = 0x00000001
  2136. // REG_NOTIFY_CHANGE_ATTRIBUTES notifies the caller of changes to the attributes of the key, such as the security descriptor information.
  2137. REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002
  2138. // 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.
  2139. REG_NOTIFY_CHANGE_LAST_SET = 0x00000004
  2140. // REG_NOTIFY_CHANGE_SECURITY notifies the caller of changes to the security descriptor of the key.
  2141. REG_NOTIFY_CHANGE_SECURITY = 0x00000008
  2142. // 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.
  2143. REG_NOTIFY_THREAD_AGNOSTIC = 0x10000000
  2144. )
  2145. type CommTimeouts struct {
  2146. ReadIntervalTimeout uint32
  2147. ReadTotalTimeoutMultiplier uint32
  2148. ReadTotalTimeoutConstant uint32
  2149. WriteTotalTimeoutMultiplier uint32
  2150. WriteTotalTimeoutConstant uint32
  2151. }
  2152. // NTUnicodeString is a UTF-16 string for NT native APIs, corresponding to UNICODE_STRING.
  2153. type NTUnicodeString struct {
  2154. Length uint16
  2155. MaximumLength uint16
  2156. Buffer *uint16
  2157. }
  2158. // NTString is an ANSI string for NT native APIs, corresponding to STRING.
  2159. type NTString struct {
  2160. Length uint16
  2161. MaximumLength uint16
  2162. Buffer *byte
  2163. }
  2164. type LIST_ENTRY struct {
  2165. Flink *LIST_ENTRY
  2166. Blink *LIST_ENTRY
  2167. }
  2168. type RUNTIME_FUNCTION struct {
  2169. BeginAddress uint32
  2170. EndAddress uint32
  2171. UnwindData uint32
  2172. }
  2173. type LDR_DATA_TABLE_ENTRY struct {
  2174. reserved1 [2]uintptr
  2175. InMemoryOrderLinks LIST_ENTRY
  2176. reserved2 [2]uintptr
  2177. DllBase uintptr
  2178. reserved3 [2]uintptr
  2179. FullDllName NTUnicodeString
  2180. reserved4 [8]byte
  2181. reserved5 [3]uintptr
  2182. reserved6 uintptr
  2183. TimeDateStamp uint32
  2184. }
  2185. type PEB_LDR_DATA struct {
  2186. reserved1 [8]byte
  2187. reserved2 [3]uintptr
  2188. InMemoryOrderModuleList LIST_ENTRY
  2189. }
  2190. type CURDIR struct {
  2191. DosPath NTUnicodeString
  2192. Handle Handle
  2193. }
  2194. type RTL_DRIVE_LETTER_CURDIR struct {
  2195. Flags uint16
  2196. Length uint16
  2197. TimeStamp uint32
  2198. DosPath NTString
  2199. }
  2200. type RTL_USER_PROCESS_PARAMETERS struct {
  2201. MaximumLength, Length uint32
  2202. Flags, DebugFlags uint32
  2203. ConsoleHandle Handle
  2204. ConsoleFlags uint32
  2205. StandardInput, StandardOutput, StandardError Handle
  2206. CurrentDirectory CURDIR
  2207. DllPath NTUnicodeString
  2208. ImagePathName NTUnicodeString
  2209. CommandLine NTUnicodeString
  2210. Environment unsafe.Pointer
  2211. StartingX, StartingY, CountX, CountY, CountCharsX, CountCharsY, FillAttribute uint32
  2212. WindowFlags, ShowWindowFlags uint32
  2213. WindowTitle, DesktopInfo, ShellInfo, RuntimeData NTUnicodeString
  2214. CurrentDirectories [32]RTL_DRIVE_LETTER_CURDIR
  2215. EnvironmentSize, EnvironmentVersion uintptr
  2216. PackageDependencyData unsafe.Pointer
  2217. ProcessGroupId uint32
  2218. LoaderThreads uint32
  2219. RedirectionDllName NTUnicodeString
  2220. HeapPartitionName NTUnicodeString
  2221. DefaultThreadpoolCpuSetMasks uintptr
  2222. DefaultThreadpoolCpuSetMaskCount uint32
  2223. }
  2224. type PEB struct {
  2225. reserved1 [2]byte
  2226. BeingDebugged byte
  2227. BitField byte
  2228. reserved3 uintptr
  2229. ImageBaseAddress uintptr
  2230. Ldr *PEB_LDR_DATA
  2231. ProcessParameters *RTL_USER_PROCESS_PARAMETERS
  2232. reserved4 [3]uintptr
  2233. AtlThunkSListPtr uintptr
  2234. reserved5 uintptr
  2235. reserved6 uint32
  2236. reserved7 uintptr
  2237. reserved8 uint32
  2238. AtlThunkSListPtr32 uint32
  2239. reserved9 [45]uintptr
  2240. reserved10 [96]byte
  2241. PostProcessInitRoutine uintptr
  2242. reserved11 [128]byte
  2243. reserved12 [1]uintptr
  2244. SessionId uint32
  2245. }
  2246. type OBJECT_ATTRIBUTES struct {
  2247. Length uint32
  2248. RootDirectory Handle
  2249. ObjectName *NTUnicodeString
  2250. Attributes uint32
  2251. SecurityDescriptor *SECURITY_DESCRIPTOR
  2252. SecurityQoS *SECURITY_QUALITY_OF_SERVICE
  2253. }
  2254. // Values for the Attributes member of OBJECT_ATTRIBUTES.
  2255. const (
  2256. OBJ_INHERIT = 0x00000002
  2257. OBJ_PERMANENT = 0x00000010
  2258. OBJ_EXCLUSIVE = 0x00000020
  2259. OBJ_CASE_INSENSITIVE = 0x00000040
  2260. OBJ_OPENIF = 0x00000080
  2261. OBJ_OPENLINK = 0x00000100
  2262. OBJ_KERNEL_HANDLE = 0x00000200
  2263. OBJ_FORCE_ACCESS_CHECK = 0x00000400
  2264. OBJ_IGNORE_IMPERSONATED_DEVICEMAP = 0x00000800
  2265. OBJ_DONT_REPARSE = 0x00001000
  2266. OBJ_VALID_ATTRIBUTES = 0x00001FF2
  2267. )
  2268. type IO_STATUS_BLOCK struct {
  2269. Status NTStatus
  2270. Information uintptr
  2271. }
  2272. type RTLP_CURDIR_REF struct {
  2273. RefCount int32
  2274. Handle Handle
  2275. }
  2276. type RTL_RELATIVE_NAME struct {
  2277. RelativeName NTUnicodeString
  2278. ContainingDirectory Handle
  2279. CurDirRef *RTLP_CURDIR_REF
  2280. }
  2281. const (
  2282. // CreateDisposition flags for NtCreateFile and NtCreateNamedPipeFile.
  2283. FILE_SUPERSEDE = 0x00000000
  2284. FILE_OPEN = 0x00000001
  2285. FILE_CREATE = 0x00000002
  2286. FILE_OPEN_IF = 0x00000003
  2287. FILE_OVERWRITE = 0x00000004
  2288. FILE_OVERWRITE_IF = 0x00000005
  2289. FILE_MAXIMUM_DISPOSITION = 0x00000005
  2290. // CreateOptions flags for NtCreateFile and NtCreateNamedPipeFile.
  2291. FILE_DIRECTORY_FILE = 0x00000001
  2292. FILE_WRITE_THROUGH = 0x00000002
  2293. FILE_SEQUENTIAL_ONLY = 0x00000004
  2294. FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008
  2295. FILE_SYNCHRONOUS_IO_ALERT = 0x00000010
  2296. FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020
  2297. FILE_NON_DIRECTORY_FILE = 0x00000040
  2298. FILE_CREATE_TREE_CONNECTION = 0x00000080
  2299. FILE_COMPLETE_IF_OPLOCKED = 0x00000100
  2300. FILE_NO_EA_KNOWLEDGE = 0x00000200
  2301. FILE_OPEN_REMOTE_INSTANCE = 0x00000400
  2302. FILE_RANDOM_ACCESS = 0x00000800
  2303. FILE_DELETE_ON_CLOSE = 0x00001000
  2304. FILE_OPEN_BY_FILE_ID = 0x00002000
  2305. FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000
  2306. FILE_NO_COMPRESSION = 0x00008000
  2307. FILE_OPEN_REQUIRING_OPLOCK = 0x00010000
  2308. FILE_DISALLOW_EXCLUSIVE = 0x00020000
  2309. FILE_RESERVE_OPFILTER = 0x00100000
  2310. FILE_OPEN_REPARSE_POINT = 0x00200000
  2311. FILE_OPEN_NO_RECALL = 0x00400000
  2312. FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
  2313. // Parameter constants for NtCreateNamedPipeFile.
  2314. FILE_PIPE_BYTE_STREAM_TYPE = 0x00000000
  2315. FILE_PIPE_MESSAGE_TYPE = 0x00000001
  2316. FILE_PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000
  2317. FILE_PIPE_REJECT_REMOTE_CLIENTS = 0x00000002
  2318. FILE_PIPE_TYPE_VALID_MASK = 0x00000003
  2319. FILE_PIPE_BYTE_STREAM_MODE = 0x00000000
  2320. FILE_PIPE_MESSAGE_MODE = 0x00000001
  2321. FILE_PIPE_QUEUE_OPERATION = 0x00000000
  2322. FILE_PIPE_COMPLETE_OPERATION = 0x00000001
  2323. FILE_PIPE_INBOUND = 0x00000000
  2324. FILE_PIPE_OUTBOUND = 0x00000001
  2325. FILE_PIPE_FULL_DUPLEX = 0x00000002
  2326. FILE_PIPE_DISCONNECTED_STATE = 0x00000001
  2327. FILE_PIPE_LISTENING_STATE = 0x00000002
  2328. FILE_PIPE_CONNECTED_STATE = 0x00000003
  2329. FILE_PIPE_CLOSING_STATE = 0x00000004
  2330. FILE_PIPE_CLIENT_END = 0x00000000
  2331. FILE_PIPE_SERVER_END = 0x00000001
  2332. )
  2333. const (
  2334. // FileInformationClass for NtSetInformationFile
  2335. FileBasicInformation = 4
  2336. FileRenameInformation = 10
  2337. FileDispositionInformation = 13
  2338. FilePositionInformation = 14
  2339. FileEndOfFileInformation = 20
  2340. FileValidDataLengthInformation = 39
  2341. FileShortNameInformation = 40
  2342. FileIoPriorityHintInformation = 43
  2343. FileReplaceCompletionInformation = 61
  2344. FileDispositionInformationEx = 64
  2345. FileCaseSensitiveInformation = 71
  2346. FileLinkInformation = 72
  2347. FileCaseSensitiveInformationForceAccessCheck = 75
  2348. FileKnownFolderInformation = 76
  2349. // Flags for FILE_RENAME_INFORMATION
  2350. FILE_RENAME_REPLACE_IF_EXISTS = 0x00000001
  2351. FILE_RENAME_POSIX_SEMANTICS = 0x00000002
  2352. FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE = 0x00000004
  2353. FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008
  2354. FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE = 0x00000010
  2355. FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE = 0x00000020
  2356. FILE_RENAME_PRESERVE_AVAILABLE_SPACE = 0x00000030
  2357. FILE_RENAME_IGNORE_READONLY_ATTRIBUTE = 0x00000040
  2358. FILE_RENAME_FORCE_RESIZE_TARGET_SR = 0x00000080
  2359. FILE_RENAME_FORCE_RESIZE_SOURCE_SR = 0x00000100
  2360. FILE_RENAME_FORCE_RESIZE_SR = 0x00000180
  2361. // Flags for FILE_DISPOSITION_INFORMATION_EX
  2362. FILE_DISPOSITION_DO_NOT_DELETE = 0x00000000
  2363. FILE_DISPOSITION_DELETE = 0x00000001
  2364. FILE_DISPOSITION_POSIX_SEMANTICS = 0x00000002
  2365. FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK = 0x00000004
  2366. FILE_DISPOSITION_ON_CLOSE = 0x00000008
  2367. FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE = 0x00000010
  2368. // Flags for FILE_CASE_SENSITIVE_INFORMATION
  2369. FILE_CS_FLAG_CASE_SENSITIVE_DIR = 0x00000001
  2370. // Flags for FILE_LINK_INFORMATION
  2371. FILE_LINK_REPLACE_IF_EXISTS = 0x00000001
  2372. FILE_LINK_POSIX_SEMANTICS = 0x00000002
  2373. FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008
  2374. FILE_LINK_NO_INCREASE_AVAILABLE_SPACE = 0x00000010
  2375. FILE_LINK_NO_DECREASE_AVAILABLE_SPACE = 0x00000020
  2376. FILE_LINK_PRESERVE_AVAILABLE_SPACE = 0x00000030
  2377. FILE_LINK_IGNORE_READONLY_ATTRIBUTE = 0x00000040
  2378. FILE_LINK_FORCE_RESIZE_TARGET_SR = 0x00000080
  2379. FILE_LINK_FORCE_RESIZE_SOURCE_SR = 0x00000100
  2380. FILE_LINK_FORCE_RESIZE_SR = 0x00000180
  2381. )
  2382. // ProcessInformationClasses for NtQueryInformationProcess and NtSetInformationProcess.
  2383. const (
  2384. ProcessBasicInformation = iota
  2385. ProcessQuotaLimits
  2386. ProcessIoCounters
  2387. ProcessVmCounters
  2388. ProcessTimes
  2389. ProcessBasePriority
  2390. ProcessRaisePriority
  2391. ProcessDebugPort
  2392. ProcessExceptionPort
  2393. ProcessAccessToken
  2394. ProcessLdtInformation
  2395. ProcessLdtSize
  2396. ProcessDefaultHardErrorMode
  2397. ProcessIoPortHandlers
  2398. ProcessPooledUsageAndLimits
  2399. ProcessWorkingSetWatch
  2400. ProcessUserModeIOPL
  2401. ProcessEnableAlignmentFaultFixup
  2402. ProcessPriorityClass
  2403. ProcessWx86Information
  2404. ProcessHandleCount
  2405. ProcessAffinityMask
  2406. ProcessPriorityBoost
  2407. ProcessDeviceMap
  2408. ProcessSessionInformation
  2409. ProcessForegroundInformation
  2410. ProcessWow64Information
  2411. ProcessImageFileName
  2412. ProcessLUIDDeviceMapsEnabled
  2413. ProcessBreakOnTermination
  2414. ProcessDebugObjectHandle
  2415. ProcessDebugFlags
  2416. ProcessHandleTracing
  2417. ProcessIoPriority
  2418. ProcessExecuteFlags
  2419. ProcessTlsInformation
  2420. ProcessCookie
  2421. ProcessImageInformation
  2422. ProcessCycleTime
  2423. ProcessPagePriority
  2424. ProcessInstrumentationCallback
  2425. ProcessThreadStackAllocation
  2426. ProcessWorkingSetWatchEx
  2427. ProcessImageFileNameWin32
  2428. ProcessImageFileMapping
  2429. ProcessAffinityUpdateMode
  2430. ProcessMemoryAllocationMode
  2431. ProcessGroupInformation
  2432. ProcessTokenVirtualizationEnabled
  2433. ProcessConsoleHostProcess
  2434. ProcessWindowInformation
  2435. ProcessHandleInformation
  2436. ProcessMitigationPolicy
  2437. ProcessDynamicFunctionTableInformation
  2438. ProcessHandleCheckingMode
  2439. ProcessKeepAliveCount
  2440. ProcessRevokeFileHandles
  2441. ProcessWorkingSetControl
  2442. ProcessHandleTable
  2443. ProcessCheckStackExtentsMode
  2444. ProcessCommandLineInformation
  2445. ProcessProtectionInformation
  2446. ProcessMemoryExhaustion
  2447. ProcessFaultInformation
  2448. ProcessTelemetryIdInformation
  2449. ProcessCommitReleaseInformation
  2450. ProcessDefaultCpuSetsInformation
  2451. ProcessAllowedCpuSetsInformation
  2452. ProcessSubsystemProcess
  2453. ProcessJobMemoryInformation
  2454. ProcessInPrivate
  2455. ProcessRaiseUMExceptionOnInvalidHandleClose
  2456. ProcessIumChallengeResponse
  2457. ProcessChildProcessInformation
  2458. ProcessHighGraphicsPriorityInformation
  2459. ProcessSubsystemInformation
  2460. ProcessEnergyValues
  2461. ProcessActivityThrottleState
  2462. ProcessActivityThrottlePolicy
  2463. ProcessWin32kSyscallFilterInformation
  2464. ProcessDisableSystemAllowedCpuSets
  2465. ProcessWakeInformation
  2466. ProcessEnergyTrackingState
  2467. ProcessManageWritesToExecutableMemory
  2468. ProcessCaptureTrustletLiveDump
  2469. ProcessTelemetryCoverage
  2470. ProcessEnclaveInformation
  2471. ProcessEnableReadWriteVmLogging
  2472. ProcessUptimeInformation
  2473. ProcessImageSection
  2474. ProcessDebugAuthInformation
  2475. ProcessSystemResourceManagement
  2476. ProcessSequenceNumber
  2477. ProcessLoaderDetour
  2478. ProcessSecurityDomainInformation
  2479. ProcessCombineSecurityDomainsInformation
  2480. ProcessEnableLogging
  2481. ProcessLeapSecondInformation
  2482. ProcessFiberShadowStackAllocation
  2483. ProcessFreeFiberShadowStackAllocation
  2484. ProcessAltSystemCallInformation
  2485. ProcessDynamicEHContinuationTargets
  2486. ProcessDynamicEnforcedCetCompatibleRanges
  2487. )
  2488. type PROCESS_BASIC_INFORMATION struct {
  2489. ExitStatus NTStatus
  2490. PebBaseAddress *PEB
  2491. AffinityMask uintptr
  2492. BasePriority int32
  2493. UniqueProcessId uintptr
  2494. InheritedFromUniqueProcessId uintptr
  2495. }
  2496. type SYSTEM_PROCESS_INFORMATION struct {
  2497. NextEntryOffset uint32
  2498. NumberOfThreads uint32
  2499. WorkingSetPrivateSize int64
  2500. HardFaultCount uint32
  2501. NumberOfThreadsHighWatermark uint32
  2502. CycleTime uint64
  2503. CreateTime int64
  2504. UserTime int64
  2505. KernelTime int64
  2506. ImageName NTUnicodeString
  2507. BasePriority int32
  2508. UniqueProcessID uintptr
  2509. InheritedFromUniqueProcessID uintptr
  2510. HandleCount uint32
  2511. SessionID uint32
  2512. UniqueProcessKey *uint32
  2513. PeakVirtualSize uintptr
  2514. VirtualSize uintptr
  2515. PageFaultCount uint32
  2516. PeakWorkingSetSize uintptr
  2517. WorkingSetSize uintptr
  2518. QuotaPeakPagedPoolUsage uintptr
  2519. QuotaPagedPoolUsage uintptr
  2520. QuotaPeakNonPagedPoolUsage uintptr
  2521. QuotaNonPagedPoolUsage uintptr
  2522. PagefileUsage uintptr
  2523. PeakPagefileUsage uintptr
  2524. PrivatePageCount uintptr
  2525. ReadOperationCount int64
  2526. WriteOperationCount int64
  2527. OtherOperationCount int64
  2528. ReadTransferCount int64
  2529. WriteTransferCount int64
  2530. OtherTransferCount int64
  2531. }
  2532. // SystemInformationClasses for NtQuerySystemInformation and NtSetSystemInformation
  2533. const (
  2534. SystemBasicInformation = iota
  2535. SystemProcessorInformation
  2536. SystemPerformanceInformation
  2537. SystemTimeOfDayInformation
  2538. SystemPathInformation
  2539. SystemProcessInformation
  2540. SystemCallCountInformation
  2541. SystemDeviceInformation
  2542. SystemProcessorPerformanceInformation
  2543. SystemFlagsInformation
  2544. SystemCallTimeInformation
  2545. SystemModuleInformation
  2546. SystemLocksInformation
  2547. SystemStackTraceInformation
  2548. SystemPagedPoolInformation
  2549. SystemNonPagedPoolInformation
  2550. SystemHandleInformation
  2551. SystemObjectInformation
  2552. SystemPageFileInformation
  2553. SystemVdmInstemulInformation
  2554. SystemVdmBopInformation
  2555. SystemFileCacheInformation
  2556. SystemPoolTagInformation
  2557. SystemInterruptInformation
  2558. SystemDpcBehaviorInformation
  2559. SystemFullMemoryInformation
  2560. SystemLoadGdiDriverInformation
  2561. SystemUnloadGdiDriverInformation
  2562. SystemTimeAdjustmentInformation
  2563. SystemSummaryMemoryInformation
  2564. SystemMirrorMemoryInformation
  2565. SystemPerformanceTraceInformation
  2566. systemObsolete0
  2567. SystemExceptionInformation
  2568. SystemCrashDumpStateInformation
  2569. SystemKernelDebuggerInformation
  2570. SystemContextSwitchInformation
  2571. SystemRegistryQuotaInformation
  2572. SystemExtendServiceTableInformation
  2573. SystemPrioritySeperation
  2574. SystemVerifierAddDriverInformation
  2575. SystemVerifierRemoveDriverInformation
  2576. SystemProcessorIdleInformation
  2577. SystemLegacyDriverInformation
  2578. SystemCurrentTimeZoneInformation
  2579. SystemLookasideInformation
  2580. SystemTimeSlipNotification
  2581. SystemSessionCreate
  2582. SystemSessionDetach
  2583. SystemSessionInformation
  2584. SystemRangeStartInformation
  2585. SystemVerifierInformation
  2586. SystemVerifierThunkExtend
  2587. SystemSessionProcessInformation
  2588. SystemLoadGdiDriverInSystemSpace
  2589. SystemNumaProcessorMap
  2590. SystemPrefetcherInformation
  2591. SystemExtendedProcessInformation
  2592. SystemRecommendedSharedDataAlignment
  2593. SystemComPlusPackage
  2594. SystemNumaAvailableMemory
  2595. SystemProcessorPowerInformation
  2596. SystemEmulationBasicInformation
  2597. SystemEmulationProcessorInformation
  2598. SystemExtendedHandleInformation
  2599. SystemLostDelayedWriteInformation
  2600. SystemBigPoolInformation
  2601. SystemSessionPoolTagInformation
  2602. SystemSessionMappedViewInformation
  2603. SystemHotpatchInformation
  2604. SystemObjectSecurityMode
  2605. SystemWatchdogTimerHandler
  2606. SystemWatchdogTimerInformation
  2607. SystemLogicalProcessorInformation
  2608. SystemWow64SharedInformationObsolete
  2609. SystemRegisterFirmwareTableInformationHandler
  2610. SystemFirmwareTableInformation
  2611. SystemModuleInformationEx
  2612. SystemVerifierTriageInformation
  2613. SystemSuperfetchInformation
  2614. SystemMemoryListInformation
  2615. SystemFileCacheInformationEx
  2616. SystemThreadPriorityClientIdInformation
  2617. SystemProcessorIdleCycleTimeInformation
  2618. SystemVerifierCancellationInformation
  2619. SystemProcessorPowerInformationEx
  2620. SystemRefTraceInformation
  2621. SystemSpecialPoolInformation
  2622. SystemProcessIdInformation
  2623. SystemErrorPortInformation
  2624. SystemBootEnvironmentInformation
  2625. SystemHypervisorInformation
  2626. SystemVerifierInformationEx
  2627. SystemTimeZoneInformation
  2628. SystemImageFileExecutionOptionsInformation
  2629. SystemCoverageInformation
  2630. SystemPrefetchPatchInformation
  2631. SystemVerifierFaultsInformation
  2632. SystemSystemPartitionInformation
  2633. SystemSystemDiskInformation
  2634. SystemProcessorPerformanceDistribution
  2635. SystemNumaProximityNodeInformation
  2636. SystemDynamicTimeZoneInformation
  2637. SystemCodeIntegrityInformation
  2638. SystemProcessorMicrocodeUpdateInformation
  2639. SystemProcessorBrandString
  2640. SystemVirtualAddressInformation
  2641. SystemLogicalProcessorAndGroupInformation
  2642. SystemProcessorCycleTimeInformation
  2643. SystemStoreInformation
  2644. SystemRegistryAppendString
  2645. SystemAitSamplingValue
  2646. SystemVhdBootInformation
  2647. SystemCpuQuotaInformation
  2648. SystemNativeBasicInformation
  2649. systemSpare1
  2650. SystemLowPriorityIoInformation
  2651. SystemTpmBootEntropyInformation
  2652. SystemVerifierCountersInformation
  2653. SystemPagedPoolInformationEx
  2654. SystemSystemPtesInformationEx
  2655. SystemNodeDistanceInformation
  2656. SystemAcpiAuditInformation
  2657. SystemBasicPerformanceInformation
  2658. SystemQueryPerformanceCounterInformation
  2659. SystemSessionBigPoolInformation
  2660. SystemBootGraphicsInformation
  2661. SystemScrubPhysicalMemoryInformation
  2662. SystemBadPageInformation
  2663. SystemProcessorProfileControlArea
  2664. SystemCombinePhysicalMemoryInformation
  2665. SystemEntropyInterruptTimingCallback
  2666. SystemConsoleInformation
  2667. SystemPlatformBinaryInformation
  2668. SystemThrottleNotificationInformation
  2669. SystemHypervisorProcessorCountInformation
  2670. SystemDeviceDataInformation
  2671. SystemDeviceDataEnumerationInformation
  2672. SystemMemoryTopologyInformation
  2673. SystemMemoryChannelInformation
  2674. SystemBootLogoInformation
  2675. SystemProcessorPerformanceInformationEx
  2676. systemSpare0
  2677. SystemSecureBootPolicyInformation
  2678. SystemPageFileInformationEx
  2679. SystemSecureBootInformation
  2680. SystemEntropyInterruptTimingRawInformation
  2681. SystemPortableWorkspaceEfiLauncherInformation
  2682. SystemFullProcessInformation
  2683. SystemKernelDebuggerInformationEx
  2684. SystemBootMetadataInformation
  2685. SystemSoftRebootInformation
  2686. SystemElamCertificateInformation
  2687. SystemOfflineDumpConfigInformation
  2688. SystemProcessorFeaturesInformation
  2689. SystemRegistryReconciliationInformation
  2690. SystemEdidInformation
  2691. SystemManufacturingInformation
  2692. SystemEnergyEstimationConfigInformation
  2693. SystemHypervisorDetailInformation
  2694. SystemProcessorCycleStatsInformation
  2695. SystemVmGenerationCountInformation
  2696. SystemTrustedPlatformModuleInformation
  2697. SystemKernelDebuggerFlags
  2698. SystemCodeIntegrityPolicyInformation
  2699. SystemIsolatedUserModeInformation
  2700. SystemHardwareSecurityTestInterfaceResultsInformation
  2701. SystemSingleModuleInformation
  2702. SystemAllowedCpuSetsInformation
  2703. SystemDmaProtectionInformation
  2704. SystemInterruptCpuSetsInformation
  2705. SystemSecureBootPolicyFullInformation
  2706. SystemCodeIntegrityPolicyFullInformation
  2707. SystemAffinitizedInterruptProcessorInformation
  2708. SystemRootSiloInformation
  2709. )
  2710. type RTL_PROCESS_MODULE_INFORMATION struct {
  2711. Section Handle
  2712. MappedBase uintptr
  2713. ImageBase uintptr
  2714. ImageSize uint32
  2715. Flags uint32
  2716. LoadOrderIndex uint16
  2717. InitOrderIndex uint16
  2718. LoadCount uint16
  2719. OffsetToFileName uint16
  2720. FullPathName [256]byte
  2721. }
  2722. type RTL_PROCESS_MODULES struct {
  2723. NumberOfModules uint32
  2724. Modules [1]RTL_PROCESS_MODULE_INFORMATION
  2725. }
  2726. // Constants for LocalAlloc flags.
  2727. const (
  2728. LMEM_FIXED = 0x0
  2729. LMEM_MOVEABLE = 0x2
  2730. LMEM_NOCOMPACT = 0x10
  2731. LMEM_NODISCARD = 0x20
  2732. LMEM_ZEROINIT = 0x40
  2733. LMEM_MODIFY = 0x80
  2734. LMEM_DISCARDABLE = 0xf00
  2735. LMEM_VALID_FLAGS = 0xf72
  2736. LMEM_INVALID_HANDLE = 0x8000
  2737. LHND = LMEM_MOVEABLE | LMEM_ZEROINIT
  2738. LPTR = LMEM_FIXED | LMEM_ZEROINIT
  2739. NONZEROLHND = LMEM_MOVEABLE
  2740. NONZEROLPTR = LMEM_FIXED
  2741. )
  2742. // Constants for the CreateNamedPipe-family of functions.
  2743. const (
  2744. PIPE_ACCESS_INBOUND = 0x1
  2745. PIPE_ACCESS_OUTBOUND = 0x2
  2746. PIPE_ACCESS_DUPLEX = 0x3
  2747. PIPE_CLIENT_END = 0x0
  2748. PIPE_SERVER_END = 0x1
  2749. PIPE_WAIT = 0x0
  2750. PIPE_NOWAIT = 0x1
  2751. PIPE_READMODE_BYTE = 0x0
  2752. PIPE_READMODE_MESSAGE = 0x2
  2753. PIPE_TYPE_BYTE = 0x0
  2754. PIPE_TYPE_MESSAGE = 0x4
  2755. PIPE_ACCEPT_REMOTE_CLIENTS = 0x0
  2756. PIPE_REJECT_REMOTE_CLIENTS = 0x8
  2757. PIPE_UNLIMITED_INSTANCES = 255
  2758. )
  2759. // Constants for security attributes when opening named pipes.
  2760. const (
  2761. SECURITY_ANONYMOUS = SecurityAnonymous << 16
  2762. SECURITY_IDENTIFICATION = SecurityIdentification << 16
  2763. SECURITY_IMPERSONATION = SecurityImpersonation << 16
  2764. SECURITY_DELEGATION = SecurityDelegation << 16
  2765. SECURITY_CONTEXT_TRACKING = 0x40000
  2766. SECURITY_EFFECTIVE_ONLY = 0x80000
  2767. SECURITY_SQOS_PRESENT = 0x100000
  2768. SECURITY_VALID_SQOS_FLAGS = 0x1f0000
  2769. )
  2770. // ResourceID represents a 16-bit resource identifier, traditionally created with the MAKEINTRESOURCE macro.
  2771. type ResourceID uint16
  2772. // ResourceIDOrString must be either a ResourceID, to specify a resource or resource type by ID,
  2773. // or a string, to specify a resource or resource type by name.
  2774. type ResourceIDOrString interface{}
  2775. // Predefined resource names and types.
  2776. var (
  2777. // Predefined names.
  2778. CREATEPROCESS_MANIFEST_RESOURCE_ID ResourceID = 1
  2779. ISOLATIONAWARE_MANIFEST_RESOURCE_ID ResourceID = 2
  2780. ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID ResourceID = 3
  2781. ISOLATIONPOLICY_MANIFEST_RESOURCE_ID ResourceID = 4
  2782. ISOLATIONPOLICY_BROWSER_MANIFEST_RESOURCE_ID ResourceID = 5
  2783. MINIMUM_RESERVED_MANIFEST_RESOURCE_ID ResourceID = 1 // inclusive
  2784. MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID ResourceID = 16 // inclusive
  2785. // Predefined types.
  2786. RT_CURSOR ResourceID = 1
  2787. RT_BITMAP ResourceID = 2
  2788. RT_ICON ResourceID = 3
  2789. RT_MENU ResourceID = 4
  2790. RT_DIALOG ResourceID = 5
  2791. RT_STRING ResourceID = 6
  2792. RT_FONTDIR ResourceID = 7
  2793. RT_FONT ResourceID = 8
  2794. RT_ACCELERATOR ResourceID = 9
  2795. RT_RCDATA ResourceID = 10
  2796. RT_MESSAGETABLE ResourceID = 11
  2797. RT_GROUP_CURSOR ResourceID = 12
  2798. RT_GROUP_ICON ResourceID = 14
  2799. RT_VERSION ResourceID = 16
  2800. RT_DLGINCLUDE ResourceID = 17
  2801. RT_PLUGPLAY ResourceID = 19
  2802. RT_VXD ResourceID = 20
  2803. RT_ANICURSOR ResourceID = 21
  2804. RT_ANIICON ResourceID = 22
  2805. RT_HTML ResourceID = 23
  2806. RT_MANIFEST ResourceID = 24
  2807. )
  2808. type VS_FIXEDFILEINFO struct {
  2809. Signature uint32
  2810. StrucVersion uint32
  2811. FileVersionMS uint32
  2812. FileVersionLS uint32
  2813. ProductVersionMS uint32
  2814. ProductVersionLS uint32
  2815. FileFlagsMask uint32
  2816. FileFlags uint32
  2817. FileOS uint32
  2818. FileType uint32
  2819. FileSubtype uint32
  2820. FileDateMS uint32
  2821. FileDateLS uint32
  2822. }
  2823. type COAUTHIDENTITY struct {
  2824. User *uint16
  2825. UserLength uint32
  2826. Domain *uint16
  2827. DomainLength uint32
  2828. Password *uint16
  2829. PasswordLength uint32
  2830. Flags uint32
  2831. }
  2832. type COAUTHINFO struct {
  2833. AuthnSvc uint32
  2834. AuthzSvc uint32
  2835. ServerPrincName *uint16
  2836. AuthnLevel uint32
  2837. ImpersonationLevel uint32
  2838. AuthIdentityData *COAUTHIDENTITY
  2839. Capabilities uint32
  2840. }
  2841. type COSERVERINFO struct {
  2842. Reserved1 uint32
  2843. Aame *uint16
  2844. AuthInfo *COAUTHINFO
  2845. Reserved2 uint32
  2846. }
  2847. type BIND_OPTS3 struct {
  2848. CbStruct uint32
  2849. Flags uint32
  2850. Mode uint32
  2851. TickCountDeadline uint32
  2852. TrackFlags uint32
  2853. ClassContext uint32
  2854. Locale uint32
  2855. ServerInfo *COSERVERINFO
  2856. Hwnd HWND
  2857. }
  2858. const (
  2859. CLSCTX_INPROC_SERVER = 0x1
  2860. CLSCTX_INPROC_HANDLER = 0x2
  2861. CLSCTX_LOCAL_SERVER = 0x4
  2862. CLSCTX_INPROC_SERVER16 = 0x8
  2863. CLSCTX_REMOTE_SERVER = 0x10
  2864. CLSCTX_INPROC_HANDLER16 = 0x20
  2865. CLSCTX_RESERVED1 = 0x40
  2866. CLSCTX_RESERVED2 = 0x80
  2867. CLSCTX_RESERVED3 = 0x100
  2868. CLSCTX_RESERVED4 = 0x200
  2869. CLSCTX_NO_CODE_DOWNLOAD = 0x400
  2870. CLSCTX_RESERVED5 = 0x800
  2871. CLSCTX_NO_CUSTOM_MARSHAL = 0x1000
  2872. CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000
  2873. CLSCTX_NO_FAILURE_LOG = 0x4000
  2874. CLSCTX_DISABLE_AAA = 0x8000
  2875. CLSCTX_ENABLE_AAA = 0x10000
  2876. CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000
  2877. CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000
  2878. CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
  2879. CLSCTX_ENABLE_CLOAKING = 0x100000
  2880. CLSCTX_APPCONTAINER = 0x400000
  2881. CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000
  2882. CLSCTX_PS_DLL = 0x80000000
  2883. COINIT_MULTITHREADED = 0x0
  2884. COINIT_APARTMENTTHREADED = 0x2
  2885. COINIT_DISABLE_OLE1DDE = 0x4
  2886. COINIT_SPEED_OVER_MEMORY = 0x8
  2887. )
  2888. // Flag for QueryFullProcessImageName.
  2889. const PROCESS_NAME_NATIVE = 1
  2890. type ModuleInfo struct {
  2891. BaseOfDll uintptr
  2892. SizeOfImage uint32
  2893. EntryPoint uintptr
  2894. }
  2895. const ALL_PROCESSOR_GROUPS = 0xFFFF