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.
 
 

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