Debian Codegraph @

windows/types_windows.go

raw
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
5 package windows
6
7 import (
8 "net"
9 "syscall"
10 "unsafe"
11 )
12
13 // NTStatus corresponds with NTSTATUS, error values returned by ntdll.dll and
14 // other native functions.
15 type NTStatus uint32
16
17 const (
18 // Invented values to support what package os expects.
19 O_RDONLY = 0x00000
20 O_WRONLY = 0x00001
21 O_RDWR = 0x00002
22 O_CREAT = 0x00040
23 O_EXCL = 0x00080
24 O_NOCTTY = 0x00100
25 O_TRUNC = 0x00200
26 O_NONBLOCK = 0x00800
27 O_APPEND = 0x00400
28 O_SYNC = 0x01000
29 O_ASYNC = 0x02000
30 O_CLOEXEC = 0x80000
31 )
32
33 const (
34 // More invented values for signals
35 SIGHUP = Signal(0x1)
36 SIGINT = Signal(0x2)
37 SIGQUIT = Signal(0x3)
38 SIGILL = Signal(0x4)
39 SIGTRAP = Signal(0x5)
40 SIGABRT = Signal(0x6)
41 SIGBUS = Signal(0x7)
42 SIGFPE = Signal(0x8)
43 SIGKILL = Signal(0x9)
44 SIGSEGV = Signal(0xb)
45 SIGPIPE = Signal(0xd)
46 SIGALRM = Signal(0xe)
47 SIGTERM = Signal(0xf)
48 )
49
50 var signals = [...]string{
51 1: "hangup",
52 2: "interrupt",
53 3: "quit",
54 4: "illegal instruction",
55 5: "trace/breakpoint trap",
56 6: "aborted",
57 7: "bus error",
58 8: "floating point exception",
59 9: "killed",
60 10: "user defined signal 1",
61 11: "segmentation fault",
62 12: "user defined signal 2",
63 13: "broken pipe",
64 14: "alarm clock",
65 15: "terminated",
66 }
67
68 // File flags for [os.OpenFile]. The O_ prefix is used to indicate
69 // that these flags are specific to the OpenFile function.
70 const (
71 O_FILE_FLAG_OPEN_NO_RECALL = FILE_FLAG_OPEN_NO_RECALL
72 O_FILE_FLAG_OPEN_REPARSE_POINT = FILE_FLAG_OPEN_REPARSE_POINT
73 O_FILE_FLAG_SESSION_AWARE = FILE_FLAG_SESSION_AWARE
74 O_FILE_FLAG_POSIX_SEMANTICS = FILE_FLAG_POSIX_SEMANTICS
75 O_FILE_FLAG_BACKUP_SEMANTICS = FILE_FLAG_BACKUP_SEMANTICS
76 O_FILE_FLAG_DELETE_ON_CLOSE = FILE_FLAG_DELETE_ON_CLOSE
77 O_FILE_FLAG_SEQUENTIAL_SCAN = FILE_FLAG_SEQUENTIAL_SCAN
78 O_FILE_FLAG_RANDOM_ACCESS = FILE_FLAG_RANDOM_ACCESS
79 O_FILE_FLAG_NO_BUFFERING = FILE_FLAG_NO_BUFFERING
80 O_FILE_FLAG_OVERLAPPED = FILE_FLAG_OVERLAPPED
81 O_FILE_FLAG_WRITE_THROUGH = FILE_FLAG_WRITE_THROUGH
82 )
83
84 const (
85 FILE_READ_DATA = 0x00000001
86 FILE_READ_ATTRIBUTES = 0x00000080
87 FILE_READ_EA = 0x00000008
88 FILE_WRITE_DATA = 0x00000002
89 FILE_WRITE_ATTRIBUTES = 0x00000100
90 FILE_WRITE_EA = 0x00000010
91 FILE_APPEND_DATA = 0x00000004
92 FILE_EXECUTE = 0x00000020
93
94 FILE_GENERIC_READ = STANDARD_RIGHTS_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES | FILE_READ_EA | SYNCHRONIZE
95 FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE
96 FILE_GENERIC_EXECUTE = STANDARD_RIGHTS_EXECUTE | FILE_READ_ATTRIBUTES | FILE_EXECUTE | SYNCHRONIZE
97
98 FILE_LIST_DIRECTORY = 0x00000001
99 FILE_TRAVERSE = 0x00000020
100
101 FILE_SHARE_READ = 0x00000001
102 FILE_SHARE_WRITE = 0x00000002
103 FILE_SHARE_DELETE = 0x00000004
104
105 FILE_ATTRIBUTE_READONLY = 0x00000001
106 FILE_ATTRIBUTE_HIDDEN = 0x00000002
107 FILE_ATTRIBUTE_SYSTEM = 0x00000004
108 FILE_ATTRIBUTE_DIRECTORY = 0x00000010
109 FILE_ATTRIBUTE_ARCHIVE = 0x00000020
110 FILE_ATTRIBUTE_DEVICE = 0x00000040
111 FILE_ATTRIBUTE_NORMAL = 0x00000080
112 FILE_ATTRIBUTE_TEMPORARY = 0x00000100
113 FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200
114 FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
115 FILE_ATTRIBUTE_COMPRESSED = 0x00000800
116 FILE_ATTRIBUTE_OFFLINE = 0x00001000
117 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
118 FILE_ATTRIBUTE_ENCRYPTED = 0x00004000
119 FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000
120 FILE_ATTRIBUTE_VIRTUAL = 0x00010000
121 FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000
122 FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000
123 FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000
124
125 INVALID_FILE_ATTRIBUTES = 0xffffffff
126
127 CREATE_NEW = 1
128 CREATE_ALWAYS = 2
129 OPEN_EXISTING = 3
130 OPEN_ALWAYS = 4
131 TRUNCATE_EXISTING = 5
132
133 FILE_FLAG_OPEN_REQUIRING_OPLOCK = 0x00040000
134 FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000
135 FILE_FLAG_OPEN_NO_RECALL = 0x00100000
136 FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
137 FILE_FLAG_SESSION_AWARE = 0x00800000
138 FILE_FLAG_POSIX_SEMANTICS = 0x01000000
139 FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
140 FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
141 FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000
142 FILE_FLAG_RANDOM_ACCESS = 0x10000000
143 FILE_FLAG_NO_BUFFERING = 0x20000000
144 FILE_FLAG_OVERLAPPED = 0x40000000
145 FILE_FLAG_WRITE_THROUGH = 0x80000000
146
147 HANDLE_FLAG_INHERIT = 0x00000001
148 STARTF_USESTDHANDLES = 0x00000100
149 STARTF_USESHOWWINDOW = 0x00000001
150 DUPLICATE_CLOSE_SOURCE = 0x00000001
151 DUPLICATE_SAME_ACCESS = 0x00000002
152
153 STD_INPUT_HANDLE = -10 & (1<<32 - 1)
154 STD_OUTPUT_HANDLE = -11 & (1<<32 - 1)
155 STD_ERROR_HANDLE = -12 & (1<<32 - 1)
156
157 FILE_BEGIN = 0
158 FILE_CURRENT = 1
159 FILE_END = 2
160
161 LANG_ENGLISH = 0x09
162 SUBLANG_ENGLISH_US = 0x01
163
164 FORMAT_MESSAGE_ALLOCATE_BUFFER = 256
165 FORMAT_MESSAGE_IGNORE_INSERTS = 512
166 FORMAT_MESSAGE_FROM_STRING = 1024
167 FORMAT_MESSAGE_FROM_HMODULE = 2048
168 FORMAT_MESSAGE_FROM_SYSTEM = 4096
169 FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192
170 FORMAT_MESSAGE_MAX_WIDTH_MASK = 255
171
172 MAX_USHORT = 0xffff
173 MAX_PATH = 260
174 MAX_LONG_PATH = 32768
175
176 MAX_MODULE_NAME32 = 255
177
178 MAX_COMPUTERNAME_LENGTH = 15
179
180 MAX_DHCPV6_DUID_LENGTH = 130
181
182 MAX_DNS_SUFFIX_STRING_LENGTH = 256
183
184 TIME_ZONE_ID_UNKNOWN = 0
185 TIME_ZONE_ID_STANDARD = 1
186
187 TIME_ZONE_ID_DAYLIGHT = 2
188 IGNORE = 0
189 INFINITE = 0xffffffff
190
191 WAIT_ABANDONED = 0x00000080
192 WAIT_OBJECT_0 = 0x00000000
193 WAIT_FAILED = 0xFFFFFFFF
194
195 // Access rights for process.
196 PROCESS_ALL_ACCESS = 0xFFFF
197 PROCESS_CREATE_PROCESS = 0x0080
198 PROCESS_CREATE_THREAD = 0x0002
199 PROCESS_DUP_HANDLE = 0x0040
200 PROCESS_QUERY_INFORMATION = 0x0400
201 PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
202 PROCESS_SET_INFORMATION = 0x0200
203 PROCESS_SET_QUOTA = 0x0100
204 PROCESS_SUSPEND_RESUME = 0x0800
205 PROCESS_TERMINATE = 0x0001
206 PROCESS_VM_OPERATION = 0x0008
207 PROCESS_VM_READ = 0x0010
208 PROCESS_VM_WRITE = 0x0020
209
210 // Access rights for thread.
211 THREAD_DIRECT_IMPERSONATION = 0x0200
212 THREAD_GET_CONTEXT = 0x0008
213 THREAD_IMPERSONATE = 0x0100
214 THREAD_QUERY_INFORMATION = 0x0040
215 THREAD_QUERY_LIMITED_INFORMATION = 0x0800
216 THREAD_SET_CONTEXT = 0x0010
217 THREAD_SET_INFORMATION = 0x0020
218 THREAD_SET_LIMITED_INFORMATION = 0x0400
219 THREAD_SET_THREAD_TOKEN = 0x0080
220 THREAD_SUSPEND_RESUME = 0x0002
221 THREAD_TERMINATE = 0x0001
222
223 FILE_MAP_COPY = 0x01
224 FILE_MAP_WRITE = 0x02
225 FILE_MAP_READ = 0x04
226 FILE_MAP_EXECUTE = 0x20
227
228 CTRL_C_EVENT = 0
229 CTRL_BREAK_EVENT = 1
230 CTRL_CLOSE_EVENT = 2
231 CTRL_LOGOFF_EVENT = 5
232 CTRL_SHUTDOWN_EVENT = 6
233
234 // Windows reserves errors >= 1<<29 for application use.
235 APPLICATION_ERROR = 1 << 29
236 )
237
238 const (
239 // Process creation flags.
240 CREATE_BREAKAWAY_FROM_JOB = 0x01000000
241 CREATE_DEFAULT_ERROR_MODE = 0x04000000
242 CREATE_NEW_CONSOLE = 0x00000010
243 CREATE_NEW_PROCESS_GROUP = 0x00000200
244 CREATE_NO_WINDOW = 0x08000000
245 CREATE_PROTECTED_PROCESS = 0x00040000
246 CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
247 CREATE_SEPARATE_WOW_VDM = 0x00000800
248 CREATE_SHARED_WOW_VDM = 0x00001000
249 CREATE_SUSPENDED = 0x00000004
250 CREATE_UNICODE_ENVIRONMENT = 0x00000400
251 DEBUG_ONLY_THIS_PROCESS = 0x00000002
252 DEBUG_PROCESS = 0x00000001
253 DETACHED_PROCESS = 0x00000008
254 EXTENDED_STARTUPINFO_PRESENT = 0x00080000
255 INHERIT_PARENT_AFFINITY = 0x00010000
256 )
257
258 const (
259 // attributes for ProcThreadAttributeList
260 PROC_THREAD_ATTRIBUTE_PARENT_PROCESS = 0x00020000
261 PROC_THREAD_ATTRIBUTE_HANDLE_LIST = 0x00020002
262 PROC_THREAD_ATTRIBUTE_GROUP_AFFINITY = 0x00030003
263 PROC_THREAD_ATTRIBUTE_PREFERRED_NODE = 0x00020004
264 PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR = 0x00030005
265 PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY = 0x00020007
266 PROC_THREAD_ATTRIBUTE_UMS_THREAD = 0x00030006
267 PROC_THREAD_ATTRIBUTE_PROTECTION_LEVEL = 0x0002000b
268 PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE = 0x00020016
269 )
270
271 const (
272 // flags for CreateToolhelp32Snapshot
273 TH32CS_SNAPHEAPLIST = 0x01
274 TH32CS_SNAPPROCESS = 0x02
275 TH32CS_SNAPTHREAD = 0x04
276 TH32CS_SNAPMODULE = 0x08
277 TH32CS_SNAPMODULE32 = 0x10
278 TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD
279 TH32CS_INHERIT = 0x80000000
280 )
281
282 const (
283 // flags for EnumProcessModulesEx
284 LIST_MODULES_32BIT = 0x01
285 LIST_MODULES_64BIT = 0x02
286 LIST_MODULES_ALL = 0x03
287 LIST_MODULES_DEFAULT = 0x00
288 )
289
290 const (
291 // filters for ReadDirectoryChangesW and FindFirstChangeNotificationW
292 FILE_NOTIFY_CHANGE_FILE_NAME = 0x001
293 FILE_NOTIFY_CHANGE_DIR_NAME = 0x002
294 FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x004
295 FILE_NOTIFY_CHANGE_SIZE = 0x008
296 FILE_NOTIFY_CHANGE_LAST_WRITE = 0x010
297 FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x020
298 FILE_NOTIFY_CHANGE_CREATION = 0x040
299 FILE_NOTIFY_CHANGE_SECURITY = 0x100
300 )
301
302 const (
303 // do not reorder
304 FILE_ACTION_ADDED = iota + 1
305 FILE_ACTION_REMOVED
306 FILE_ACTION_MODIFIED
307 FILE_ACTION_RENAMED_OLD_NAME
308 FILE_ACTION_RENAMED_NEW_NAME
309 )
310
311 const (
312 // wincrypt.h
313 /* certenrolld_begin -- PROV_RSA_*/
314 PROV_RSA_FULL = 1
315 PROV_RSA_SIG = 2
316 PROV_DSS = 3
317 PROV_FORTEZZA = 4
318 PROV_MS_EXCHANGE = 5
319 PROV_SSL = 6
320 PROV_RSA_SCHANNEL = 12
321 PROV_DSS_DH = 13
322 PROV_EC_ECDSA_SIG = 14
323 PROV_EC_ECNRA_SIG = 15
324 PROV_EC_ECDSA_FULL = 16
325 PROV_EC_ECNRA_FULL = 17
326 PROV_DH_SCHANNEL = 18
327 PROV_SPYRUS_LYNKS = 20
328 PROV_RNG = 21
329 PROV_INTEL_SEC = 22
330 PROV_REPLACE_OWF = 23
331 PROV_RSA_AES = 24
332
333 /* dwFlags definitions for CryptAcquireContext */
334 CRYPT_VERIFYCONTEXT = 0xF0000000
335 CRYPT_NEWKEYSET = 0x00000008
336 CRYPT_DELETEKEYSET = 0x00000010
337 CRYPT_MACHINE_KEYSET = 0x00000020
338 CRYPT_SILENT = 0x00000040
339 CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080
340
341 /* Flags for PFXImportCertStore */
342 CRYPT_EXPORTABLE = 0x00000001
343 CRYPT_USER_PROTECTED = 0x00000002
344 CRYPT_USER_KEYSET = 0x00001000
345 PKCS12_PREFER_CNG_KSP = 0x00000100
346 PKCS12_ALWAYS_CNG_KSP = 0x00000200
347 PKCS12_ALLOW_OVERWRITE_KEY = 0x00004000
348 PKCS12_NO_PERSIST_KEY = 0x00008000
349 PKCS12_INCLUDE_EXTENDED_PROPERTIES = 0x00000010
350
351 /* Flags for CryptAcquireCertificatePrivateKey */
352 CRYPT_ACQUIRE_CACHE_FLAG = 0x00000001
353 CRYPT_ACQUIRE_USE_PROV_INFO_FLAG = 0x00000002
354 CRYPT_ACQUIRE_COMPARE_KEY_FLAG = 0x00000004
355 CRYPT_ACQUIRE_NO_HEALING = 0x00000008
356 CRYPT_ACQUIRE_SILENT_FLAG = 0x00000040
357 CRYPT_ACQUIRE_WINDOW_HANDLE_FLAG = 0x00000080
358 CRYPT_ACQUIRE_NCRYPT_KEY_FLAGS_MASK = 0x00070000
359 CRYPT_ACQUIRE_ALLOW_NCRYPT_KEY_FLAG = 0x00010000
360 CRYPT_ACQUIRE_PREFER_NCRYPT_KEY_FLAG = 0x00020000
361 CRYPT_ACQUIRE_ONLY_NCRYPT_KEY_FLAG = 0x00040000
362
363 /* pdwKeySpec for CryptAcquireCertificatePrivateKey */
364 AT_KEYEXCHANGE = 1
365 AT_SIGNATURE = 2
366 CERT_NCRYPT_KEY_SPEC = 0xFFFFFFFF
367
368 /* Default usage match type is AND with value zero */
369 USAGE_MATCH_TYPE_AND = 0
370 USAGE_MATCH_TYPE_OR = 1
371
372 /* msgAndCertEncodingType values for CertOpenStore function */
373 X509_ASN_ENCODING = 0x00000001
374 PKCS_7_ASN_ENCODING = 0x00010000
375
376 /* storeProvider values for CertOpenStore function */
377 CERT_STORE_PROV_MSG = 1
378 CERT_STORE_PROV_MEMORY = 2
379 CERT_STORE_PROV_FILE = 3
380 CERT_STORE_PROV_REG = 4
381 CERT_STORE_PROV_PKCS7 = 5
382 CERT_STORE_PROV_SERIALIZED = 6
383 CERT_STORE_PROV_FILENAME_A = 7
384 CERT_STORE_PROV_FILENAME_W = 8
385 CERT_STORE_PROV_FILENAME = CERT_STORE_PROV_FILENAME_W
386 CERT_STORE_PROV_SYSTEM_A = 9
387 CERT_STORE_PROV_SYSTEM_W = 10
388 CERT_STORE_PROV_SYSTEM = CERT_STORE_PROV_SYSTEM_W
389 CERT_STORE_PROV_COLLECTION = 11
390 CERT_STORE_PROV_SYSTEM_REGISTRY_A = 12
391 CERT_STORE_PROV_SYSTEM_REGISTRY_W = 13
392 CERT_STORE_PROV_SYSTEM_REGISTRY = CERT_STORE_PROV_SYSTEM_REGISTRY_W
393 CERT_STORE_PROV_PHYSICAL_W = 14
394 CERT_STORE_PROV_PHYSICAL = CERT_STORE_PROV_PHYSICAL_W
395 CERT_STORE_PROV_SMART_CARD_W = 15
396 CERT_STORE_PROV_SMART_CARD = CERT_STORE_PROV_SMART_CARD_W
397 CERT_STORE_PROV_LDAP_W = 16
398 CERT_STORE_PROV_LDAP = CERT_STORE_PROV_LDAP_W
399 CERT_STORE_PROV_PKCS12 = 17
400
401 /* store characteristics (low WORD of flag) for CertOpenStore function */
402 CERT_STORE_NO_CRYPT_RELEASE_FLAG = 0x00000001
403 CERT_STORE_SET_LOCALIZED_NAME_FLAG = 0x00000002
404 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004
405 CERT_STORE_DELETE_FLAG = 0x00000010
406 CERT_STORE_UNSAFE_PHYSICAL_FLAG = 0x00000020
407 CERT_STORE_SHARE_STORE_FLAG = 0x00000040
408 CERT_STORE_SHARE_CONTEXT_FLAG = 0x00000080
409 CERT_STORE_MANIFOLD_FLAG = 0x00000100
410 CERT_STORE_ENUM_ARCHIVED_FLAG = 0x00000200
411 CERT_STORE_UPDATE_KEYID_FLAG = 0x00000400
412 CERT_STORE_BACKUP_RESTORE_FLAG = 0x00000800
413 CERT_STORE_MAXIMUM_ALLOWED_FLAG = 0x00001000
414 CERT_STORE_CREATE_NEW_FLAG = 0x00002000
415 CERT_STORE_OPEN_EXISTING_FLAG = 0x00004000
416 CERT_STORE_READONLY_FLAG = 0x00008000
417
418 /* store locations (high WORD of flag) for CertOpenStore function */
419 CERT_SYSTEM_STORE_CURRENT_USER = 0x00010000
420 CERT_SYSTEM_STORE_LOCAL_MACHINE = 0x00020000
421 CERT_SYSTEM_STORE_CURRENT_SERVICE = 0x00040000
422 CERT_SYSTEM_STORE_SERVICES = 0x00050000
423 CERT_SYSTEM_STORE_USERS = 0x00060000
424 CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY = 0x00070000
425 CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = 0x00080000
426 CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE = 0x00090000
427 CERT_SYSTEM_STORE_UNPROTECTED_FLAG = 0x40000000
428 CERT_SYSTEM_STORE_RELOCATE_FLAG = 0x80000000
429
430 /* Miscellaneous high-WORD flags for CertOpenStore function */
431 CERT_REGISTRY_STORE_REMOTE_FLAG = 0x00010000
432 CERT_REGISTRY_STORE_SERIALIZED_FLAG = 0x00020000
433 CERT_REGISTRY_STORE_ROAMING_FLAG = 0x00040000
434 CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG = 0x00080000
435 CERT_REGISTRY_STORE_LM_GPT_FLAG = 0x01000000
436 CERT_REGISTRY_STORE_CLIENT_GPT_FLAG = 0x80000000
437 CERT_FILE_STORE_COMMIT_ENABLE_FLAG = 0x00010000
438 CERT_LDAP_STORE_SIGN_FLAG = 0x00010000
439 CERT_LDAP_STORE_AREC_EXCLUSIVE_FLAG = 0x00020000
440 CERT_LDAP_STORE_OPENED_FLAG = 0x00040000
441 CERT_LDAP_STORE_UNBIND_FLAG = 0x00080000
442
443 /* addDisposition values for CertAddCertificateContextToStore function */
444 CERT_STORE_ADD_NEW = 1
445 CERT_STORE_ADD_USE_EXISTING = 2
446 CERT_STORE_ADD_REPLACE_EXISTING = 3
447 CERT_STORE_ADD_ALWAYS = 4
448 CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5
449 CERT_STORE_ADD_NEWER = 6
450 CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES = 7
451
452 /* ErrorStatus values for CertTrustStatus struct */
453 CERT_TRUST_NO_ERROR = 0x00000000
454 CERT_TRUST_IS_NOT_TIME_VALID = 0x00000001
455 CERT_TRUST_IS_REVOKED = 0x00000004
456 CERT_TRUST_IS_NOT_SIGNATURE_VALID = 0x00000008
457 CERT_TRUST_IS_NOT_VALID_FOR_USAGE = 0x00000010
458 CERT_TRUST_IS_UNTRUSTED_ROOT = 0x00000020
459 CERT_TRUST_REVOCATION_STATUS_UNKNOWN = 0x00000040
460 CERT_TRUST_IS_CYCLIC = 0x00000080
461 CERT_TRUST_INVALID_EXTENSION = 0x00000100
462 CERT_TRUST_INVALID_POLICY_CONSTRAINTS = 0x00000200
463 CERT_TRUST_INVALID_BASIC_CONSTRAINTS = 0x00000400
464 CERT_TRUST_INVALID_NAME_CONSTRAINTS = 0x00000800
465 CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000
466 CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT = 0x00002000
467 CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000
468 CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT = 0x00008000
469 CERT_TRUST_IS_PARTIAL_CHAIN = 0x00010000
470 CERT_TRUST_CTL_IS_NOT_TIME_VALID = 0x00020000
471 CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID = 0x00040000
472 CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE = 0x00080000
473 CERT_TRUST_HAS_WEAK_SIGNATURE = 0x00100000
474 CERT_TRUST_IS_OFFLINE_REVOCATION = 0x01000000
475 CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY = 0x02000000
476 CERT_TRUST_IS_EXPLICIT_DISTRUST = 0x04000000
477 CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT = 0x08000000
478
479 /* InfoStatus values for CertTrustStatus struct */
480 CERT_TRUST_HAS_EXACT_MATCH_ISSUER = 0x00000001
481 CERT_TRUST_HAS_KEY_MATCH_ISSUER = 0x00000002
482 CERT_TRUST_HAS_NAME_MATCH_ISSUER = 0x00000004
483 CERT_TRUST_IS_SELF_SIGNED = 0x00000008
484 CERT_TRUST_HAS_PREFERRED_ISSUER = 0x00000100
485 CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY = 0x00000400
486 CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS = 0x00000400
487 CERT_TRUST_IS_PEER_TRUSTED = 0x00000800
488 CERT_TRUST_HAS_CRL_VALIDITY_EXTENDED = 0x00001000
489 CERT_TRUST_IS_FROM_EXCLUSIVE_TRUST_STORE = 0x00002000
490 CERT_TRUST_IS_CA_TRUSTED = 0x00004000
491 CERT_TRUST_IS_COMPLEX_CHAIN = 0x00010000
492
493 /* Certificate Information Flags */
494 CERT_INFO_VERSION_FLAG = 1
495 CERT_INFO_SERIAL_NUMBER_FLAG = 2
496 CERT_INFO_SIGNATURE_ALGORITHM_FLAG = 3
497 CERT_INFO_ISSUER_FLAG = 4
498 CERT_INFO_NOT_BEFORE_FLAG = 5
499 CERT_INFO_NOT_AFTER_FLAG = 6
500 CERT_INFO_SUBJECT_FLAG = 7
501 CERT_INFO_SUBJECT_PUBLIC_KEY_INFO_FLAG = 8
502 CERT_INFO_ISSUER_UNIQUE_ID_FLAG = 9
503 CERT_INFO_SUBJECT_UNIQUE_ID_FLAG = 10
504 CERT_INFO_EXTENSION_FLAG = 11
505
506 /* dwFindType for CertFindCertificateInStore */
507 CERT_COMPARE_MASK = 0xFFFF
508 CERT_COMPARE_SHIFT = 16
509 CERT_COMPARE_ANY = 0
510 CERT_COMPARE_SHA1_HASH = 1
511 CERT_COMPARE_NAME = 2
512 CERT_COMPARE_ATTR = 3
513 CERT_COMPARE_MD5_HASH = 4
514 CERT_COMPARE_PROPERTY = 5
515 CERT_COMPARE_PUBLIC_KEY = 6
516 CERT_COMPARE_HASH = CERT_COMPARE_SHA1_HASH
517 CERT_COMPARE_NAME_STR_A = 7
518 CERT_COMPARE_NAME_STR_W = 8
519 CERT_COMPARE_KEY_SPEC = 9
520 CERT_COMPARE_ENHKEY_USAGE = 10
521 CERT_COMPARE_CTL_USAGE = CERT_COMPARE_ENHKEY_USAGE
522 CERT_COMPARE_SUBJECT_CERT = 11
523 CERT_COMPARE_ISSUER_OF = 12
524 CERT_COMPARE_EXISTING = 13
525 CERT_COMPARE_SIGNATURE_HASH = 14
526 CERT_COMPARE_KEY_IDENTIFIER = 15
527 CERT_COMPARE_CERT_ID = 16
528 CERT_COMPARE_CROSS_CERT_DIST_POINTS = 17
529 CERT_COMPARE_PUBKEY_MD5_HASH = 18
530 CERT_COMPARE_SUBJECT_INFO_ACCESS = 19
531 CERT_COMPARE_HASH_STR = 20
532 CERT_COMPARE_HAS_PRIVATE_KEY = 21
533 CERT_FIND_ANY = (CERT_COMPARE_ANY << CERT_COMPARE_SHIFT)
534 CERT_FIND_SHA1_HASH = (CERT_COMPARE_SHA1_HASH << CERT_COMPARE_SHIFT)
535 CERT_FIND_MD5_HASH = (CERT_COMPARE_MD5_HASH << CERT_COMPARE_SHIFT)
536 CERT_FIND_SIGNATURE_HASH = (CERT_COMPARE_SIGNATURE_HASH << CERT_COMPARE_SHIFT)
537 CERT_FIND_KEY_IDENTIFIER = (CERT_COMPARE_KEY_IDENTIFIER << CERT_COMPARE_SHIFT)
538 CERT_FIND_HASH = CERT_FIND_SHA1_HASH
539 CERT_FIND_PROPERTY = (CERT_COMPARE_PROPERTY << CERT_COMPARE_SHIFT)
540 CERT_FIND_PUBLIC_KEY = (CERT_COMPARE_PUBLIC_KEY << CERT_COMPARE_SHIFT)
541 CERT_FIND_SUBJECT_NAME = (CERT_COMPARE_NAME<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
542 CERT_FIND_SUBJECT_ATTR = (CERT_COMPARE_ATTR<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
543 CERT_FIND_ISSUER_NAME = (CERT_COMPARE_NAME<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
544 CERT_FIND_ISSUER_ATTR = (CERT_COMPARE_ATTR<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
545 CERT_FIND_SUBJECT_STR_A = (CERT_COMPARE_NAME_STR_A<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
546 CERT_FIND_SUBJECT_STR_W = (CERT_COMPARE_NAME_STR_W<<CERT_COMPARE_SHIFT | CERT_INFO_SUBJECT_FLAG)
547 CERT_FIND_SUBJECT_STR = CERT_FIND_SUBJECT_STR_W
548 CERT_FIND_ISSUER_STR_A = (CERT_COMPARE_NAME_STR_A<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
549 CERT_FIND_ISSUER_STR_W = (CERT_COMPARE_NAME_STR_W<<CERT_COMPARE_SHIFT | CERT_INFO_ISSUER_FLAG)
550 CERT_FIND_ISSUER_STR = CERT_FIND_ISSUER_STR_W
551 CERT_FIND_KEY_SPEC = (CERT_COMPARE_KEY_SPEC << CERT_COMPARE_SHIFT)
552 CERT_FIND_ENHKEY_USAGE = (CERT_COMPARE_ENHKEY_USAGE << CERT_COMPARE_SHIFT)
553 CERT_FIND_CTL_USAGE = CERT_FIND_ENHKEY_USAGE
554 CERT_FIND_SUBJECT_CERT = (CERT_COMPARE_SUBJECT_CERT << CERT_COMPARE_SHIFT)
555 CERT_FIND_ISSUER_OF = (CERT_COMPARE_ISSUER_OF << CERT_COMPARE_SHIFT)
556 CERT_FIND_EXISTING = (CERT_COMPARE_EXISTING << CERT_COMPARE_SHIFT)
557 CERT_FIND_CERT_ID = (CERT_COMPARE_CERT_ID << CERT_COMPARE_SHIFT)
558 CERT_FIND_CROSS_CERT_DIST_POINTS = (CERT_COMPARE_CROSS_CERT_DIST_POINTS << CERT_COMPARE_SHIFT)
559 CERT_FIND_PUBKEY_MD5_HASH = (CERT_COMPARE_PUBKEY_MD5_HASH << CERT_COMPARE_SHIFT)
560 CERT_FIND_SUBJECT_INFO_ACCESS = (CERT_COMPARE_SUBJECT_INFO_ACCESS << CERT_COMPARE_SHIFT)
561 CERT_FIND_HASH_STR = (CERT_COMPARE_HASH_STR << CERT_COMPARE_SHIFT)
562 CERT_FIND_HAS_PRIVATE_KEY = (CERT_COMPARE_HAS_PRIVATE_KEY << CERT_COMPARE_SHIFT)
563 CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG = 0x1
564 CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG = 0x2
565 CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG = 0x4
566 CERT_FIND_NO_ENHKEY_USAGE_FLAG = 0x8
567 CERT_FIND_OR_ENHKEY_USAGE_FLAG = 0x10
568 CERT_FIND_VALID_ENHKEY_USAGE_FLAG = 0x20
569 CERT_FIND_OPTIONAL_CTL_USAGE_FLAG = CERT_FIND_OPTIONAL_ENHKEY_USAGE_FLAG
570 CERT_FIND_EXT_ONLY_CTL_USAGE_FLAG = CERT_FIND_EXT_ONLY_ENHKEY_USAGE_FLAG
571 CERT_FIND_PROP_ONLY_CTL_USAGE_FLAG = CERT_FIND_PROP_ONLY_ENHKEY_USAGE_FLAG
572 CERT_FIND_NO_CTL_USAGE_FLAG = CERT_FIND_NO_ENHKEY_USAGE_FLAG
573 CERT_FIND_OR_CTL_USAGE_FLAG = CERT_FIND_OR_ENHKEY_USAGE_FLAG
574 CERT_FIND_VALID_CTL_USAGE_FLAG = CERT_FIND_VALID_ENHKEY_USAGE_FLAG
575
576 /* policyOID values for CertVerifyCertificateChainPolicy function */
577 CERT_CHAIN_POLICY_BASE = 1
578 CERT_CHAIN_POLICY_AUTHENTICODE = 2
579 CERT_CHAIN_POLICY_AUTHENTICODE_TS = 3
580 CERT_CHAIN_POLICY_SSL = 4
581 CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5
582 CERT_CHAIN_POLICY_NT_AUTH = 6
583 CERT_CHAIN_POLICY_MICROSOFT_ROOT = 7
584 CERT_CHAIN_POLICY_EV = 8
585 CERT_CHAIN_POLICY_SSL_F12 = 9
586
587 /* flag for dwFindType CertFindChainInStore */
588 CERT_CHAIN_FIND_BY_ISSUER = 1
589
590 /* dwFindFlags for CertFindChainInStore when dwFindType == CERT_CHAIN_FIND_BY_ISSUER */
591 CERT_CHAIN_FIND_BY_ISSUER_COMPARE_KEY_FLAG = 0x0001
592 CERT_CHAIN_FIND_BY_ISSUER_COMPLEX_CHAIN_FLAG = 0x0002
593 CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_URL_FLAG = 0x0004
594 CERT_CHAIN_FIND_BY_ISSUER_LOCAL_MACHINE_FLAG = 0x0008
595 CERT_CHAIN_FIND_BY_ISSUER_NO_KEY_FLAG = 0x4000
596 CERT_CHAIN_FIND_BY_ISSUER_CACHE_ONLY_FLAG = 0x8000
597
598 /* Certificate Store close flags */
599 CERT_CLOSE_STORE_FORCE_FLAG = 0x00000001
600 CERT_CLOSE_STORE_CHECK_FLAG = 0x00000002
601
602 /* CryptQueryObject object type */
603 CERT_QUERY_OBJECT_FILE = 1
604 CERT_QUERY_OBJECT_BLOB = 2
605
606 /* CryptQueryObject content type flags */
607 CERT_QUERY_CONTENT_CERT = 1
608 CERT_QUERY_CONTENT_CTL = 2
609 CERT_QUERY_CONTENT_CRL = 3
610 CERT_QUERY_CONTENT_SERIALIZED_STORE = 4
611 CERT_QUERY_CONTENT_SERIALIZED_CERT = 5
612 CERT_QUERY_CONTENT_SERIALIZED_CTL = 6
613 CERT_QUERY_CONTENT_SERIALIZED_CRL = 7
614 CERT_QUERY_CONTENT_PKCS7_SIGNED = 8
615 CERT_QUERY_CONTENT_PKCS7_UNSIGNED = 9
616 CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED = 10
617 CERT_QUERY_CONTENT_PKCS10 = 11
618 CERT_QUERY_CONTENT_PFX = 12
619 CERT_QUERY_CONTENT_CERT_PAIR = 13
620 CERT_QUERY_CONTENT_PFX_AND_LOAD = 14
621 CERT_QUERY_CONTENT_FLAG_CERT = (1 << CERT_QUERY_CONTENT_CERT)
622 CERT_QUERY_CONTENT_FLAG_CTL = (1 << CERT_QUERY_CONTENT_CTL)
623 CERT_QUERY_CONTENT_FLAG_CRL = (1 << CERT_QUERY_CONTENT_CRL)
624 CERT_QUERY_CONTENT_FLAG_SERIALIZED_STORE = (1 << CERT_QUERY_CONTENT_SERIALIZED_STORE)
625 CERT_QUERY_CONTENT_FLAG_SERIALIZED_CERT = (1 << CERT_QUERY_CONTENT_SERIALIZED_CERT)
626 CERT_QUERY_CONTENT_FLAG_SERIALIZED_CTL = (1 << CERT_QUERY_CONTENT_SERIALIZED_CTL)
627 CERT_QUERY_CONTENT_FLAG_SERIALIZED_CRL = (1 << CERT_QUERY_CONTENT_SERIALIZED_CRL)
628 CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED)
629 CERT_QUERY_CONTENT_FLAG_PKCS7_UNSIGNED = (1 << CERT_QUERY_CONTENT_PKCS7_UNSIGNED)
630 CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED = (1 << CERT_QUERY_CONTENT_PKCS7_SIGNED_EMBED)
631 CERT_QUERY_CONTENT_FLAG_PKCS10 = (1 << CERT_QUERY_CONTENT_PKCS10)
632 CERT_QUERY_CONTENT_FLAG_PFX = (1 << CERT_QUERY_CONTENT_PFX)
633 CERT_QUERY_CONTENT_FLAG_CERT_PAIR = (1 << CERT_QUERY_CONTENT_CERT_PAIR)
634 CERT_QUERY_CONTENT_FLAG_PFX_AND_LOAD = (1 << CERT_QUERY_CONTENT_PFX_AND_LOAD)
635 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)
636 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)
637
638 /* CryptQueryObject format type flags */
639 CERT_QUERY_FORMAT_BINARY = 1
640 CERT_QUERY_FORMAT_BASE64_ENCODED = 2
641 CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED = 3
642 CERT_QUERY_FORMAT_FLAG_BINARY = (1 << CERT_QUERY_FORMAT_BINARY)
643 CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED = (1 << CERT_QUERY_FORMAT_BASE64_ENCODED)
644 CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED = (1 << CERT_QUERY_FORMAT_ASN_ASCII_HEX_ENCODED)
645 CERT_QUERY_FORMAT_FLAG_ALL = (CERT_QUERY_FORMAT_FLAG_BINARY | CERT_QUERY_FORMAT_FLAG_BASE64_ENCODED | CERT_QUERY_FORMAT_FLAG_ASN_ASCII_HEX_ENCODED)
646
647 /* CertGetNameString name types */
648 CERT_NAME_EMAIL_TYPE = 1
649 CERT_NAME_RDN_TYPE = 2
650 CERT_NAME_ATTR_TYPE = 3
651 CERT_NAME_SIMPLE_DISPLAY_TYPE = 4
652 CERT_NAME_FRIENDLY_DISPLAY_TYPE = 5
653 CERT_NAME_DNS_TYPE = 6
654 CERT_NAME_URL_TYPE = 7
655 CERT_NAME_UPN_TYPE = 8
656
657 /* CertGetNameString flags */
658 CERT_NAME_ISSUER_FLAG = 0x1
659 CERT_NAME_DISABLE_IE4_UTF8_FLAG = 0x10000
660 CERT_NAME_SEARCH_ALL_NAMES_FLAG = 0x2
661 CERT_NAME_STR_ENABLE_PUNYCODE_FLAG = 0x00200000
662
663 /* AuthType values for SSLExtraCertChainPolicyPara struct */
664 AUTHTYPE_CLIENT = 1
665 AUTHTYPE_SERVER = 2
666
667 /* Checks values for SSLExtraCertChainPolicyPara struct */
668 SECURITY_FLAG_IGNORE_REVOCATION = 0x00000080
669 SECURITY_FLAG_IGNORE_UNKNOWN_CA = 0x00000100
670 SECURITY_FLAG_IGNORE_WRONG_USAGE = 0x00000200
671 SECURITY_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000
672 SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000
673
674 /* Flags for Crypt[Un]ProtectData */
675 CRYPTPROTECT_UI_FORBIDDEN = 0x1
676 CRYPTPROTECT_LOCAL_MACHINE = 0x4
677 CRYPTPROTECT_CRED_SYNC = 0x8
678 CRYPTPROTECT_AUDIT = 0x10
679 CRYPTPROTECT_NO_RECOVERY = 0x20
680 CRYPTPROTECT_VERIFY_PROTECTION = 0x40
681 CRYPTPROTECT_CRED_REGENERATE = 0x80
682
683 /* Flags for CryptProtectPromptStruct */
684 CRYPTPROTECT_PROMPT_ON_UNPROTECT = 1
685 CRYPTPROTECT_PROMPT_ON_PROTECT = 2
686 CRYPTPROTECT_PROMPT_RESERVED = 4
687 CRYPTPROTECT_PROMPT_STRONG = 8
688 CRYPTPROTECT_PROMPT_REQUIRE_STRONG = 16
689 )
690
691 const (
692 // flags for SetErrorMode
693 SEM_FAILCRITICALERRORS = 0x0001
694 SEM_NOALIGNMENTFAULTEXCEPT = 0x0004
695 SEM_NOGPFAULTERRORBOX = 0x0002
696 SEM_NOOPENFILEERRORBOX = 0x8000
697 )
698
699 const (
700 // Priority class.
701 ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
702 BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
703 HIGH_PRIORITY_CLASS = 0x00000080
704 IDLE_PRIORITY_CLASS = 0x00000040
705 NORMAL_PRIORITY_CLASS = 0x00000020
706 PROCESS_MODE_BACKGROUND_BEGIN = 0x00100000
707 PROCESS_MODE_BACKGROUND_END = 0x00200000
708 REALTIME_PRIORITY_CLASS = 0x00000100
709 )
710
711 /* wintrust.h constants for WinVerifyTrustEx */
712 const (
713 WTD_UI_ALL = 1
714 WTD_UI_NONE = 2
715 WTD_UI_NOBAD = 3
716 WTD_UI_NOGOOD = 4
717
718 WTD_REVOKE_NONE = 0
719 WTD_REVOKE_WHOLECHAIN = 1
720
721 WTD_CHOICE_FILE = 1
722 WTD_CHOICE_CATALOG = 2
723 WTD_CHOICE_BLOB = 3
724 WTD_CHOICE_SIGNER = 4
725 WTD_CHOICE_CERT = 5
726
727 WTD_STATEACTION_IGNORE = 0x00000000
728 WTD_STATEACTION_VERIFY = 0x00000001
729 WTD_STATEACTION_CLOSE = 0x00000002
730 WTD_STATEACTION_AUTO_CACHE = 0x00000003
731 WTD_STATEACTION_AUTO_CACHE_FLUSH = 0x00000004
732
733 WTD_USE_IE4_TRUST_FLAG = 0x1
734 WTD_NO_IE4_CHAIN_FLAG = 0x2
735 WTD_NO_POLICY_USAGE_FLAG = 0x4
736 WTD_REVOCATION_CHECK_NONE = 0x10
737 WTD_REVOCATION_CHECK_END_CERT = 0x20
738 WTD_REVOCATION_CHECK_CHAIN = 0x40
739 WTD_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT = 0x80
740 WTD_SAFER_FLAG = 0x100
741 WTD_HASH_ONLY_FLAG = 0x200
742 WTD_USE_DEFAULT_OSVER_CHECK = 0x400
743 WTD_LIFETIME_SIGNING_FLAG = 0x800
744 WTD_CACHE_ONLY_URL_RETRIEVAL = 0x1000
745 WTD_DISABLE_MD2_MD4 = 0x2000
746 WTD_MOTW = 0x4000
747
748 WTD_UICONTEXT_EXECUTE = 0
749 WTD_UICONTEXT_INSTALL = 1
750 )
751
752 var (
753 OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00")
754 OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00")
755 OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00")
756
757 WINTRUST_ACTION_GENERIC_VERIFY_V2 = GUID{
758 Data1: 0xaac56b,
759 Data2: 0xcd44,
760 Data3: 0x11d0,
761 Data4: [8]byte{0x8c, 0xc2, 0x0, 0xc0, 0x4f, 0xc2, 0x95, 0xee},
762 }
763 )
764
765 // Pointer represents a pointer to an arbitrary Windows type.
766 //
767 // Pointer-typed fields may point to one of many different types. It's
768 // up to the caller to provide a pointer to the appropriate type, cast
769 // to Pointer. The caller must obey the unsafe.Pointer rules while
770 // doing so.
771 type Pointer *struct{}
772
773 // Invented values to support what package os expects.
774 type Timeval struct {
775 Sec int32
776 Usec int32
777 }
778
779 func (tv *Timeval) Nanoseconds() int64 {
780 return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3
781 }
782
783 func NsecToTimeval(nsec int64) (tv Timeval) {
784 tv.Sec = int32(nsec / 1e9)
785 tv.Usec = int32(nsec % 1e9 / 1e3)
786 return
787 }
788
789 type Overlapped struct {
790 Internal uintptr
791 InternalHigh uintptr
792 Offset uint32
793 OffsetHigh uint32
794 HEvent Handle
795 }
796
797 type FileNotifyInformation struct {
798 NextEntryOffset uint32
799 Action uint32
800 FileNameLength uint32
801 FileName uint16
802 }
803
804 type Filetime struct {
805 LowDateTime uint32
806 HighDateTime uint32
807 }
808
809 // Nanoseconds returns Filetime ft in nanoseconds
810 // since Epoch (00:00:00 UTC, January 1, 1970).
811 func (ft *Filetime) Nanoseconds() int64 {
812 // 100-nanosecond intervals since January 1, 1601
813 nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime)
814 // change starting time to the Epoch (00:00:00 UTC, January 1, 1970)
815 nsec -= 116444736000000000
816 // convert into nanoseconds
817 nsec *= 100
818 return nsec
819 }
820
821 func NsecToFiletime(nsec int64) (ft Filetime) {
822 // convert into 100-nanosecond
823 nsec /= 100
824 // change starting time to January 1, 1601
825 nsec += 116444736000000000
826 // split into high / low
827 ft.LowDateTime = uint32(nsec & 0xffffffff)
828 ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff)
829 return ft
830 }
831
832 type Win32finddata struct {
833 FileAttributes uint32
834 CreationTime Filetime
835 LastAccessTime Filetime
836 LastWriteTime Filetime
837 FileSizeHigh uint32
838 FileSizeLow uint32
839 Reserved0 uint32
840 Reserved1 uint32
841 FileName [MAX_PATH - 1]uint16
842 AlternateFileName [13]uint16
843 }
844
845 // This is the actual system call structure.
846 // Win32finddata is what we committed to in Go 1.
847 type win32finddata1 struct {
848 FileAttributes uint32
849 CreationTime Filetime
850 LastAccessTime Filetime
851 LastWriteTime Filetime
852 FileSizeHigh uint32
853 FileSizeLow uint32
854 Reserved0 uint32
855 Reserved1 uint32
856 FileName [MAX_PATH]uint16
857 AlternateFileName [14]uint16
858
859 // The Microsoft documentation for this struct¹ describes three additional
860 // fields: dwFileType, dwCreatorType, and wFinderFlags. However, those fields
861 // are empirically only present in the macOS port of the Win32 API,² and thus
862 // not needed for binaries built for Windows.
863 //
864 // ¹ https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-win32_find_dataw describe
865 // ² https://golang.org/issue/42637#issuecomment-760715755.
866 }
867
868 func copyFindData(dst *Win32finddata, src *win32finddata1) {
869 dst.FileAttributes = src.FileAttributes
870 dst.CreationTime = src.CreationTime
871 dst.LastAccessTime = src.LastAccessTime
872 dst.LastWriteTime = src.LastWriteTime
873 dst.FileSizeHigh = src.FileSizeHigh
874 dst.FileSizeLow = src.FileSizeLow
875 dst.Reserved0 = src.Reserved0
876 dst.Reserved1 = src.Reserved1
877
878 // The src is 1 element bigger than dst, but it must be NUL.
879 copy(dst.FileName[:], src.FileName[:])
880 copy(dst.AlternateFileName[:], src.AlternateFileName[:])
881 }
882
883 type ByHandleFileInformation struct {
884 FileAttributes uint32
885 CreationTime Filetime
886 LastAccessTime Filetime
887 LastWriteTime Filetime
888 VolumeSerialNumber uint32
889 FileSizeHigh uint32
890 FileSizeLow uint32
891 NumberOfLinks uint32
892 FileIndexHigh uint32
893 FileIndexLow uint32
894 }
895
896 const (
897 GetFileExInfoStandard = 0
898 GetFileExMaxInfoLevel = 1
899 )
900
901 type Win32FileAttributeData struct {
902 FileAttributes uint32
903 CreationTime Filetime
904 LastAccessTime Filetime
905 LastWriteTime Filetime
906 FileSizeHigh uint32
907 FileSizeLow uint32
908 }
909
910 // ShowWindow constants
911 const (
912 // winuser.h
913 SW_HIDE = 0
914 SW_NORMAL = 1
915 SW_SHOWNORMAL = 1
916 SW_SHOWMINIMIZED = 2
917 SW_SHOWMAXIMIZED = 3
918 SW_MAXIMIZE = 3
919 SW_SHOWNOACTIVATE = 4
920 SW_SHOW = 5
921 SW_MINIMIZE = 6
922 SW_SHOWMINNOACTIVE = 7
923 SW_SHOWNA = 8
924 SW_RESTORE = 9
925 SW_SHOWDEFAULT = 10
926 SW_FORCEMINIMIZE = 11
927 )
928
929 type StartupInfo struct {
930 Cb uint32
931 _ *uint16
932 Desktop *uint16
933 Title *uint16
934 X uint32
935 Y uint32
936 XSize uint32
937 YSize uint32
938 XCountChars uint32
939 YCountChars uint32
940 FillAttribute uint32
941 Flags uint32
942 ShowWindow uint16
943 _ uint16
944 _ *byte
945 StdInput Handle
946 StdOutput Handle
947 StdErr Handle
948 }
949
950 type StartupInfoEx struct {
951 StartupInfo
952 ProcThreadAttributeList *ProcThreadAttributeList
953 }
954
955 // ProcThreadAttributeList is a placeholder type to represent a PROC_THREAD_ATTRIBUTE_LIST.
956 //
957 // To create a *ProcThreadAttributeList, use NewProcThreadAttributeList, update
958 // it with ProcThreadAttributeListContainer.Update, free its memory using
959 // ProcThreadAttributeListContainer.Delete, and access the list itself using
960 // ProcThreadAttributeListContainer.List.
961 type ProcThreadAttributeList struct{}
962
963 type ProcThreadAttributeListContainer struct {
964 data *ProcThreadAttributeList
965 pointers []unsafe.Pointer
966 }
967
968 type ProcessInformation struct {
969 Process Handle
970 Thread Handle
971 ProcessId uint32
972 ThreadId uint32
973 }
974
975 type ProcessEntry32 struct {
976 Size uint32
977 Usage uint32
978 ProcessID uint32
979 DefaultHeapID uintptr
980 ModuleID uint32
981 Threads uint32
982 ParentProcessID uint32
983 PriClassBase int32
984 Flags uint32
985 ExeFile [MAX_PATH]uint16
986 }
987
988 type ThreadEntry32 struct {
989 Size uint32
990 Usage uint32
991 ThreadID uint32
992 OwnerProcessID uint32
993 BasePri int32
994 DeltaPri int32
995 Flags uint32
996 }
997
998 type ModuleEntry32 struct {
999 Size uint32
1000 ModuleID uint32
1001 ProcessID uint32
1002 GlblcntUsage uint32
1003 ProccntUsage uint32
1004 ModBaseAddr uintptr
1005 ModBaseSize uint32
1006 ModuleHandle Handle
1007 Module [MAX_MODULE_NAME32 + 1]uint16
1008 ExePath [MAX_PATH]uint16
1009 }
1010
1011 const SizeofModuleEntry32 = unsafe.Sizeof(ModuleEntry32{})
1012
1013 type Systemtime struct {
1014 Year uint16
1015 Month uint16
1016 DayOfWeek uint16
1017 Day uint16
1018 Hour uint16
1019 Minute uint16
1020 Second uint16
1021 Milliseconds uint16
1022 }
1023
1024 type Timezoneinformation struct {
1025 Bias int32
1026 StandardName [32]uint16
1027 StandardDate Systemtime
1028 StandardBias int32
1029 DaylightName [32]uint16
1030 DaylightDate Systemtime
1031 DaylightBias int32
1032 }
1033
1034 // Socket related.
1035
1036 const (
1037 AF_UNSPEC = 0
1038 AF_UNIX = 1
1039 AF_INET = 2
1040 AF_NETBIOS = 17
1041 AF_INET6 = 23
1042 AF_IRDA = 26
1043 AF_BTH = 32
1044
1045 SOCK_STREAM = 1
1046 SOCK_DGRAM = 2
1047 SOCK_RAW = 3
1048 SOCK_RDM = 4
1049 SOCK_SEQPACKET = 5
1050
1051 IPPROTO_IP = 0
1052 IPPROTO_ICMP = 1
1053 IPPROTO_IGMP = 2
1054 BTHPROTO_RFCOMM = 3
1055 IPPROTO_TCP = 6
1056 IPPROTO_UDP = 17
1057 IPPROTO_IPV6 = 41
1058 IPPROTO_ICMPV6 = 58
1059 IPPROTO_RM = 113
1060
1061 SOL_SOCKET = 0xffff
1062 SO_REUSEADDR = 4
1063 SO_KEEPALIVE = 8
1064 SO_DONTROUTE = 16
1065 SO_BROADCAST = 32
1066 SO_LINGER = 128
1067 SO_RCVBUF = 0x1002
1068 SO_RCVTIMEO = 0x1006
1069 SO_SNDBUF = 0x1001
1070 SO_UPDATE_ACCEPT_CONTEXT = 0x700b
1071 SO_UPDATE_CONNECT_CONTEXT = 0x7010
1072
1073 IOC_OUT = 0x40000000
1074 IOC_IN = 0x80000000
1075 IOC_VENDOR = 0x18000000
1076 IOC_INOUT = IOC_IN | IOC_OUT
1077 IOC_WS2 = 0x08000000
1078 SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6
1079 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4
1080 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12
1081 SIO_UDP_NETRESET = IOC_IN | IOC_VENDOR | 15
1082
1083 // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460
1084
1085 IP_HDRINCL = 0x2
1086 IP_TOS = 0x3
1087 IP_TTL = 0x4
1088 IP_MULTICAST_IF = 0x9
1089 IP_MULTICAST_TTL = 0xa
1090 IP_MULTICAST_LOOP = 0xb
1091 IP_ADD_MEMBERSHIP = 0xc
1092 IP_DROP_MEMBERSHIP = 0xd
1093 IP_PKTINFO = 0x13
1094 IP_MTU_DISCOVER = 0x47
1095
1096 IPV6_V6ONLY = 0x1b
1097 IPV6_UNICAST_HOPS = 0x4
1098 IPV6_MULTICAST_IF = 0x9
1099 IPV6_MULTICAST_HOPS = 0xa
1100 IPV6_MULTICAST_LOOP = 0xb
1101 IPV6_JOIN_GROUP = 0xc
1102 IPV6_LEAVE_GROUP = 0xd
1103 IPV6_PKTINFO = 0x13
1104 IPV6_MTU_DISCOVER = 0x47
1105
1106 MSG_OOB = 0x1
1107 MSG_PEEK = 0x2
1108 MSG_DONTROUTE = 0x4
1109 MSG_WAITALL = 0x8
1110
1111 MSG_TRUNC = 0x0100
1112 MSG_CTRUNC = 0x0200
1113 MSG_BCAST = 0x0400
1114 MSG_MCAST = 0x0800
1115
1116 SOMAXCONN = 0x7fffffff
1117
1118 TCP_NODELAY = 1
1119 TCP_EXPEDITED_1122 = 2
1120 TCP_KEEPALIVE = 3
1121 TCP_MAXSEG = 4
1122 TCP_MAXRT = 5
1123 TCP_STDURG = 6
1124 TCP_NOURG = 7
1125 TCP_ATMARK = 8
1126 TCP_NOSYNRETRIES = 9
1127 TCP_TIMESTAMPS = 10
1128 TCP_OFFLOAD_PREFERENCE = 11
1129 TCP_CONGESTION_ALGORITHM = 12
1130 TCP_DELAY_FIN_ACK = 13
1131 TCP_MAXRTMS = 14
1132 TCP_FASTOPEN = 15
1133 TCP_KEEPCNT = 16
1134 TCP_KEEPIDLE = TCP_KEEPALIVE
1135 TCP_KEEPINTVL = 17
1136 TCP_FAIL_CONNECT_ON_ICMP_ERROR = 18
1137 TCP_ICMP_ERROR_INFO = 19
1138
1139 UDP_NOCHECKSUM = 1
1140 UDP_SEND_MSG_SIZE = 2
1141 UDP_RECV_MAX_COALESCED_SIZE = 3
1142 UDP_CHECKSUM_COVERAGE = 20
1143
1144 UDP_COALESCED_INFO = 3
1145
1146 SHUT_RD = 0
1147 SHUT_WR = 1
1148 SHUT_RDWR = 2
1149
1150 WSADESCRIPTION_LEN = 256
1151 WSASYS_STATUS_LEN = 128
1152 )
1153
1154 // enum PMTUD_STATE from ws2ipdef.h
1155 const (
1156 IP_PMTUDISC_NOT_SET = 0
1157 IP_PMTUDISC_DO = 1
1158 IP_PMTUDISC_DONT = 2
1159 IP_PMTUDISC_PROBE = 3
1160 IP_PMTUDISC_MAX = 4
1161 )
1162
1163 type WSABuf struct {
1164 Len uint32
1165 Buf *byte
1166 }
1167
1168 type WSAMsg struct {
1169 Name *syscall.RawSockaddrAny
1170 Namelen int32
1171 Buffers *WSABuf
1172 BufferCount uint32
1173 Control WSABuf
1174 Flags uint32
1175 }
1176
1177 type WSACMSGHDR struct {
1178 Len uintptr
1179 Level int32
1180 Type int32
1181 }
1182
1183 type IN_PKTINFO struct {
1184 Addr [4]byte
1185 Ifindex uint32
1186 }
1187
1188 type IN6_PKTINFO struct {
1189 Addr [16]byte
1190 Ifindex uint32
1191 }
1192
1193 // Flags for WSASocket
1194 const (
1195 WSA_FLAG_OVERLAPPED = 0x01
1196 WSA_FLAG_MULTIPOINT_C_ROOT = 0x02
1197 WSA_FLAG_MULTIPOINT_C_LEAF = 0x04
1198 WSA_FLAG_MULTIPOINT_D_ROOT = 0x08
1199 WSA_FLAG_MULTIPOINT_D_LEAF = 0x10
1200 WSA_FLAG_ACCESS_SYSTEM_SECURITY = 0x40
1201 WSA_FLAG_NO_HANDLE_INHERIT = 0x80
1202 WSA_FLAG_REGISTERED_IO = 0x100
1203 )
1204
1205 // Invented values to support what package os expects.
1206 const (
1207 S_IFMT = 0x1f000
1208 S_IFIFO = 0x1000
1209 S_IFCHR = 0x2000
1210 S_IFDIR = 0x4000
1211 S_IFBLK = 0x6000
1212 S_IFREG = 0x8000
1213 S_IFLNK = 0xa000
1214 S_IFSOCK = 0xc000
1215 S_ISUID = 0x800
1216 S_ISGID = 0x400
1217 S_ISVTX = 0x200
1218 S_IRUSR = 0x100
1219 S_IWRITE = 0x80
1220 S_IWUSR = 0x80
1221 S_IXUSR = 0x40
1222 )
1223
1224 const (
1225 FILE_TYPE_CHAR = 0x0002
1226 FILE_TYPE_DISK = 0x0001
1227 FILE_TYPE_PIPE = 0x0003
1228 FILE_TYPE_REMOTE = 0x8000
1229 FILE_TYPE_UNKNOWN = 0x0000
1230 )
1231
1232 type Hostent struct {
1233 Name *byte
1234 Aliases **byte
1235 AddrType uint16
1236 Length uint16
1237 AddrList **byte
1238 }
1239
1240 type Protoent struct {
1241 Name *byte
1242 Aliases **byte
1243 Proto uint16
1244 }
1245
1246 const (
1247 DNS_TYPE_A = 0x0001
1248 DNS_TYPE_NS = 0x0002
1249 DNS_TYPE_MD = 0x0003
1250 DNS_TYPE_MF = 0x0004
1251 DNS_TYPE_CNAME = 0x0005
1252 DNS_TYPE_SOA = 0x0006
1253 DNS_TYPE_MB = 0x0007
1254 DNS_TYPE_MG = 0x0008
1255 DNS_TYPE_MR = 0x0009
1256 DNS_TYPE_NULL = 0x000a
1257 DNS_TYPE_WKS = 0x000b
1258 DNS_TYPE_PTR = 0x000c
1259 DNS_TYPE_HINFO = 0x000d
1260 DNS_TYPE_MINFO = 0x000e
1261 DNS_TYPE_MX = 0x000f
1262 DNS_TYPE_TEXT = 0x0010
1263 DNS_TYPE_RP = 0x0011
1264 DNS_TYPE_AFSDB = 0x0012
1265 DNS_TYPE_X25 = 0x0013
1266 DNS_TYPE_ISDN = 0x0014
1267 DNS_TYPE_RT = 0x0015
1268 DNS_TYPE_NSAP = 0x0016
1269 DNS_TYPE_NSAPPTR = 0x0017
1270 DNS_TYPE_SIG = 0x0018
1271 DNS_TYPE_KEY = 0x0019
1272 DNS_TYPE_PX = 0x001a
1273 DNS_TYPE_GPOS = 0x001b
1274 DNS_TYPE_AAAA = 0x001c
1275 DNS_TYPE_LOC = 0x001d
1276 DNS_TYPE_NXT = 0x001e
1277 DNS_TYPE_EID = 0x001f
1278 DNS_TYPE_NIMLOC = 0x0020
1279 DNS_TYPE_SRV = 0x0021
1280 DNS_TYPE_ATMA = 0x0022
1281 DNS_TYPE_NAPTR = 0x0023
1282 DNS_TYPE_KX = 0x0024
1283 DNS_TYPE_CERT = 0x0025
1284 DNS_TYPE_A6 = 0x0026
1285 DNS_TYPE_DNAME = 0x0027
1286 DNS_TYPE_SINK = 0x0028
1287 DNS_TYPE_OPT = 0x0029
1288 DNS_TYPE_DS = 0x002B
1289 DNS_TYPE_RRSIG = 0x002E
1290 DNS_TYPE_NSEC = 0x002F
1291 DNS_TYPE_DNSKEY = 0x0030
1292 DNS_TYPE_DHCID = 0x0031
1293 DNS_TYPE_UINFO = 0x0064
1294 DNS_TYPE_UID = 0x0065
1295 DNS_TYPE_GID = 0x0066
1296 DNS_TYPE_UNSPEC = 0x0067
1297 DNS_TYPE_ADDRS = 0x00f8
1298 DNS_TYPE_TKEY = 0x00f9
1299 DNS_TYPE_TSIG = 0x00fa
1300 DNS_TYPE_IXFR = 0x00fb
1301 DNS_TYPE_AXFR = 0x00fc
1302 DNS_TYPE_MAILB = 0x00fd
1303 DNS_TYPE_MAILA = 0x00fe
1304 DNS_TYPE_ALL = 0x00ff
1305 DNS_TYPE_ANY = 0x00ff
1306 DNS_TYPE_WINS = 0xff01
1307 DNS_TYPE_WINSR = 0xff02
1308 DNS_TYPE_NBSTAT = 0xff01
1309 )
1310
1311 const (
1312 // flags inside DNSRecord.Dw
1313 DnsSectionQuestion = 0x0000
1314 DnsSectionAnswer = 0x0001
1315 DnsSectionAuthority = 0x0002
1316 DnsSectionAdditional = 0x0003
1317 )
1318
1319 const (
1320 // flags of WSALookupService
1321 LUP_DEEP = 0x0001
1322 LUP_CONTAINERS = 0x0002
1323 LUP_NOCONTAINERS = 0x0004
1324 LUP_NEAREST = 0x0008
1325 LUP_RETURN_NAME = 0x0010
1326 LUP_RETURN_TYPE = 0x0020
1327 LUP_RETURN_VERSION = 0x0040
1328 LUP_RETURN_COMMENT = 0x0080
1329 LUP_RETURN_ADDR = 0x0100
1330 LUP_RETURN_BLOB = 0x0200
1331 LUP_RETURN_ALIASES = 0x0400
1332 LUP_RETURN_QUERY_STRING = 0x0800
1333 LUP_RETURN_ALL = 0x0FF0
1334 LUP_RES_SERVICE = 0x8000
1335
1336 LUP_FLUSHCACHE = 0x1000
1337 LUP_FLUSHPREVIOUS = 0x2000
1338
1339 LUP_NON_AUTHORITATIVE = 0x4000
1340 LUP_SECURE = 0x8000
1341 LUP_RETURN_PREFERRED_NAMES = 0x10000
1342 LUP_DNS_ONLY = 0x20000
1343
1344 LUP_ADDRCONFIG = 0x100000
1345 LUP_DUAL_ADDR = 0x200000
1346 LUP_FILESERVER = 0x400000
1347 LUP_DISABLE_IDN_ENCODING = 0x00800000
1348 LUP_API_ANSI = 0x01000000
1349
1350 LUP_RESOLUTION_HANDLE = 0x80000000
1351 )
1352
1353 const (
1354 // values of WSAQUERYSET's namespace
1355 NS_ALL = 0
1356 NS_DNS = 12
1357 NS_NLA = 15
1358 NS_BTH = 16
1359 NS_EMAIL = 37
1360 NS_PNRPNAME = 38
1361 NS_PNRPCLOUD = 39
1362 )
1363
1364 type DNSSRVData struct {
1365 Target *uint16
1366 Priority uint16
1367 Weight uint16
1368 Port uint16
1369 Pad uint16
1370 }
1371
1372 type DNSPTRData struct {
1373 Host *uint16
1374 }
1375
1376 type DNSMXData struct {
1377 NameExchange *uint16
1378 Preference uint16
1379 Pad uint16
1380 }
1381
1382 type DNSTXTData struct {
1383 StringCount uint16
1384 StringArray [1]*uint16
1385 }
1386
1387 type DNSRecord struct {
1388 Next *DNSRecord
1389 Name *uint16
1390 Type uint16
1391 Length uint16
1392 Dw uint32
1393 Ttl uint32
1394 Reserved uint32
1395 Data [40]byte
1396 }
1397
1398 const (
1399 TF_DISCONNECT = 1
1400 TF_REUSE_SOCKET = 2
1401 TF_WRITE_BEHIND = 4
1402 TF_USE_DEFAULT_WORKER = 0
1403 TF_USE_SYSTEM_THREAD = 16
1404 TF_USE_KERNEL_APC = 32
1405 )
1406
1407 type TransmitFileBuffers struct {
1408 Head uintptr
1409 HeadLength uint32
1410 Tail uintptr
1411 TailLength uint32
1412 }
1413
1414 const (
1415 IFF_UP = 1
1416 IFF_BROADCAST = 2
1417 IFF_LOOPBACK = 4
1418 IFF_POINTTOPOINT = 8
1419 IFF_MULTICAST = 16
1420 )
1421
1422 const SIO_GET_INTERFACE_LIST = 0x4004747F
1423
1424 // TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old.
1425 // will be fixed to change variable type as suitable.
1426
1427 type SockaddrGen [24]byte
1428
1429 type InterfaceInfo struct {
1430 Flags uint32
1431 Address SockaddrGen
1432 BroadcastAddress SockaddrGen
1433 Netmask SockaddrGen
1434 }
1435
1436 type IpAddressString struct {
1437 String [16]byte
1438 }
1439
1440 type IpMaskString IpAddressString
1441
1442 type IpAddrString struct {
1443 Next *IpAddrString
1444 IpAddress IpAddressString
1445 IpMask IpMaskString
1446 Context uint32
1447 }
1448
1449 const MAX_ADAPTER_NAME_LENGTH = 256
1450 const MAX_ADAPTER_DESCRIPTION_LENGTH = 128
1451 const MAX_ADAPTER_ADDRESS_LENGTH = 8
1452
1453 type IpAdapterInfo struct {
1454 Next *IpAdapterInfo
1455 ComboIndex uint32
1456 AdapterName [MAX_ADAPTER_NAME_LENGTH + 4]byte
1457 Description [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte
1458 AddressLength uint32
1459 Address [MAX_ADAPTER_ADDRESS_LENGTH]byte
1460 Index uint32
1461 Type uint32
1462 DhcpEnabled uint32
1463 CurrentIpAddress *IpAddrString
1464 IpAddressList IpAddrString
1465 GatewayList IpAddrString
1466 DhcpServer IpAddrString
1467 HaveWins bool
1468 PrimaryWinsServer IpAddrString
1469 SecondaryWinsServer IpAddrString
1470 LeaseObtained int64
1471 LeaseExpires int64
1472 }
1473
1474 const MAXLEN_PHYSADDR = 8
1475 const MAX_INTERFACE_NAME_LEN = 256
1476 const MAXLEN_IFDESCR = 256
1477
1478 type MibIfRow struct {
1479 Name [MAX_INTERFACE_NAME_LEN]uint16
1480 Index uint32
1481 Type uint32
1482 Mtu uint32
1483 Speed uint32
1484 PhysAddrLen uint32
1485 PhysAddr [MAXLEN_PHYSADDR]byte
1486 AdminStatus uint32
1487 OperStatus uint32
1488 LastChange uint32
1489 InOctets uint32
1490 InUcastPkts uint32
1491 InNUcastPkts uint32
1492 InDiscards uint32
1493 InErrors uint32
1494 InUnknownProtos uint32
1495 OutOctets uint32
1496 OutUcastPkts uint32
1497 OutNUcastPkts uint32
1498 OutDiscards uint32
1499 OutErrors uint32
1500 OutQLen uint32
1501 DescrLen uint32
1502 Descr [MAXLEN_IFDESCR]byte
1503 }
1504
1505 type CertInfo struct {
1506 Version uint32
1507 SerialNumber CryptIntegerBlob
1508 SignatureAlgorithm CryptAlgorithmIdentifier
1509 Issuer CertNameBlob
1510 NotBefore Filetime
1511 NotAfter Filetime
1512 Subject CertNameBlob
1513 SubjectPublicKeyInfo CertPublicKeyInfo
1514 IssuerUniqueId CryptBitBlob
1515 SubjectUniqueId CryptBitBlob
1516 CountExtensions uint32
1517 Extensions *CertExtension
1518 }
1519
1520 type CertExtension struct {
1521 ObjId *byte
1522 Critical int32
1523 Value CryptObjidBlob
1524 }
1525
1526 type CryptAlgorithmIdentifier struct {
1527 ObjId *byte
1528 Parameters CryptObjidBlob
1529 }
1530
1531 type CertPublicKeyInfo struct {
1532 Algorithm CryptAlgorithmIdentifier
1533 PublicKey CryptBitBlob
1534 }
1535
1536 type DataBlob struct {
1537 Size uint32
1538 Data *byte
1539 }
1540 type CryptIntegerBlob DataBlob
1541 type CryptUintBlob DataBlob
1542 type CryptObjidBlob DataBlob
1543 type CertNameBlob DataBlob
1544 type CertRdnValueBlob DataBlob
1545 type CertBlob DataBlob
1546 type CrlBlob DataBlob
1547 type CryptDataBlob DataBlob
1548 type CryptHashBlob DataBlob
1549 type CryptDigestBlob DataBlob
1550 type CryptDerBlob DataBlob
1551 type CryptAttrBlob DataBlob
1552
1553 type CryptBitBlob struct {
1554 Size uint32
1555 Data *byte
1556 UnusedBits uint32
1557 }
1558
1559 type CertContext struct {
1560 EncodingType uint32
1561 EncodedCert *byte
1562 Length uint32
1563 CertInfo *CertInfo
1564 Store Handle
1565 }
1566
1567 type CertChainContext struct {
1568 Size uint32
1569 TrustStatus CertTrustStatus
1570 ChainCount uint32
1571 Chains **CertSimpleChain
1572 LowerQualityChainCount uint32
1573 LowerQualityChains **CertChainContext
1574 HasRevocationFreshnessTime uint32
1575 RevocationFreshnessTime uint32
1576 }
1577
1578 type CertTrustListInfo struct {
1579 // Not implemented
1580 }
1581
1582 type CertSimpleChain struct {
1583 Size uint32
1584 TrustStatus CertTrustStatus
1585 NumElements uint32
1586 Elements **CertChainElement
1587 TrustListInfo *CertTrustListInfo
1588 HasRevocationFreshnessTime uint32
1589 RevocationFreshnessTime uint32
1590 }
1591
1592 type CertChainElement struct {
1593 Size uint32
1594 CertContext *CertContext
1595 TrustStatus CertTrustStatus
1596 RevocationInfo *CertRevocationInfo
1597 IssuanceUsage *CertEnhKeyUsage
1598 ApplicationUsage *CertEnhKeyUsage
1599 ExtendedErrorInfo *uint16
1600 }
1601
1602 type CertRevocationCrlInfo struct {
1603 // Not implemented
1604 }
1605
1606 type CertRevocationInfo struct {
1607 Size uint32
1608 RevocationResult uint32
1609 RevocationOid *byte
1610 OidSpecificInfo Pointer
1611 HasFreshnessTime uint32
1612 FreshnessTime uint32
1613 CrlInfo *CertRevocationCrlInfo
1614 }
1615
1616 type CertTrustStatus struct {
1617 ErrorStatus uint32
1618 InfoStatus uint32
1619 }
1620
1621 type CertUsageMatch struct {
1622 Type uint32
1623 Usage CertEnhKeyUsage
1624 }
1625
1626 type CertEnhKeyUsage struct {
1627 Length uint32
1628 UsageIdentifiers **byte
1629 }
1630
1631 type CertChainPara struct {
1632 Size uint32
1633 RequestedUsage CertUsageMatch
1634 RequstedIssuancePolicy CertUsageMatch
1635 URLRetrievalTimeout uint32
1636 CheckRevocationFreshnessTime uint32
1637 RevocationFreshnessTime uint32
1638 CacheResync *Filetime
1639 }
1640
1641 type CertChainPolicyPara struct {
1642 Size uint32
1643 Flags uint32
1644 ExtraPolicyPara Pointer
1645 }
1646
1647 type SSLExtraCertChainPolicyPara struct {
1648 Size uint32
1649 AuthType uint32
1650 Checks uint32
1651 ServerName *uint16
1652 }
1653
1654 type CertChainPolicyStatus struct {
1655 Size uint32
1656 Error uint32
1657 ChainIndex uint32
1658 ElementIndex uint32
1659 ExtraPolicyStatus Pointer
1660 }
1661
1662 type CertPolicyInfo struct {
1663 Identifier *byte
1664 CountQualifiers uint32
1665 Qualifiers *CertPolicyQualifierInfo
1666 }
1667
1668 type CertPoliciesInfo struct {
1669 Count uint32
1670 PolicyInfos *CertPolicyInfo
1671 }
1672
1673 type CertPolicyQualifierInfo struct {
1674 // Not implemented
1675 }
1676
1677 type CertStrongSignPara struct {
1678 Size uint32
1679 InfoChoice uint32
1680 InfoOrSerializedInfoOrOID unsafe.Pointer
1681 }
1682
1683 type CryptProtectPromptStruct struct {
1684 Size uint32
1685 PromptFlags uint32
1686 App HWND
1687 Prompt *uint16
1688 }
1689
1690 type CertChainFindByIssuerPara struct {
1691 Size uint32
1692 UsageIdentifier *byte
1693 KeySpec uint32
1694 AcquirePrivateKeyFlags uint32
1695 IssuerCount uint32
1696 Issuer Pointer
1697 FindCallback Pointer
1698 FindArg Pointer
1699 IssuerChainIndex *uint32
1700 IssuerElementIndex *uint32
1701 }
1702
1703 type WinTrustData struct {
1704 Size uint32
1705 PolicyCallbackData uintptr
1706 SIPClientData uintptr
1707 UIChoice uint32
1708 RevocationChecks uint32
1709 UnionChoice uint32
1710 FileOrCatalogOrBlobOrSgnrOrCert unsafe.Pointer
1711 StateAction uint32
1712 StateData Handle
1713 URLReference *uint16
1714 ProvFlags uint32
1715 UIContext uint32
1716 SignatureSettings *WinTrustSignatureSettings
1717 }
1718
1719 type WinTrustFileInfo struct {
1720 Size uint32
1721 FilePath *uint16
1722 File Handle
1723 KnownSubject *GUID
1724 }
1725
1726 type WinTrustSignatureSettings struct {
1727 Size uint32
1728 Index uint32
1729 Flags uint32
1730 SecondarySigs uint32
1731 VerifiedSigIndex uint32
1732 CryptoPolicy *CertStrongSignPara
1733 }
1734
1735 const (
1736 // do not reorder
1737 HKEY_CLASSES_ROOT = 0x80000000 + iota
1738 HKEY_CURRENT_USER
1739 HKEY_LOCAL_MACHINE
1740 HKEY_USERS
1741 HKEY_PERFORMANCE_DATA
1742 HKEY_CURRENT_CONFIG
1743 HKEY_DYN_DATA
1744
1745 KEY_QUERY_VALUE = 1
1746 KEY_SET_VALUE = 2
1747 KEY_CREATE_SUB_KEY = 4
1748 KEY_ENUMERATE_SUB_KEYS = 8
1749 KEY_NOTIFY = 16
1750 KEY_CREATE_LINK = 32
1751 KEY_WRITE = 0x20006
1752 KEY_EXECUTE = 0x20019
1753 KEY_READ = 0x20019
1754 KEY_WOW64_64KEY = 0x0100
1755 KEY_WOW64_32KEY = 0x0200
1756 KEY_ALL_ACCESS = 0xf003f
1757 )
1758
1759 const (
1760 // do not reorder
1761 REG_NONE = iota
1762 REG_SZ
1763 REG_EXPAND_SZ
1764 REG_BINARY
1765 REG_DWORD_LITTLE_ENDIAN
1766 REG_DWORD_BIG_ENDIAN
1767 REG_LINK
1768 REG_MULTI_SZ
1769 REG_RESOURCE_LIST
1770 REG_FULL_RESOURCE_DESCRIPTOR
1771 REG_RESOURCE_REQUIREMENTS_LIST
1772 REG_QWORD_LITTLE_ENDIAN
1773 REG_DWORD = REG_DWORD_LITTLE_ENDIAN
1774 REG_QWORD = REG_QWORD_LITTLE_ENDIAN
1775 )
1776
1777 const (
1778 EVENT_MODIFY_STATE = 0x0002
1779 EVENT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
1780
1781 MUTANT_QUERY_STATE = 0x0001
1782 MUTANT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE
1783
1784 SEMAPHORE_MODIFY_STATE = 0x0002
1785 SEMAPHORE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3
1786
1787 TIMER_QUERY_STATE = 0x0001
1788 TIMER_MODIFY_STATE = 0x0002
1789 TIMER_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | TIMER_QUERY_STATE | TIMER_MODIFY_STATE
1790
1791 MUTEX_MODIFY_STATE = MUTANT_QUERY_STATE
1792 MUTEX_ALL_ACCESS = MUTANT_ALL_ACCESS
1793
1794 CREATE_EVENT_MANUAL_RESET = 0x1
1795 CREATE_EVENT_INITIAL_SET = 0x2
1796 CREATE_MUTEX_INITIAL_OWNER = 0x1
1797 )
1798
1799 type AddrinfoW struct {
1800 Flags int32
1801 Family int32
1802 Socktype int32
1803 Protocol int32
1804 Addrlen uintptr
1805 Canonname *uint16
1806 Addr uintptr
1807 Next *AddrinfoW
1808 }
1809
1810 const (
1811 AI_PASSIVE = 1
1812 AI_CANONNAME = 2
1813 AI_NUMERICHOST = 4
1814 )
1815
1816 type GUID struct {
1817 Data1 uint32
1818 Data2 uint16
1819 Data3 uint16
1820 Data4 [8]byte
1821 }
1822
1823 var WSAID_CONNECTEX = GUID{
1824 0x25a207b9,
1825 0xddf3,
1826 0x4660,
1827 [8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e},
1828 }
1829
1830 var WSAID_WSASENDMSG = GUID{
1831 0xa441e712,
1832 0x754f,
1833 0x43ca,
1834 [8]byte{0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d},
1835 }
1836
1837 var WSAID_WSARECVMSG = GUID{
1838 0xf689d7c8,
1839 0x6f1f,
1840 0x436b,
1841 [8]byte{0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22},
1842 }
1843
1844 const (
1845 FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1
1846 FILE_SKIP_SET_EVENT_ON_HANDLE = 2
1847 )
1848
1849 const (
1850 WSAPROTOCOL_LEN = 255
1851 MAX_PROTOCOL_CHAIN = 7
1852 BASE_PROTOCOL = 1
1853 LAYERED_PROTOCOL = 0
1854
1855 XP1_CONNECTIONLESS = 0x00000001
1856 XP1_GUARANTEED_DELIVERY = 0x00000002
1857 XP1_GUARANTEED_ORDER = 0x00000004
1858 XP1_MESSAGE_ORIENTED = 0x00000008
1859 XP1_PSEUDO_STREAM = 0x00000010
1860 XP1_GRACEFUL_CLOSE = 0x00000020
1861 XP1_EXPEDITED_DATA = 0x00000040
1862 XP1_CONNECT_DATA = 0x00000080
1863 XP1_DISCONNECT_DATA = 0x00000100
1864 XP1_SUPPORT_BROADCAST = 0x00000200
1865 XP1_SUPPORT_MULTIPOINT = 0x00000400
1866 XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800
1867 XP1_MULTIPOINT_DATA_PLANE = 0x00001000
1868 XP1_QOS_SUPPORTED = 0x00002000
1869 XP1_UNI_SEND = 0x00008000
1870 XP1_UNI_RECV = 0x00010000
1871 XP1_IFS_HANDLES = 0x00020000
1872 XP1_PARTIAL_MESSAGE = 0x00040000
1873 XP1_SAN_SUPPORT_SDP = 0x00080000
1874
1875 PFL_MULTIPLE_PROTO_ENTRIES = 0x00000001
1876 PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002
1877 PFL_HIDDEN = 0x00000004
1878 PFL_MATCHES_PROTOCOL_ZERO = 0x00000008
1879 PFL_NETWORKDIRECT_PROVIDER = 0x00000010
1880 )
1881
1882 type WSAProtocolInfo struct {
1883 ServiceFlags1 uint32
1884 ServiceFlags2 uint32
1885 ServiceFlags3 uint32
1886 ServiceFlags4 uint32
1887 ProviderFlags uint32
1888 ProviderId GUID
1889 CatalogEntryId uint32
1890 ProtocolChain WSAProtocolChain
1891 Version int32
1892 AddressFamily int32
1893 MaxSockAddr int32
1894 MinSockAddr int32
1895 SocketType int32
1896 Protocol int32
1897 ProtocolMaxOffset int32
1898 NetworkByteOrder int32
1899 SecurityScheme int32
1900 MessageSize uint32
1901 ProviderReserved uint32
1902 ProtocolName [WSAPROTOCOL_LEN + 1]uint16
1903 }
1904
1905 type WSAProtocolChain struct {
1906 ChainLen int32
1907 ChainEntries [MAX_PROTOCOL_CHAIN]uint32
1908 }
1909
1910 type TCPKeepalive struct {
1911 OnOff uint32
1912 Time uint32
1913 Interval uint32
1914 }
1915
1916 type symbolicLinkReparseBuffer struct {
1917 SubstituteNameOffset uint16
1918 SubstituteNameLength uint16
1919 PrintNameOffset uint16
1920 PrintNameLength uint16
1921 Flags uint32
1922 PathBuffer [1]uint16
1923 }
1924
1925 type mountPointReparseBuffer struct {
1926 SubstituteNameOffset uint16
1927 SubstituteNameLength uint16
1928 PrintNameOffset uint16
1929 PrintNameLength uint16
1930 PathBuffer [1]uint16
1931 }
1932
1933 type reparseDataBuffer struct {
1934 ReparseTag uint32
1935 ReparseDataLength uint16
1936 Reserved uint16
1937
1938 // GenericReparseBuffer
1939 reparseBuffer byte
1940 }
1941
1942 const (
1943 FSCTL_CREATE_OR_GET_OBJECT_ID = 0x0900C0
1944 FSCTL_DELETE_OBJECT_ID = 0x0900A0
1945 FSCTL_DELETE_REPARSE_POINT = 0x0900AC
1946 FSCTL_DUPLICATE_EXTENTS_TO_FILE = 0x098344
1947 FSCTL_DUPLICATE_EXTENTS_TO_FILE_EX = 0x0983E8
1948 FSCTL_FILESYSTEM_GET_STATISTICS = 0x090060
1949 FSCTL_FILE_LEVEL_TRIM = 0x098208
1950 FSCTL_FIND_FILES_BY_SID = 0x09008F
1951 FSCTL_GET_COMPRESSION = 0x09003C
1952 FSCTL_GET_INTEGRITY_INFORMATION = 0x09027C
1953 FSCTL_GET_NTFS_VOLUME_DATA = 0x090064
1954 FSCTL_GET_REFS_VOLUME_DATA = 0x0902D8
1955 FSCTL_GET_OBJECT_ID = 0x09009C
1956 FSCTL_GET_REPARSE_POINT = 0x0900A8
1957 FSCTL_GET_RETRIEVAL_POINTER_COUNT = 0x09042B
1958 FSCTL_GET_RETRIEVAL_POINTERS = 0x090073
1959 FSCTL_GET_RETRIEVAL_POINTERS_AND_REFCOUNT = 0x0903D3
1960 FSCTL_IS_PATHNAME_VALID = 0x09002C
1961 FSCTL_LMR_SET_LINK_TRACKING_INFORMATION = 0x1400EC
1962 FSCTL_MARK_HANDLE = 0x0900FC
1963 FSCTL_OFFLOAD_READ = 0x094264
1964 FSCTL_OFFLOAD_WRITE = 0x098268
1965 FSCTL_PIPE_PEEK = 0x11400C
1966 FSCTL_PIPE_TRANSCEIVE = 0x11C017
1967 FSCTL_PIPE_WAIT = 0x110018
1968 FSCTL_QUERY_ALLOCATED_RANGES = 0x0940CF
1969 FSCTL_QUERY_FAT_BPB = 0x090058
1970 FSCTL_QUERY_FILE_REGIONS = 0x090284
1971 FSCTL_QUERY_ON_DISK_VOLUME_INFO = 0x09013C
1972 FSCTL_QUERY_SPARING_INFO = 0x090138
1973 FSCTL_READ_FILE_USN_DATA = 0x0900EB
1974 FSCTL_RECALL_FILE = 0x090117
1975 FSCTL_REFS_STREAM_SNAPSHOT_MANAGEMENT = 0x090440
1976 FSCTL_SET_COMPRESSION = 0x09C040
1977 FSCTL_SET_DEFECT_MANAGEMENT = 0x098134
1978 FSCTL_SET_ENCRYPTION = 0x0900D7
1979 FSCTL_SET_INTEGRITY_INFORMATION = 0x09C280
1980 FSCTL_SET_INTEGRITY_INFORMATION_EX = 0x090380
1981 FSCTL_SET_OBJECT_ID = 0x090098
1982 FSCTL_SET_OBJECT_ID_EXTENDED = 0x0900BC
1983 FSCTL_SET_REPARSE_POINT = 0x0900A4
1984 FSCTL_SET_SPARSE = 0x0900C4
1985 FSCTL_SET_ZERO_DATA = 0x0980C8
1986 FSCTL_SET_ZERO_ON_DEALLOCATION = 0x090194
1987 FSCTL_SIS_COPYFILE = 0x090100
1988 FSCTL_WRITE_USN_CLOSE_RECORD = 0x0900EF
1989
1990 MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024
1991 IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
1992 IO_REPARSE_TAG_SYMLINK = 0xA000000C
1993 SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
1994 )
1995
1996 // FILE_ZERO_DATA_INFORMATION from winioctl.h
1997 type FileZeroDataInformation struct {
1998 FileOffset int64
1999 BeyondFinalZero int64
2000 }
2001
2002 const (
2003 ComputerNameNetBIOS = 0
2004 ComputerNameDnsHostname = 1
2005 ComputerNameDnsDomain = 2
2006 ComputerNameDnsFullyQualified = 3
2007 ComputerNamePhysicalNetBIOS = 4
2008 ComputerNamePhysicalDnsHostname = 5
2009 ComputerNamePhysicalDnsDomain = 6
2010 ComputerNamePhysicalDnsFullyQualified = 7
2011 ComputerNameMax = 8
2012 )
2013
2014 // For MessageBox()
2015 const (
2016 MB_OK = 0x00000000
2017 MB_OKCANCEL = 0x00000001
2018 MB_ABORTRETRYIGNORE = 0x00000002
2019 MB_YESNOCANCEL = 0x00000003
2020 MB_YESNO = 0x00000004
2021 MB_RETRYCANCEL = 0x00000005
2022 MB_CANCELTRYCONTINUE = 0x00000006
2023 MB_ICONHAND = 0x00000010
2024 MB_ICONQUESTION = 0x00000020
2025 MB_ICONEXCLAMATION = 0x00000030
2026 MB_ICONASTERISK = 0x00000040
2027 MB_USERICON = 0x00000080
2028 MB_ICONWARNING = MB_ICONEXCLAMATION
2029 MB_ICONERROR = MB_ICONHAND
2030 MB_ICONINFORMATION = MB_ICONASTERISK
2031 MB_ICONSTOP = MB_ICONHAND
2032 MB_DEFBUTTON1 = 0x00000000
2033 MB_DEFBUTTON2 = 0x00000100
2034 MB_DEFBUTTON3 = 0x00000200
2035 MB_DEFBUTTON4 = 0x00000300
2036 MB_APPLMODAL = 0x00000000
2037 MB_SYSTEMMODAL = 0x00001000
2038 MB_TASKMODAL = 0x00002000
2039 MB_HELP = 0x00004000
2040 MB_NOFOCUS = 0x00008000
2041 MB_SETFOREGROUND = 0x00010000
2042 MB_DEFAULT_DESKTOP_ONLY = 0x00020000
2043 MB_TOPMOST = 0x00040000
2044 MB_RIGHT = 0x00080000
2045 MB_RTLREADING = 0x00100000
2046 MB_SERVICE_NOTIFICATION = 0x00200000
2047 )
2048
2049 const (
2050 MOVEFILE_REPLACE_EXISTING = 0x1
2051 MOVEFILE_COPY_ALLOWED = 0x2
2052 MOVEFILE_DELAY_UNTIL_REBOOT = 0x4
2053 MOVEFILE_WRITE_THROUGH = 0x8
2054 MOVEFILE_CREATE_HARDLINK = 0x10
2055 MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20
2056 )
2057
2058 // Flags for GetAdaptersAddresses, see
2059 // https://learn.microsoft.com/en-us/windows/win32/api/iphlpapi/nf-iphlpapi-getadaptersaddresses.
2060 const (
2061 GAA_FLAG_SKIP_UNICAST = 0x1
2062 GAA_FLAG_SKIP_ANYCAST = 0x2
2063 GAA_FLAG_SKIP_MULTICAST = 0x4
2064 GAA_FLAG_SKIP_DNS_SERVER = 0x8
2065 GAA_FLAG_INCLUDE_PREFIX = 0x10
2066 GAA_FLAG_SKIP_FRIENDLY_NAME = 0x20
2067 GAA_FLAG_INCLUDE_WINS_INFO = 0x40
2068 GAA_FLAG_INCLUDE_GATEWAYS = 0x80
2069 GAA_FLAG_INCLUDE_ALL_INTERFACES = 0x100
2070 GAA_FLAG_INCLUDE_ALL_COMPARTMENTS = 0x200
2071 GAA_FLAG_INCLUDE_TUNNEL_BINDINGORDER = 0x400
2072 )
2073
2074 const (
2075 IF_TYPE_OTHER = 1
2076 IF_TYPE_ETHERNET_CSMACD = 6
2077 IF_TYPE_ISO88025_TOKENRING = 9
2078 IF_TYPE_PPP = 23
2079 IF_TYPE_SOFTWARE_LOOPBACK = 24
2080 IF_TYPE_ATM = 37
2081 IF_TYPE_IEEE80211 = 71
2082 IF_TYPE_TUNNEL = 131
2083 IF_TYPE_IEEE1394 = 144
2084 )
2085
2086 // Enum NL_PREFIX_ORIGIN for [IpAdapterUnicastAddress], see
2087 // https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_prefix_origin
2088 const (
2089 IpPrefixOriginOther = 0
2090 IpPrefixOriginManual = 1
2091 IpPrefixOriginWellKnown = 2
2092 IpPrefixOriginDhcp = 3
2093 IpPrefixOriginRouterAdvertisement = 4
2094 IpPrefixOriginUnchanged = 1 << 4
2095 )
2096
2097 // Enum NL_SUFFIX_ORIGIN for [IpAdapterUnicastAddress], see
2098 // https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_suffix_origin
2099 const (
2100 NlsoOther = 0
2101 NlsoManual = 1
2102 NlsoWellKnown = 2
2103 NlsoDhcp = 3
2104 NlsoLinkLayerAddress = 4
2105 NlsoRandom = 5
2106 IpSuffixOriginOther = 0
2107 IpSuffixOriginManual = 1
2108 IpSuffixOriginWellKnown = 2
2109 IpSuffixOriginDhcp = 3
2110 IpSuffixOriginLinkLayerAddress = 4
2111 IpSuffixOriginRandom = 5
2112 IpSuffixOriginUnchanged = 1 << 4
2113 )
2114
2115 // Enum NL_DAD_STATE for [IpAdapterUnicastAddress], see
2116 // https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_dad_state
2117 const (
2118 NldsInvalid = 0
2119 NldsTentative = 1
2120 NldsDuplicate = 2
2121 NldsDeprecated = 3
2122 NldsPreferred = 4
2123 IpDadStateInvalid = 0
2124 IpDadStateTentative = 1
2125 IpDadStateDuplicate = 2
2126 IpDadStateDeprecated = 3
2127 IpDadStatePreferred = 4
2128 )
2129
2130 type SocketAddress struct {
2131 Sockaddr *syscall.RawSockaddrAny
2132 SockaddrLength int32
2133 }
2134
2135 // IP returns an IPv4 or IPv6 address, or nil if the underlying SocketAddress is neither.
2136 func (addr *SocketAddress) IP() net.IP {
2137 if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet4{}) && addr.Sockaddr.Addr.Family == AF_INET {
2138 return (*RawSockaddrInet4)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
2139 } else if uintptr(addr.SockaddrLength) >= unsafe.Sizeof(RawSockaddrInet6{}) && addr.Sockaddr.Addr.Family == AF_INET6 {
2140 return (*RawSockaddrInet6)(unsafe.Pointer(addr.Sockaddr)).Addr[:]
2141 }
2142 return nil
2143 }
2144
2145 type IpAdapterUnicastAddress struct {
2146 Length uint32
2147 Flags uint32
2148 Next *IpAdapterUnicastAddress
2149 Address SocketAddress
2150 PrefixOrigin int32
2151 SuffixOrigin int32
2152 DadState int32
2153 ValidLifetime uint32
2154 PreferredLifetime uint32
2155 LeaseLifetime uint32
2156 OnLinkPrefixLength uint8
2157 }
2158
2159 type IpAdapterAnycastAddress struct {
2160 Length uint32
2161 Flags uint32
2162 Next *IpAdapterAnycastAddress
2163 Address SocketAddress
2164 }
2165
2166 type IpAdapterMulticastAddress struct {
2167 Length uint32
2168 Flags uint32
2169 Next *IpAdapterMulticastAddress
2170 Address SocketAddress
2171 }
2172
2173 type IpAdapterDnsServerAdapter struct {
2174 Length uint32
2175 Reserved uint32
2176 Next *IpAdapterDnsServerAdapter
2177 Address SocketAddress
2178 }
2179
2180 type IpAdapterPrefix struct {
2181 Length uint32
2182 Flags uint32
2183 Next *IpAdapterPrefix
2184 Address SocketAddress
2185 PrefixLength uint32
2186 }
2187
2188 type IpAdapterAddresses struct {
2189 Length uint32
2190 IfIndex uint32
2191 Next *IpAdapterAddresses
2192 AdapterName *byte
2193 FirstUnicastAddress *IpAdapterUnicastAddress
2194 FirstAnycastAddress *IpAdapterAnycastAddress
2195 FirstMulticastAddress *IpAdapterMulticastAddress
2196 FirstDnsServerAddress *IpAdapterDnsServerAdapter
2197 DnsSuffix *uint16
2198 Description *uint16
2199 FriendlyName *uint16
2200 PhysicalAddress [syscall.MAX_ADAPTER_ADDRESS_LENGTH]byte
2201 PhysicalAddressLength uint32
2202 Flags uint32
2203 Mtu uint32
2204 IfType uint32
2205 OperStatus uint32
2206 Ipv6IfIndex uint32
2207 ZoneIndices [16]uint32
2208 FirstPrefix *IpAdapterPrefix
2209 TransmitLinkSpeed uint64
2210 ReceiveLinkSpeed uint64
2211 FirstWinsServerAddress *IpAdapterWinsServerAddress
2212 FirstGatewayAddress *IpAdapterGatewayAddress
2213 Ipv4Metric uint32
2214 Ipv6Metric uint32
2215 Luid uint64
2216 Dhcpv4Server SocketAddress
2217 CompartmentId uint32
2218 NetworkGuid GUID
2219 ConnectionType uint32
2220 TunnelType uint32
2221 Dhcpv6Server SocketAddress
2222 Dhcpv6ClientDuid [MAX_DHCPV6_DUID_LENGTH]byte
2223 Dhcpv6ClientDuidLength uint32
2224 Dhcpv6Iaid uint32
2225 FirstDnsSuffix *IpAdapterDNSSuffix
2226 }
2227
2228 type IpAdapterWinsServerAddress struct {
2229 Length uint32
2230 Reserved uint32
2231 Next *IpAdapterWinsServerAddress
2232 Address SocketAddress
2233 }
2234
2235 type IpAdapterGatewayAddress struct {
2236 Length uint32
2237 Reserved uint32
2238 Next *IpAdapterGatewayAddress
2239 Address SocketAddress
2240 }
2241
2242 type IpAdapterDNSSuffix struct {
2243 Next *IpAdapterDNSSuffix
2244 String [MAX_DNS_SUFFIX_STRING_LENGTH]uint16
2245 }
2246
2247 const (
2248 IfOperStatusUp = 1
2249 IfOperStatusDown = 2
2250 IfOperStatusTesting = 3
2251 IfOperStatusUnknown = 4
2252 IfOperStatusDormant = 5
2253 IfOperStatusNotPresent = 6
2254 IfOperStatusLowerLayerDown = 7
2255 )
2256
2257 const (
2258 IF_MAX_PHYS_ADDRESS_LENGTH = 32
2259 IF_MAX_STRING_SIZE = 256
2260 )
2261
2262 // MIB_IF_ENTRY_LEVEL enumeration from netioapi.h or
2263 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/nf-netioapi-getifentry2ex.
2264 const (
2265 MibIfEntryNormal = 0
2266 MibIfEntryNormalWithoutStatistics = 2
2267 )
2268
2269 // MIB_NOTIFICATION_TYPE enumeration from netioapi.h or
2270 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ne-netioapi-mib_notification_type.
2271 const (
2272 MibParameterNotification = 0
2273 MibAddInstance = 1
2274 MibDeleteInstance = 2
2275 MibInitialNotification = 3
2276 )
2277
2278 // MibIfRow2 stores information about a particular interface. See
2279 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_row2.
2280 type MibIfRow2 struct {
2281 InterfaceLuid uint64
2282 InterfaceIndex uint32
2283 InterfaceGuid GUID
2284 Alias [IF_MAX_STRING_SIZE + 1]uint16
2285 Description [IF_MAX_STRING_SIZE + 1]uint16
2286 PhysicalAddressLength uint32
2287 PhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]uint8
2288 PermanentPhysicalAddress [IF_MAX_PHYS_ADDRESS_LENGTH]uint8
2289 Mtu uint32
2290 Type uint32
2291 TunnelType uint32
2292 MediaType uint32
2293 PhysicalMediumType uint32
2294 AccessType uint32
2295 DirectionType uint32
2296 InterfaceAndOperStatusFlags uint8
2297 OperStatus uint32
2298 AdminStatus uint32
2299 MediaConnectState uint32
2300 NetworkGuid GUID
2301 ConnectionType uint32
2302 TransmitLinkSpeed uint64
2303 ReceiveLinkSpeed uint64
2304 InOctets uint64
2305 InUcastPkts uint64
2306 InNUcastPkts uint64
2307 InDiscards uint64
2308 InErrors uint64
2309 InUnknownProtos uint64
2310 InUcastOctets uint64
2311 InMulticastOctets uint64
2312 InBroadcastOctets uint64
2313 OutOctets uint64
2314 OutUcastPkts uint64
2315 OutNUcastPkts uint64
2316 OutDiscards uint64
2317 OutErrors uint64
2318 OutUcastOctets uint64
2319 OutMulticastOctets uint64
2320 OutBroadcastOctets uint64
2321 OutQLen uint64
2322 }
2323
2324 // MIB_IF_TABLE_LEVEL enumeration from netioapi.h or
2325 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ne-netioapi-mib_if_table_level.
2326 const (
2327 MibIfTableNormal = 0
2328 MibIfTableRaw = 1
2329 MibIfTableNormalWithoutStatistics = 2
2330 )
2331
2332 // MibIfTable2 contains a table of logical and physical interface entries. See
2333 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_if_table2.
2334 type MibIfTable2 struct {
2335 NumEntries uint32
2336 Table [1]MibIfRow2
2337 }
2338
2339 // IP_ADDRESS_PREFIX stores an IP address prefix. See
2340 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-ip_address_prefix.
2341 type IpAddressPrefix struct {
2342 Prefix RawSockaddrInet
2343 PrefixLength uint8
2344 }
2345
2346 // NL_ROUTE_ORIGIN enumeration from nldef.h or
2347 // https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_route_origin.
2348 const (
2349 NlroManual = 0
2350 NlroWellKnown = 1
2351 NlroDHCP = 2
2352 NlroRouterAdvertisement = 3
2353 Nlro6to4 = 4
2354 )
2355
2356 // NL_ROUTE_ORIGIN enumeration from nldef.h or
2357 // https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_route_protocol.
2358 const (
2359 MIB_IPPROTO_OTHER = 1
2360 MIB_IPPROTO_LOCAL = 2
2361 MIB_IPPROTO_NETMGMT = 3
2362 MIB_IPPROTO_ICMP = 4
2363 MIB_IPPROTO_EGP = 5
2364 MIB_IPPROTO_GGP = 6
2365 MIB_IPPROTO_HELLO = 7
2366 MIB_IPPROTO_RIP = 8
2367 MIB_IPPROTO_IS_IS = 9
2368 MIB_IPPROTO_ES_IS = 10
2369 MIB_IPPROTO_CISCO = 11
2370 MIB_IPPROTO_BBN = 12
2371 MIB_IPPROTO_OSPF = 13
2372 MIB_IPPROTO_BGP = 14
2373 MIB_IPPROTO_IDPR = 15
2374 MIB_IPPROTO_EIGRP = 16
2375 MIB_IPPROTO_DVMRP = 17
2376 MIB_IPPROTO_RPL = 18
2377 MIB_IPPROTO_DHCP = 19
2378 MIB_IPPROTO_NT_AUTOSTATIC = 10002
2379 MIB_IPPROTO_NT_STATIC = 10006
2380 MIB_IPPROTO_NT_STATIC_NON_DOD = 10007
2381 )
2382
2383 // MIB_IPFORWARD_ROW2 stores information about an IP route entry. See
2384 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipforward_row2.
2385 type MibIpForwardRow2 struct {
2386 InterfaceLuid uint64
2387 InterfaceIndex uint32
2388 DestinationPrefix IpAddressPrefix
2389 NextHop RawSockaddrInet
2390 SitePrefixLength uint8
2391 ValidLifetime uint32
2392 PreferredLifetime uint32
2393 Metric uint32
2394 Protocol uint32
2395 Loopback uint8
2396 AutoconfigureAddress uint8
2397 Publish uint8
2398 Immortal uint8
2399 Age uint32
2400 Origin uint32
2401 }
2402
2403 // MIB_IPFORWARD_TABLE2 contains a table of IP route entries. See
2404 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipforward_table2.
2405 type MibIpForwardTable2 struct {
2406 NumEntries uint32
2407 Table [1]MibIpForwardRow2
2408 }
2409
2410 // Rows returns the IP route entries in the table.
2411 func (t *MibIpForwardTable2) Rows() []MibIpForwardRow2 {
2412 return unsafe.Slice(&t.Table[0], t.NumEntries)
2413 }
2414
2415 // MIB_UNICASTIPADDRESS_ROW stores information about a unicast IP address. See
2416 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_row.
2417 type MibUnicastIpAddressRow struct {
2418 Address RawSockaddrInet6 // SOCKADDR_INET union
2419 InterfaceLuid uint64
2420 InterfaceIndex uint32
2421 PrefixOrigin uint32
2422 SuffixOrigin uint32
2423 ValidLifetime uint32
2424 PreferredLifetime uint32
2425 OnLinkPrefixLength uint8
2426 SkipAsSource uint8
2427 DadState uint32
2428 ScopeId uint32
2429 CreationTimeStamp Filetime
2430 }
2431
2432 // MibUnicastIpAddressTable contains a table of unicast IP address entries. See
2433 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_table.
2434 type MibUnicastIpAddressTable struct {
2435 NumEntries uint32
2436 Table [1]MibUnicastIpAddressRow
2437 }
2438
2439 const ScopeLevelCount = 16
2440
2441 // MIB_IPINTERFACE_ROW stores interface management information for a particular IP address family on a network interface.
2442 // See https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipinterface_row.
2443 type MibIpInterfaceRow struct {
2444 Family uint16
2445 InterfaceLuid uint64
2446 InterfaceIndex uint32
2447 MaxReassemblySize uint32
2448 InterfaceIdentifier uint64
2449 MinRouterAdvertisementInterval uint32
2450 MaxRouterAdvertisementInterval uint32
2451 AdvertisingEnabled uint8
2452 ForwardingEnabled uint8
2453 WeakHostSend uint8
2454 WeakHostReceive uint8
2455 UseAutomaticMetric uint8
2456 UseNeighborUnreachabilityDetection uint8
2457 ManagedAddressConfigurationSupported uint8
2458 OtherStatefulConfigurationSupported uint8
2459 AdvertiseDefaultRoute uint8
2460 RouterDiscoveryBehavior uint32
2461 DadTransmits uint32
2462 BaseReachableTime uint32
2463 RetransmitTime uint32
2464 PathMtuDiscoveryTimeout uint32
2465 LinkLocalAddressBehavior uint32
2466 LinkLocalAddressTimeout uint32
2467 ZoneIndices [ScopeLevelCount]uint32
2468 SitePrefixLength uint32
2469 Metric uint32
2470 NlMtu uint32
2471 Connected uint8
2472 SupportsWakeUpPatterns uint8
2473 SupportsNeighborDiscovery uint8
2474 SupportsRouterDiscovery uint8
2475 ReachableTime uint32
2476 TransmitOffload uint32
2477 ReceiveOffload uint32
2478 DisableDefaultRoutes uint8
2479 }
2480
2481 // MibIpInterfaceTable contains a table of IP interface entries. See
2482 // https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipinterface_table.
2483 type MibIpInterfaceTable struct {
2484 NumEntries uint32
2485 Table [1]MibIpInterfaceRow
2486 }
2487
2488 // Console related constants used for the mode parameter to SetConsoleMode. See
2489 // https://docs.microsoft.com/en-us/windows/console/setconsolemode for details.
2490
2491 const (
2492 ENABLE_PROCESSED_INPUT = 0x1
2493 ENABLE_LINE_INPUT = 0x2
2494 ENABLE_ECHO_INPUT = 0x4
2495 ENABLE_WINDOW_INPUT = 0x8
2496 ENABLE_MOUSE_INPUT = 0x10
2497 ENABLE_INSERT_MODE = 0x20
2498 ENABLE_QUICK_EDIT_MODE = 0x40
2499 ENABLE_EXTENDED_FLAGS = 0x80
2500 ENABLE_AUTO_POSITION = 0x100
2501 ENABLE_VIRTUAL_TERMINAL_INPUT = 0x200
2502
2503 ENABLE_PROCESSED_OUTPUT = 0x1
2504 ENABLE_WRAP_AT_EOL_OUTPUT = 0x2
2505 ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4
2506 DISABLE_NEWLINE_AUTO_RETURN = 0x8
2507 ENABLE_LVB_GRID_WORLDWIDE = 0x10
2508 )
2509
2510 // Pseudo console related constants used for the flags parameter to
2511 // CreatePseudoConsole. See: https://learn.microsoft.com/en-us/windows/console/createpseudoconsole
2512 const (
2513 PSEUDOCONSOLE_INHERIT_CURSOR = 0x1
2514 )
2515
2516 type Coord struct {
2517 X int16
2518 Y int16
2519 }
2520
2521 type SmallRect struct {
2522 Left int16
2523 Top int16
2524 Right int16
2525 Bottom int16
2526 }
2527
2528 // Used with GetConsoleScreenBuffer to retrieve information about a console
2529 // screen buffer. See
2530 // https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str
2531 // for details.
2532
2533 type ConsoleScreenBufferInfo struct {
2534 Size Coord
2535 CursorPosition Coord
2536 Attributes uint16
2537 Window SmallRect
2538 MaximumWindowSize Coord
2539 }
2540
2541 const UNIX_PATH_MAX = 108 // defined in afunix.h
2542
2543 const (
2544 // flags for JOBOBJECT_BASIC_LIMIT_INFORMATION.LimitFlags
2545 JOB_OBJECT_LIMIT_ACTIVE_PROCESS = 0x00000008
2546 JOB_OBJECT_LIMIT_AFFINITY = 0x00000010
2547 JOB_OBJECT_LIMIT_BREAKAWAY_OK = 0x00000800
2548 JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = 0x00000400
2549 JOB_OBJECT_LIMIT_JOB_MEMORY = 0x00000200
2550 JOB_OBJECT_LIMIT_JOB_TIME = 0x00000004
2551 JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x00002000
2552 JOB_OBJECT_LIMIT_PRESERVE_JOB_TIME = 0x00000040
2553 JOB_OBJECT_LIMIT_PRIORITY_CLASS = 0x00000020
2554 JOB_OBJECT_LIMIT_PROCESS_MEMORY = 0x00000100
2555 JOB_OBJECT_LIMIT_PROCESS_TIME = 0x00000002
2556 JOB_OBJECT_LIMIT_SCHEDULING_CLASS = 0x00000080
2557 JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK = 0x00001000
2558 JOB_OBJECT_LIMIT_SUBSET_AFFINITY = 0x00004000
2559 JOB_OBJECT_LIMIT_WORKINGSET = 0x00000001
2560 )
2561
2562 type IO_COUNTERS struct {
2563 ReadOperationCount uint64
2564 WriteOperationCount uint64
2565 OtherOperationCount uint64
2566 ReadTransferCount uint64
2567 WriteTransferCount uint64
2568 OtherTransferCount uint64
2569 }
2570
2571 type JOBOBJECT_EXTENDED_LIMIT_INFORMATION struct {
2572 BasicLimitInformation JOBOBJECT_BASIC_LIMIT_INFORMATION
2573 IoInfo IO_COUNTERS
2574 ProcessMemoryLimit uintptr
2575 JobMemoryLimit uintptr
2576 PeakProcessMemoryUsed uintptr
2577 PeakJobMemoryUsed uintptr
2578 }
2579
2580 const (
2581 // UIRestrictionsClass
2582 JOB_OBJECT_UILIMIT_DESKTOP = 0x00000040
2583 JOB_OBJECT_UILIMIT_DISPLAYSETTINGS = 0x00000010
2584 JOB_OBJECT_UILIMIT_EXITWINDOWS = 0x00000080
2585 JOB_OBJECT_UILIMIT_GLOBALATOMS = 0x00000020
2586 JOB_OBJECT_UILIMIT_HANDLES = 0x00000001
2587 JOB_OBJECT_UILIMIT_READCLIPBOARD = 0x00000002
2588 JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS = 0x00000008
2589 JOB_OBJECT_UILIMIT_WRITECLIPBOARD = 0x00000004
2590 )
2591
2592 type JOBOBJECT_BASIC_UI_RESTRICTIONS struct {
2593 UIRestrictionsClass uint32
2594 }
2595
2596 const (
2597 // JobObjectInformationClass for QueryInformationJobObject and SetInformationJobObject
2598 JobObjectAssociateCompletionPortInformation = 7
2599 JobObjectBasicAccountingInformation = 1
2600 JobObjectBasicAndIoAccountingInformation = 8
2601 JobObjectBasicLimitInformation = 2
2602 JobObjectBasicProcessIdList = 3
2603 JobObjectBasicUIRestrictions = 4
2604 JobObjectCpuRateControlInformation = 15
2605 JobObjectEndOfJobTimeInformation = 6
2606 JobObjectExtendedLimitInformation = 9
2607 JobObjectGroupInformation = 11
2608 JobObjectGroupInformationEx = 14
2609 JobObjectLimitViolationInformation = 13
2610 JobObjectLimitViolationInformation2 = 34
2611 JobObjectNetRateControlInformation = 32
2612 JobObjectNotificationLimitInformation = 12
2613 JobObjectNotificationLimitInformation2 = 33
2614 JobObjectSecurityLimitInformation = 5
2615 )
2616
2617 const (
2618 KF_FLAG_DEFAULT = 0x00000000
2619 KF_FLAG_FORCE_APP_DATA_REDIRECTION = 0x00080000
2620 KF_FLAG_RETURN_FILTER_REDIRECTION_TARGET = 0x00040000
2621 KF_FLAG_FORCE_PACKAGE_REDIRECTION = 0x00020000
2622 KF_FLAG_NO_PACKAGE_REDIRECTION = 0x00010000
2623 KF_FLAG_FORCE_APPCONTAINER_REDIRECTION = 0x00020000
2624 KF_FLAG_NO_APPCONTAINER_REDIRECTION = 0x00010000
2625 KF_FLAG_CREATE = 0x00008000
2626 KF_FLAG_DONT_VERIFY = 0x00004000
2627 KF_FLAG_DONT_UNEXPAND = 0x00002000
2628 KF_FLAG_NO_ALIAS = 0x00001000
2629 KF_FLAG_INIT = 0x00000800
2630 KF_FLAG_DEFAULT_PATH = 0x00000400
2631 KF_FLAG_NOT_PARENT_RELATIVE = 0x00000200
2632 KF_FLAG_SIMPLE_IDLIST = 0x00000100
2633 KF_FLAG_ALIAS_ONLY = 0x80000000
2634 )
2635
2636 type OsVersionInfoEx struct {
2637 osVersionInfoSize uint32
2638 MajorVersion uint32
2639 MinorVersion uint32
2640 BuildNumber uint32
2641 PlatformId uint32
2642 CsdVersion [128]uint16
2643 ServicePackMajor uint16
2644 ServicePackMinor uint16
2645 SuiteMask uint16
2646 ProductType byte
2647 _ byte
2648 }
2649
2650 const (
2651 EWX_LOGOFF = 0x00000000
2652 EWX_SHUTDOWN = 0x00000001
2653 EWX_REBOOT = 0x00000002
2654 EWX_FORCE = 0x00000004
2655 EWX_POWEROFF = 0x00000008
2656 EWX_FORCEIFHUNG = 0x00000010
2657 EWX_QUICKRESOLVE = 0x00000020
2658 EWX_RESTARTAPPS = 0x00000040
2659 EWX_HYBRID_SHUTDOWN = 0x00400000
2660 EWX_BOOTOPTIONS = 0x01000000
2661
2662 SHTDN_REASON_FLAG_COMMENT_REQUIRED = 0x01000000
2663 SHTDN_REASON_FLAG_DIRTY_PROBLEM_ID_REQUIRED = 0x02000000
2664 SHTDN_REASON_FLAG_CLEAN_UI = 0x04000000
2665 SHTDN_REASON_FLAG_DIRTY_UI = 0x08000000
2666 SHTDN_REASON_FLAG_USER_DEFINED = 0x40000000
2667 SHTDN_REASON_FLAG_PLANNED = 0x80000000
2668 SHTDN_REASON_MAJOR_OTHER = 0x00000000
2669 SHTDN_REASON_MAJOR_NONE = 0x00000000
2670 SHTDN_REASON_MAJOR_HARDWARE = 0x00010000
2671 SHTDN_REASON_MAJOR_OPERATINGSYSTEM = 0x00020000
2672 SHTDN_REASON_MAJOR_SOFTWARE = 0x00030000
2673 SHTDN_REASON_MAJOR_APPLICATION = 0x00040000
2674 SHTDN_REASON_MAJOR_SYSTEM = 0x00050000
2675 SHTDN_REASON_MAJOR_POWER = 0x00060000
2676 SHTDN_REASON_MAJOR_LEGACY_API = 0x00070000
2677 SHTDN_REASON_MINOR_OTHER = 0x00000000
2678 SHTDN_REASON_MINOR_NONE = 0x000000ff
2679 SHTDN_REASON_MINOR_MAINTENANCE = 0x00000001
2680 SHTDN_REASON_MINOR_INSTALLATION = 0x00000002
2681 SHTDN_REASON_MINOR_UPGRADE = 0x00000003
2682 SHTDN_REASON_MINOR_RECONFIG = 0x00000004
2683 SHTDN_REASON_MINOR_HUNG = 0x00000005
2684 SHTDN_REASON_MINOR_UNSTABLE = 0x00000006
2685 SHTDN_REASON_MINOR_DISK = 0x00000007
2686 SHTDN_REASON_MINOR_PROCESSOR = 0x00000008
2687 SHTDN_REASON_MINOR_NETWORKCARD = 0x00000009
2688 SHTDN_REASON_MINOR_POWER_SUPPLY = 0x0000000a
2689 SHTDN_REASON_MINOR_CORDUNPLUGGED = 0x0000000b
2690 SHTDN_REASON_MINOR_ENVIRONMENT = 0x0000000c
2691 SHTDN_REASON_MINOR_HARDWARE_DRIVER = 0x0000000d
2692 SHTDN_REASON_MINOR_OTHERDRIVER = 0x0000000e
2693 SHTDN_REASON_MINOR_BLUESCREEN = 0x0000000F
2694 SHTDN_REASON_MINOR_SERVICEPACK = 0x00000010
2695 SHTDN_REASON_MINOR_HOTFIX = 0x00000011
2696 SHTDN_REASON_MINOR_SECURITYFIX = 0x00000012
2697 SHTDN_REASON_MINOR_SECURITY = 0x00000013
2698 SHTDN_REASON_MINOR_NETWORK_CONNECTIVITY = 0x00000014
2699 SHTDN_REASON_MINOR_WMI = 0x00000015
2700 SHTDN_REASON_MINOR_SERVICEPACK_UNINSTALL = 0x00000016
2701 SHTDN_REASON_MINOR_HOTFIX_UNINSTALL = 0x00000017
2702 SHTDN_REASON_MINOR_SECURITYFIX_UNINSTALL = 0x00000018
2703 SHTDN_REASON_MINOR_MMC = 0x00000019
2704 SHTDN_REASON_MINOR_SYSTEMRESTORE = 0x0000001a
2705 SHTDN_REASON_MINOR_TERMSRV = 0x00000020
2706 SHTDN_REASON_MINOR_DC_PROMOTION = 0x00000021
2707 SHTDN_REASON_MINOR_DC_DEMOTION = 0x00000022
2708 SHTDN_REASON_UNKNOWN = SHTDN_REASON_MINOR_NONE
2709 SHTDN_REASON_LEGACY_API = SHTDN_REASON_MAJOR_LEGACY_API | SHTDN_REASON_FLAG_PLANNED
2710 SHTDN_REASON_VALID_BIT_MASK = 0xc0ffffff
2711
2712 SHUTDOWN_NORETRY = 0x1
2713 )
2714
2715 // Flags used for GetModuleHandleEx
2716 const (
2717 GET_MODULE_HANDLE_EX_FLAG_PIN = 1
2718 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2
2719 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 4
2720 )
2721
2722 // MUI function flag values
2723 const (
2724 MUI_LANGUAGE_ID = 0x4
2725 MUI_LANGUAGE_NAME = 0x8
2726 MUI_MERGE_SYSTEM_FALLBACK = 0x10
2727 MUI_MERGE_USER_FALLBACK = 0x20
2728 MUI_UI_FALLBACK = MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK
2729 MUI_THREAD_LANGUAGES = 0x40
2730 MUI_CONSOLE_FILTER = 0x100
2731 MUI_COMPLEX_SCRIPT_FILTER = 0x200
2732 MUI_RESET_FILTERS = 0x001
2733 MUI_USER_PREFERRED_UI_LANGUAGES = 0x10
2734 MUI_USE_INSTALLED_LANGUAGES = 0x20
2735 MUI_USE_SEARCH_ALL_LANGUAGES = 0x40
2736 MUI_LANG_NEUTRAL_PE_FILE = 0x100
2737 MUI_NON_LANG_NEUTRAL_FILE = 0x200
2738 MUI_MACHINE_LANGUAGE_SETTINGS = 0x400
2739 MUI_FILETYPE_NOT_LANGUAGE_NEUTRAL = 0x001
2740 MUI_FILETYPE_LANGUAGE_NEUTRAL_MAIN = 0x002
2741 MUI_FILETYPE_LANGUAGE_NEUTRAL_MUI = 0x004
2742 MUI_QUERY_TYPE = 0x001
2743 MUI_QUERY_CHECKSUM = 0x002
2744 MUI_QUERY_LANGUAGE_NAME = 0x004
2745 MUI_QUERY_RESOURCE_TYPES = 0x008
2746 MUI_FILEINFO_VERSION = 0x001
2747
2748 MUI_FULL_LANGUAGE = 0x01
2749 MUI_PARTIAL_LANGUAGE = 0x02
2750 MUI_LIP_LANGUAGE = 0x04
2751 MUI_LANGUAGE_INSTALLED = 0x20
2752 MUI_LANGUAGE_LICENSED = 0x40
2753 )
2754
2755 // FILE_INFO_BY_HANDLE_CLASS constants for SetFileInformationByHandle/GetFileInformationByHandleEx
2756 const (
2757 FileBasicInfo = 0
2758 FileStandardInfo = 1
2759 FileNameInfo = 2
2760 FileRenameInfo = 3
2761 FileDispositionInfo = 4
2762 FileAllocationInfo = 5
2763 FileEndOfFileInfo = 6
2764 FileStreamInfo = 7
2765 FileCompressionInfo = 8
2766 FileAttributeTagInfo = 9
2767 FileIdBothDirectoryInfo = 10
2768 FileIdBothDirectoryRestartInfo = 11
2769 FileIoPriorityHintInfo = 12
2770 FileRemoteProtocolInfo = 13
2771 FileFullDirectoryInfo = 14
2772 FileFullDirectoryRestartInfo = 15
2773 FileStorageInfo = 16
2774 FileAlignmentInfo = 17
2775 FileIdInfo = 18
2776 FileIdExtdDirectoryInfo = 19
2777 FileIdExtdDirectoryRestartInfo = 20
2778 FileDispositionInfoEx = 21
2779 FileRenameInfoEx = 22
2780 FileCaseSensitiveInfo = 23
2781 FileNormalizedNameInfo = 24
2782 )
2783
2784 // LoadLibrary flags for determining from where to search for a DLL
2785 const (
2786 DONT_RESOLVE_DLL_REFERENCES = 0x1
2787 LOAD_LIBRARY_AS_DATAFILE = 0x2
2788 LOAD_WITH_ALTERED_SEARCH_PATH = 0x8
2789 LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x10
2790 LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x20
2791 LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x40
2792 LOAD_LIBRARY_REQUIRE_SIGNED_TARGET = 0x80
2793 LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR = 0x100
2794 LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x200
2795 LOAD_LIBRARY_SEARCH_USER_DIRS = 0x400
2796 LOAD_LIBRARY_SEARCH_SYSTEM32 = 0x800
2797 LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x1000
2798 LOAD_LIBRARY_SAFE_CURRENT_DIRS = 0x00002000
2799 LOAD_LIBRARY_SEARCH_SYSTEM32_NO_FORWARDER = 0x00004000
2800 LOAD_LIBRARY_OS_INTEGRITY_CONTINUITY = 0x00008000
2801 )
2802
2803 // RegNotifyChangeKeyValue notifyFilter flags.
2804 const (
2805 // REG_NOTIFY_CHANGE_NAME notifies the caller if a subkey is added or deleted.
2806 REG_NOTIFY_CHANGE_NAME = 0x00000001
2807
2808 // REG_NOTIFY_CHANGE_ATTRIBUTES notifies the caller of changes to the attributes of the key, such as the security descriptor information.
2809 REG_NOTIFY_CHANGE_ATTRIBUTES = 0x00000002
2810
2811 // 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.
2812 REG_NOTIFY_CHANGE_LAST_SET = 0x00000004
2813
2814 // REG_NOTIFY_CHANGE_SECURITY notifies the caller of changes to the security descriptor of the key.
2815 REG_NOTIFY_CHANGE_SECURITY = 0x00000008
2816
2817 // 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.
2818 REG_NOTIFY_THREAD_AGNOSTIC = 0x10000000
2819 )
2820
2821 type CommTimeouts struct {
2822 ReadIntervalTimeout uint32
2823 ReadTotalTimeoutMultiplier uint32
2824 ReadTotalTimeoutConstant uint32
2825 WriteTotalTimeoutMultiplier uint32
2826 WriteTotalTimeoutConstant uint32
2827 }
2828
2829 // NTUnicodeString is a UTF-16 string for NT native APIs, corresponding to UNICODE_STRING.
2830 type NTUnicodeString struct {
2831 // Note: Length and MaximumLength are in *bytes*, not uint16s.
2832 // They should always be even.
2833 Length uint16
2834 MaximumLength uint16
2835 Buffer *uint16
2836 }
2837
2838 // NTString is an ANSI string for NT native APIs, corresponding to STRING.
2839 type NTString struct {
2840 Length uint16
2841 MaximumLength uint16
2842 Buffer *byte
2843 }
2844
2845 type LIST_ENTRY struct {
2846 Flink *LIST_ENTRY
2847 Blink *LIST_ENTRY
2848 }
2849
2850 type RUNTIME_FUNCTION struct {
2851 BeginAddress uint32
2852 EndAddress uint32
2853 UnwindData uint32
2854 }
2855
2856 type LDR_DATA_TABLE_ENTRY struct {
2857 reserved1 [2]uintptr
2858 InMemoryOrderLinks LIST_ENTRY
2859 reserved2 [2]uintptr
2860 DllBase uintptr
2861 reserved3 [2]uintptr
2862 FullDllName NTUnicodeString
2863 reserved4 [8]byte
2864 reserved5 [3]uintptr
2865 reserved6 uintptr
2866 TimeDateStamp uint32
2867 }
2868
2869 type PEB_LDR_DATA struct {
2870 reserved1 [8]byte
2871 reserved2 [3]uintptr
2872 InMemoryOrderModuleList LIST_ENTRY
2873 }
2874
2875 type CURDIR struct {
2876 DosPath NTUnicodeString
2877 Handle Handle
2878 }
2879
2880 type RTL_DRIVE_LETTER_CURDIR struct {
2881 Flags uint16
2882 Length uint16
2883 TimeStamp uint32
2884 DosPath NTString
2885 }
2886
2887 type RTL_USER_PROCESS_PARAMETERS struct {
2888 MaximumLength, Length uint32
2889
2890 Flags, DebugFlags uint32
2891
2892 ConsoleHandle Handle
2893 ConsoleFlags uint32
2894 StandardInput, StandardOutput, StandardError Handle
2895
2896 CurrentDirectory CURDIR
2897 DllPath NTUnicodeString
2898 ImagePathName NTUnicodeString
2899 CommandLine NTUnicodeString
2900 Environment unsafe.Pointer
2901
2902 StartingX, StartingY, CountX, CountY, CountCharsX, CountCharsY, FillAttribute uint32
2903
2904 WindowFlags, ShowWindowFlags uint32
2905 WindowTitle, DesktopInfo, ShellInfo, RuntimeData NTUnicodeString
2906 CurrentDirectories [32]RTL_DRIVE_LETTER_CURDIR
2907
2908 EnvironmentSize, EnvironmentVersion uintptr
2909
2910 PackageDependencyData unsafe.Pointer
2911 ProcessGroupId uint32
2912 LoaderThreads uint32
2913
2914 RedirectionDllName NTUnicodeString
2915 HeapPartitionName NTUnicodeString
2916 DefaultThreadpoolCpuSetMasks uintptr
2917 DefaultThreadpoolCpuSetMaskCount uint32
2918 }
2919
2920 type PEB struct {
2921 reserved1 [2]byte
2922 BeingDebugged byte
2923 BitField byte
2924 reserved3 uintptr
2925 ImageBaseAddress uintptr
2926 Ldr *PEB_LDR_DATA
2927 ProcessParameters *RTL_USER_PROCESS_PARAMETERS
2928 reserved4 [3]uintptr
2929 AtlThunkSListPtr uintptr
2930 reserved5 uintptr
2931 reserved6 uint32
2932 reserved7 uintptr
2933 reserved8 uint32
2934 AtlThunkSListPtr32 uint32
2935 reserved9 [45]uintptr
2936 reserved10 [96]byte
2937 PostProcessInitRoutine uintptr
2938 reserved11 [128]byte
2939 reserved12 [1]uintptr
2940 SessionId uint32
2941 }
2942
2943 type OBJECT_ATTRIBUTES struct {
2944 Length uint32
2945 RootDirectory Handle
2946 ObjectName *NTUnicodeString
2947 Attributes uint32
2948 SecurityDescriptor *SECURITY_DESCRIPTOR
2949 SecurityQoS *SECURITY_QUALITY_OF_SERVICE
2950 }
2951
2952 // Values for the Attributes member of OBJECT_ATTRIBUTES.
2953 const (
2954 OBJ_INHERIT = 0x00000002
2955 OBJ_PERMANENT = 0x00000010
2956 OBJ_EXCLUSIVE = 0x00000020
2957 OBJ_CASE_INSENSITIVE = 0x00000040
2958 OBJ_OPENIF = 0x00000080
2959 OBJ_OPENLINK = 0x00000100
2960 OBJ_KERNEL_HANDLE = 0x00000200
2961 OBJ_FORCE_ACCESS_CHECK = 0x00000400
2962 OBJ_IGNORE_IMPERSONATED_DEVICEMAP = 0x00000800
2963 OBJ_DONT_REPARSE = 0x00001000
2964 OBJ_VALID_ATTRIBUTES = 0x00001FF2
2965 )
2966
2967 type IO_STATUS_BLOCK struct {
2968 Status NTStatus
2969 Information uintptr
2970 }
2971
2972 type RTLP_CURDIR_REF struct {
2973 RefCount int32
2974 Handle Handle
2975 }
2976
2977 type RTL_RELATIVE_NAME struct {
2978 RelativeName NTUnicodeString
2979 ContainingDirectory Handle
2980 CurDirRef *RTLP_CURDIR_REF
2981 }
2982
2983 const (
2984 // CreateDisposition flags for NtCreateFile and NtCreateNamedPipeFile.
2985 FILE_SUPERSEDE = 0x00000000
2986 FILE_OPEN = 0x00000001
2987 FILE_CREATE = 0x00000002
2988 FILE_OPEN_IF = 0x00000003
2989 FILE_OVERWRITE = 0x00000004
2990 FILE_OVERWRITE_IF = 0x00000005
2991 FILE_MAXIMUM_DISPOSITION = 0x00000005
2992
2993 // CreateOptions flags for NtCreateFile and NtCreateNamedPipeFile.
2994 FILE_DIRECTORY_FILE = 0x00000001
2995 FILE_WRITE_THROUGH = 0x00000002
2996 FILE_SEQUENTIAL_ONLY = 0x00000004
2997 FILE_NO_INTERMEDIATE_BUFFERING = 0x00000008
2998 FILE_SYNCHRONOUS_IO_ALERT = 0x00000010
2999 FILE_SYNCHRONOUS_IO_NONALERT = 0x00000020
3000 FILE_NON_DIRECTORY_FILE = 0x00000040
3001 FILE_CREATE_TREE_CONNECTION = 0x00000080
3002 FILE_COMPLETE_IF_OPLOCKED = 0x00000100
3003 FILE_NO_EA_KNOWLEDGE = 0x00000200
3004 FILE_OPEN_REMOTE_INSTANCE = 0x00000400
3005 FILE_RANDOM_ACCESS = 0x00000800
3006 FILE_DELETE_ON_CLOSE = 0x00001000
3007 FILE_OPEN_BY_FILE_ID = 0x00002000
3008 FILE_OPEN_FOR_BACKUP_INTENT = 0x00004000
3009 FILE_NO_COMPRESSION = 0x00008000
3010 FILE_OPEN_REQUIRING_OPLOCK = 0x00010000
3011 FILE_DISALLOW_EXCLUSIVE = 0x00020000
3012 FILE_RESERVE_OPFILTER = 0x00100000
3013 FILE_OPEN_REPARSE_POINT = 0x00200000
3014 FILE_OPEN_NO_RECALL = 0x00400000
3015 FILE_OPEN_FOR_FREE_SPACE_QUERY = 0x00800000
3016
3017 // Parameter constants for NtCreateNamedPipeFile.
3018
3019 FILE_PIPE_BYTE_STREAM_TYPE = 0x00000000
3020 FILE_PIPE_MESSAGE_TYPE = 0x00000001
3021
3022 FILE_PIPE_ACCEPT_REMOTE_CLIENTS = 0x00000000
3023 FILE_PIPE_REJECT_REMOTE_CLIENTS = 0x00000002
3024
3025 FILE_PIPE_TYPE_VALID_MASK = 0x00000003
3026
3027 FILE_PIPE_BYTE_STREAM_MODE = 0x00000000
3028 FILE_PIPE_MESSAGE_MODE = 0x00000001
3029
3030 FILE_PIPE_QUEUE_OPERATION = 0x00000000
3031 FILE_PIPE_COMPLETE_OPERATION = 0x00000001
3032
3033 FILE_PIPE_INBOUND = 0x00000000
3034 FILE_PIPE_OUTBOUND = 0x00000001
3035 FILE_PIPE_FULL_DUPLEX = 0x00000002
3036
3037 FILE_PIPE_DISCONNECTED_STATE = 0x00000001
3038 FILE_PIPE_LISTENING_STATE = 0x00000002
3039 FILE_PIPE_CONNECTED_STATE = 0x00000003
3040 FILE_PIPE_CLOSING_STATE = 0x00000004
3041
3042 FILE_PIPE_CLIENT_END = 0x00000000
3043 FILE_PIPE_SERVER_END = 0x00000001
3044 )
3045
3046 const (
3047 // FileInformationClass for NtSetInformationFile/NtQueryInformationFile, see
3048 // https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/ne-wdm-_file_information_class
3049 FileBasicInformation = 4
3050 FileEaInformation = 7
3051 FileRenameInformation = 10
3052 FileDispositionInformation = 13
3053 FilePositionInformation = 14
3054 FileEndOfFileInformation = 20
3055 FileValidDataLengthInformation = 39
3056 FileShortNameInformation = 40
3057 FileIoPriorityHintInformation = 43
3058 FileReplaceCompletionInformation = 61
3059 FileDispositionInformationEx = 64
3060 FileCaseSensitiveInformation = 71
3061 FileLinkInformation = 72
3062 FileCaseSensitiveInformationForceAccessCheck = 75
3063 FileKnownFolderInformation = 76
3064
3065 // Flags for FILE_RENAME_INFORMATION
3066 FILE_RENAME_REPLACE_IF_EXISTS = 0x00000001
3067 FILE_RENAME_POSIX_SEMANTICS = 0x00000002
3068 FILE_RENAME_SUPPRESS_PIN_STATE_INHERITANCE = 0x00000004
3069 FILE_RENAME_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008
3070 FILE_RENAME_NO_INCREASE_AVAILABLE_SPACE = 0x00000010
3071 FILE_RENAME_NO_DECREASE_AVAILABLE_SPACE = 0x00000020
3072 FILE_RENAME_PRESERVE_AVAILABLE_SPACE = 0x00000030
3073 FILE_RENAME_IGNORE_READONLY_ATTRIBUTE = 0x00000040
3074 FILE_RENAME_FORCE_RESIZE_TARGET_SR = 0x00000080
3075 FILE_RENAME_FORCE_RESIZE_SOURCE_SR = 0x00000100
3076 FILE_RENAME_FORCE_RESIZE_SR = 0x00000180
3077
3078 // Flags for FILE_DISPOSITION_INFORMATION_EX
3079 FILE_DISPOSITION_DO_NOT_DELETE = 0x00000000
3080 FILE_DISPOSITION_DELETE = 0x00000001
3081 FILE_DISPOSITION_POSIX_SEMANTICS = 0x00000002
3082 FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK = 0x00000004
3083 FILE_DISPOSITION_ON_CLOSE = 0x00000008
3084 FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE = 0x00000010
3085
3086 // Flags for FILE_CASE_SENSITIVE_INFORMATION
3087 FILE_CS_FLAG_CASE_SENSITIVE_DIR = 0x00000001
3088
3089 // Flags for FILE_LINK_INFORMATION
3090 FILE_LINK_REPLACE_IF_EXISTS = 0x00000001
3091 FILE_LINK_POSIX_SEMANTICS = 0x00000002
3092 FILE_LINK_SUPPRESS_STORAGE_RESERVE_INHERITANCE = 0x00000008
3093 FILE_LINK_NO_INCREASE_AVAILABLE_SPACE = 0x00000010
3094 FILE_LINK_NO_DECREASE_AVAILABLE_SPACE = 0x00000020
3095 FILE_LINK_PRESERVE_AVAILABLE_SPACE = 0x00000030
3096 FILE_LINK_IGNORE_READONLY_ATTRIBUTE = 0x00000040
3097 FILE_LINK_FORCE_RESIZE_TARGET_SR = 0x00000080
3098 FILE_LINK_FORCE_RESIZE_SOURCE_SR = 0x00000100
3099 FILE_LINK_FORCE_RESIZE_SR = 0x00000180
3100 )
3101
3102 // ProcessInformationClasses for NtQueryInformationProcess and NtSetInformationProcess.
3103 const (
3104 ProcessBasicInformation = iota
3105 ProcessQuotaLimits
3106 ProcessIoCounters
3107 ProcessVmCounters
3108 ProcessTimes
3109 ProcessBasePriority
3110 ProcessRaisePriority
3111 ProcessDebugPort
3112 ProcessExceptionPort
3113 ProcessAccessToken
3114 ProcessLdtInformation
3115 ProcessLdtSize
3116 ProcessDefaultHardErrorMode
3117 ProcessIoPortHandlers
3118 ProcessPooledUsageAndLimits
3119 ProcessWorkingSetWatch
3120 ProcessUserModeIOPL
3121 ProcessEnableAlignmentFaultFixup
3122 ProcessPriorityClass
3123 ProcessWx86Information
3124 ProcessHandleCount
3125 ProcessAffinityMask
3126 ProcessPriorityBoost
3127 ProcessDeviceMap
3128 ProcessSessionInformation
3129 ProcessForegroundInformation
3130 ProcessWow64Information
3131 ProcessImageFileName
3132 ProcessLUIDDeviceMapsEnabled
3133 ProcessBreakOnTermination
3134 ProcessDebugObjectHandle
3135 ProcessDebugFlags
3136 ProcessHandleTracing
3137 ProcessIoPriority
3138 ProcessExecuteFlags
3139 ProcessTlsInformation
3140 ProcessCookie
3141 ProcessImageInformation
3142 ProcessCycleTime
3143 ProcessPagePriority
3144 ProcessInstrumentationCallback
3145 ProcessThreadStackAllocation
3146 ProcessWorkingSetWatchEx
3147 ProcessImageFileNameWin32
3148 ProcessImageFileMapping
3149 ProcessAffinityUpdateMode
3150 ProcessMemoryAllocationMode
3151 ProcessGroupInformation
3152 ProcessTokenVirtualizationEnabled
3153 ProcessConsoleHostProcess
3154 ProcessWindowInformation
3155 ProcessHandleInformation
3156 ProcessMitigationPolicy
3157 ProcessDynamicFunctionTableInformation
3158 ProcessHandleCheckingMode
3159 ProcessKeepAliveCount
3160 ProcessRevokeFileHandles
3161 ProcessWorkingSetControl
3162 ProcessHandleTable
3163 ProcessCheckStackExtentsMode
3164 ProcessCommandLineInformation
3165 ProcessProtectionInformation
3166 ProcessMemoryExhaustion
3167 ProcessFaultInformation
3168 ProcessTelemetryIdInformation
3169 ProcessCommitReleaseInformation
3170 ProcessDefaultCpuSetsInformation
3171 ProcessAllowedCpuSetsInformation
3172 ProcessSubsystemProcess
3173 ProcessJobMemoryInformation
3174 ProcessInPrivate
3175 ProcessRaiseUMExceptionOnInvalidHandleClose
3176 ProcessIumChallengeResponse
3177 ProcessChildProcessInformation
3178 ProcessHighGraphicsPriorityInformation
3179 ProcessSubsystemInformation
3180 ProcessEnergyValues
3181 ProcessActivityThrottleState
3182 ProcessActivityThrottlePolicy
3183 ProcessWin32kSyscallFilterInformation
3184 ProcessDisableSystemAllowedCpuSets
3185 ProcessWakeInformation
3186 ProcessEnergyTrackingState
3187 ProcessManageWritesToExecutableMemory
3188 ProcessCaptureTrustletLiveDump
3189 ProcessTelemetryCoverage
3190 ProcessEnclaveInformation
3191 ProcessEnableReadWriteVmLogging
3192 ProcessUptimeInformation
3193 ProcessImageSection
3194 ProcessDebugAuthInformation
3195 ProcessSystemResourceManagement
3196 ProcessSequenceNumber
3197 ProcessLoaderDetour
3198 ProcessSecurityDomainInformation
3199 ProcessCombineSecurityDomainsInformation
3200 ProcessEnableLogging
3201 ProcessLeapSecondInformation
3202 ProcessFiberShadowStackAllocation
3203 ProcessFreeFiberShadowStackAllocation
3204 ProcessAltSystemCallInformation
3205 ProcessDynamicEHContinuationTargets
3206 ProcessDynamicEnforcedCetCompatibleRanges
3207 )
3208
3209 type PROCESS_BASIC_INFORMATION struct {
3210 ExitStatus NTStatus
3211 PebBaseAddress *PEB
3212 AffinityMask uintptr
3213 BasePriority int32
3214 UniqueProcessId uintptr
3215 InheritedFromUniqueProcessId uintptr
3216 }
3217
3218 type SYSTEM_PROCESS_INFORMATION struct {
3219 NextEntryOffset uint32
3220 NumberOfThreads uint32
3221 WorkingSetPrivateSize int64
3222 HardFaultCount uint32
3223 NumberOfThreadsHighWatermark uint32
3224 CycleTime uint64
3225 CreateTime int64
3226 UserTime int64
3227 KernelTime int64
3228 ImageName NTUnicodeString
3229 BasePriority int32
3230 UniqueProcessID uintptr
3231 InheritedFromUniqueProcessID uintptr
3232 HandleCount uint32
3233 SessionID uint32
3234 UniqueProcessKey *uint32
3235 PeakVirtualSize uintptr
3236 VirtualSize uintptr
3237 PageFaultCount uint32
3238 PeakWorkingSetSize uintptr
3239 WorkingSetSize uintptr
3240 QuotaPeakPagedPoolUsage uintptr
3241 QuotaPagedPoolUsage uintptr
3242 QuotaPeakNonPagedPoolUsage uintptr
3243 QuotaNonPagedPoolUsage uintptr
3244 PagefileUsage uintptr
3245 PeakPagefileUsage uintptr
3246 PrivatePageCount uintptr
3247 ReadOperationCount int64
3248 WriteOperationCount int64
3249 OtherOperationCount int64
3250 ReadTransferCount int64
3251 WriteTransferCount int64
3252 OtherTransferCount int64
3253 }
3254
3255 // SystemInformationClasses for NtQuerySystemInformation and NtSetSystemInformation
3256 const (
3257 SystemBasicInformation = iota
3258 SystemProcessorInformation
3259 SystemPerformanceInformation
3260 SystemTimeOfDayInformation
3261 SystemPathInformation
3262 SystemProcessInformation
3263 SystemCallCountInformation
3264 SystemDeviceInformation
3265 SystemProcessorPerformanceInformation
3266 SystemFlagsInformation
3267 SystemCallTimeInformation
3268 SystemModuleInformation
3269 SystemLocksInformation
3270 SystemStackTraceInformation
3271 SystemPagedPoolInformation
3272 SystemNonPagedPoolInformation
3273 SystemHandleInformation
3274 SystemObjectInformation
3275 SystemPageFileInformation
3276 SystemVdmInstemulInformation
3277 SystemVdmBopInformation
3278 SystemFileCacheInformation
3279 SystemPoolTagInformation
3280 SystemInterruptInformation
3281 SystemDpcBehaviorInformation
3282 SystemFullMemoryInformation
3283 SystemLoadGdiDriverInformation
3284 SystemUnloadGdiDriverInformation
3285 SystemTimeAdjustmentInformation
3286 SystemSummaryMemoryInformation
3287 SystemMirrorMemoryInformation
3288 SystemPerformanceTraceInformation
3289 systemObsolete0
3290 SystemExceptionInformation
3291 SystemCrashDumpStateInformation
3292 SystemKernelDebuggerInformation
3293 SystemContextSwitchInformation
3294 SystemRegistryQuotaInformation
3295 SystemExtendServiceTableInformation
3296 SystemPrioritySeperation
3297 SystemVerifierAddDriverInformation
3298 SystemVerifierRemoveDriverInformation
3299 SystemProcessorIdleInformation
3300 SystemLegacyDriverInformation
3301 SystemCurrentTimeZoneInformation
3302 SystemLookasideInformation
3303 SystemTimeSlipNotification
3304 SystemSessionCreate
3305 SystemSessionDetach
3306 SystemSessionInformation
3307 SystemRangeStartInformation
3308 SystemVerifierInformation
3309 SystemVerifierThunkExtend
3310 SystemSessionProcessInformation
3311 SystemLoadGdiDriverInSystemSpace
3312 SystemNumaProcessorMap
3313 SystemPrefetcherInformation
3314 SystemExtendedProcessInformation
3315 SystemRecommendedSharedDataAlignment
3316 SystemComPlusPackage
3317 SystemNumaAvailableMemory
3318 SystemProcessorPowerInformation
3319 SystemEmulationBasicInformation
3320 SystemEmulationProcessorInformation
3321 SystemExtendedHandleInformation
3322 SystemLostDelayedWriteInformation
3323 SystemBigPoolInformation
3324 SystemSessionPoolTagInformation
3325 SystemSessionMappedViewInformation
3326 SystemHotpatchInformation
3327 SystemObjectSecurityMode
3328 SystemWatchdogTimerHandler
3329 SystemWatchdogTimerInformation
3330 SystemLogicalProcessorInformation
3331 SystemWow64SharedInformationObsolete
3332 SystemRegisterFirmwareTableInformationHandler
3333 SystemFirmwareTableInformation
3334 SystemModuleInformationEx
3335 SystemVerifierTriageInformation
3336 SystemSuperfetchInformation
3337 SystemMemoryListInformation
3338 SystemFileCacheInformationEx
3339 SystemThreadPriorityClientIdInformation
3340 SystemProcessorIdleCycleTimeInformation
3341 SystemVerifierCancellationInformation
3342 SystemProcessorPowerInformationEx
3343 SystemRefTraceInformation
3344 SystemSpecialPoolInformation
3345 SystemProcessIdInformation
3346 SystemErrorPortInformation
3347 SystemBootEnvironmentInformation
3348 SystemHypervisorInformation
3349 SystemVerifierInformationEx
3350 SystemTimeZoneInformation
3351 SystemImageFileExecutionOptionsInformation
3352 SystemCoverageInformation
3353 SystemPrefetchPatchInformation
3354 SystemVerifierFaultsInformation
3355 SystemSystemPartitionInformation
3356 SystemSystemDiskInformation
3357 SystemProcessorPerformanceDistribution
3358 SystemNumaProximityNodeInformation
3359 SystemDynamicTimeZoneInformation
3360 SystemCodeIntegrityInformation
3361 SystemProcessorMicrocodeUpdateInformation
3362 SystemProcessorBrandString
3363 SystemVirtualAddressInformation
3364 SystemLogicalProcessorAndGroupInformation
3365 SystemProcessorCycleTimeInformation
3366 SystemStoreInformation
3367 SystemRegistryAppendString
3368 SystemAitSamplingValue
3369 SystemVhdBootInformation
3370 SystemCpuQuotaInformation
3371 SystemNativeBasicInformation
3372 systemSpare1
3373 SystemLowPriorityIoInformation
3374 SystemTpmBootEntropyInformation
3375 SystemVerifierCountersInformation
3376 SystemPagedPoolInformationEx
3377 SystemSystemPtesInformationEx
3378 SystemNodeDistanceInformation
3379 SystemAcpiAuditInformation
3380 SystemBasicPerformanceInformation
3381 SystemQueryPerformanceCounterInformation
3382 SystemSessionBigPoolInformation
3383 SystemBootGraphicsInformation
3384 SystemScrubPhysicalMemoryInformation
3385 SystemBadPageInformation
3386 SystemProcessorProfileControlArea
3387 SystemCombinePhysicalMemoryInformation
3388 SystemEntropyInterruptTimingCallback
3389 SystemConsoleInformation
3390 SystemPlatformBinaryInformation
3391 SystemThrottleNotificationInformation
3392 SystemHypervisorProcessorCountInformation
3393 SystemDeviceDataInformation
3394 SystemDeviceDataEnumerationInformation
3395 SystemMemoryTopologyInformation
3396 SystemMemoryChannelInformation
3397 SystemBootLogoInformation
3398 SystemProcessorPerformanceInformationEx
3399 systemSpare0
3400 SystemSecureBootPolicyInformation
3401 SystemPageFileInformationEx
3402 SystemSecureBootInformation
3403 SystemEntropyInterruptTimingRawInformation
3404 SystemPortableWorkspaceEfiLauncherInformation
3405 SystemFullProcessInformation
3406 SystemKernelDebuggerInformationEx
3407 SystemBootMetadataInformation
3408 SystemSoftRebootInformation
3409 SystemElamCertificateInformation
3410 SystemOfflineDumpConfigInformation
3411 SystemProcessorFeaturesInformation
3412 SystemRegistryReconciliationInformation
3413 SystemEdidInformation
3414 SystemManufacturingInformation
3415 SystemEnergyEstimationConfigInformation
3416 SystemHypervisorDetailInformation
3417 SystemProcessorCycleStatsInformation
3418 SystemVmGenerationCountInformation
3419 SystemTrustedPlatformModuleInformation
3420 SystemKernelDebuggerFlags
3421 SystemCodeIntegrityPolicyInformation
3422 SystemIsolatedUserModeInformation
3423 SystemHardwareSecurityTestInterfaceResultsInformation
3424 SystemSingleModuleInformation
3425 SystemAllowedCpuSetsInformation
3426 SystemDmaProtectionInformation
3427 SystemInterruptCpuSetsInformation
3428 SystemSecureBootPolicyFullInformation
3429 SystemCodeIntegrityPolicyFullInformation
3430 SystemAffinitizedInterruptProcessorInformation
3431 SystemRootSiloInformation
3432 )
3433
3434 type RTL_PROCESS_MODULE_INFORMATION struct {
3435 Section Handle
3436 MappedBase uintptr
3437 ImageBase uintptr
3438 ImageSize uint32
3439 Flags uint32
3440 LoadOrderIndex uint16
3441 InitOrderIndex uint16
3442 LoadCount uint16
3443 OffsetToFileName uint16
3444 FullPathName [256]byte
3445 }
3446
3447 type RTL_PROCESS_MODULES struct {
3448 NumberOfModules uint32
3449 Modules [1]RTL_PROCESS_MODULE_INFORMATION
3450 }
3451
3452 // Constants for LocalAlloc flags.
3453 const (
3454 LMEM_FIXED = 0x0
3455 LMEM_MOVEABLE = 0x2
3456 LMEM_NOCOMPACT = 0x10
3457 LMEM_NODISCARD = 0x20
3458 LMEM_ZEROINIT = 0x40
3459 LMEM_MODIFY = 0x80
3460 LMEM_DISCARDABLE = 0xf00
3461 LMEM_VALID_FLAGS = 0xf72
3462 LMEM_INVALID_HANDLE = 0x8000
3463 LHND = LMEM_MOVEABLE | LMEM_ZEROINIT
3464 LPTR = LMEM_FIXED | LMEM_ZEROINIT
3465 NONZEROLHND = LMEM_MOVEABLE
3466 NONZEROLPTR = LMEM_FIXED
3467 )
3468
3469 // Constants for the CreateNamedPipe-family of functions.
3470 const (
3471 PIPE_ACCESS_INBOUND = 0x1
3472 PIPE_ACCESS_OUTBOUND = 0x2
3473 PIPE_ACCESS_DUPLEX = 0x3
3474
3475 PIPE_CLIENT_END = 0x0
3476 PIPE_SERVER_END = 0x1
3477
3478 PIPE_WAIT = 0x0
3479 PIPE_NOWAIT = 0x1
3480 PIPE_READMODE_BYTE = 0x0
3481 PIPE_READMODE_MESSAGE = 0x2
3482 PIPE_TYPE_BYTE = 0x0
3483 PIPE_TYPE_MESSAGE = 0x4
3484 PIPE_ACCEPT_REMOTE_CLIENTS = 0x0
3485 PIPE_REJECT_REMOTE_CLIENTS = 0x8
3486
3487 PIPE_UNLIMITED_INSTANCES = 255
3488 )
3489
3490 // Constants for security attributes when opening named pipes.
3491 const (
3492 SECURITY_ANONYMOUS = SecurityAnonymous << 16
3493 SECURITY_IDENTIFICATION = SecurityIdentification << 16
3494 SECURITY_IMPERSONATION = SecurityImpersonation << 16
3495 SECURITY_DELEGATION = SecurityDelegation << 16
3496
3497 SECURITY_CONTEXT_TRACKING = 0x40000
3498 SECURITY_EFFECTIVE_ONLY = 0x80000
3499
3500 SECURITY_SQOS_PRESENT = 0x100000
3501 SECURITY_VALID_SQOS_FLAGS = 0x1f0000
3502 )
3503
3504 // ResourceID represents a 16-bit resource identifier, traditionally created with the MAKEINTRESOURCE macro.
3505 type ResourceID uint16
3506
3507 // ResourceIDOrString must be either a ResourceID, to specify a resource or resource type by ID,
3508 // or a string, to specify a resource or resource type by name.
3509 type ResourceIDOrString interface{}
3510
3511 // Predefined resource names and types.
3512 var (
3513 // Predefined names.
3514 CREATEPROCESS_MANIFEST_RESOURCE_ID ResourceID = 1
3515 ISOLATIONAWARE_MANIFEST_RESOURCE_ID ResourceID = 2
3516 ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID ResourceID = 3
3517 ISOLATIONPOLICY_MANIFEST_RESOURCE_ID ResourceID = 4
3518 ISOLATIONPOLICY_BROWSER_MANIFEST_RESOURCE_ID ResourceID = 5
3519 MINIMUM_RESERVED_MANIFEST_RESOURCE_ID ResourceID = 1 // inclusive
3520 MAXIMUM_RESERVED_MANIFEST_RESOURCE_ID ResourceID = 16 // inclusive
3521
3522 // Predefined types.
3523 RT_CURSOR ResourceID = 1
3524 RT_BITMAP ResourceID = 2
3525 RT_ICON ResourceID = 3
3526 RT_MENU ResourceID = 4
3527 RT_DIALOG ResourceID = 5
3528 RT_STRING ResourceID = 6
3529 RT_FONTDIR ResourceID = 7
3530 RT_FONT ResourceID = 8
3531 RT_ACCELERATOR ResourceID = 9
3532 RT_RCDATA ResourceID = 10
3533 RT_MESSAGETABLE ResourceID = 11
3534 RT_GROUP_CURSOR ResourceID = 12
3535 RT_GROUP_ICON ResourceID = 14
3536 RT_VERSION ResourceID = 16
3537 RT_DLGINCLUDE ResourceID = 17
3538 RT_PLUGPLAY ResourceID = 19
3539 RT_VXD ResourceID = 20
3540 RT_ANICURSOR ResourceID = 21
3541 RT_ANIICON ResourceID = 22
3542 RT_HTML ResourceID = 23
3543 RT_MANIFEST ResourceID = 24
3544 )
3545
3546 type VS_FIXEDFILEINFO struct {
3547 Signature uint32
3548 StrucVersion uint32
3549 FileVersionMS uint32
3550 FileVersionLS uint32
3551 ProductVersionMS uint32
3552 ProductVersionLS uint32
3553 FileFlagsMask uint32
3554 FileFlags uint32
3555 FileOS uint32
3556 FileType uint32
3557 FileSubtype uint32
3558 FileDateMS uint32
3559 FileDateLS uint32
3560 }
3561
3562 type COAUTHIDENTITY struct {
3563 User *uint16
3564 UserLength uint32
3565 Domain *uint16
3566 DomainLength uint32
3567 Password *uint16
3568 PasswordLength uint32
3569 Flags uint32
3570 }
3571
3572 type COAUTHINFO struct {
3573 AuthnSvc uint32
3574 AuthzSvc uint32
3575 ServerPrincName *uint16
3576 AuthnLevel uint32
3577 ImpersonationLevel uint32
3578 AuthIdentityData *COAUTHIDENTITY
3579 Capabilities uint32
3580 }
3581
3582 type COSERVERINFO struct {
3583 Reserved1 uint32
3584 Aame *uint16
3585 AuthInfo *COAUTHINFO
3586 Reserved2 uint32
3587 }
3588
3589 type BIND_OPTS3 struct {
3590 CbStruct uint32
3591 Flags uint32
3592 Mode uint32
3593 TickCountDeadline uint32
3594 TrackFlags uint32
3595 ClassContext uint32
3596 Locale uint32
3597 ServerInfo *COSERVERINFO
3598 Hwnd HWND
3599 }
3600
3601 const (
3602 CLSCTX_INPROC_SERVER = 0x1
3603 CLSCTX_INPROC_HANDLER = 0x2
3604 CLSCTX_LOCAL_SERVER = 0x4
3605 CLSCTX_INPROC_SERVER16 = 0x8
3606 CLSCTX_REMOTE_SERVER = 0x10
3607 CLSCTX_INPROC_HANDLER16 = 0x20
3608 CLSCTX_RESERVED1 = 0x40
3609 CLSCTX_RESERVED2 = 0x80
3610 CLSCTX_RESERVED3 = 0x100
3611 CLSCTX_RESERVED4 = 0x200
3612 CLSCTX_NO_CODE_DOWNLOAD = 0x400
3613 CLSCTX_RESERVED5 = 0x800
3614 CLSCTX_NO_CUSTOM_MARSHAL = 0x1000
3615 CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000
3616 CLSCTX_NO_FAILURE_LOG = 0x4000
3617 CLSCTX_DISABLE_AAA = 0x8000
3618 CLSCTX_ENABLE_AAA = 0x10000
3619 CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000
3620 CLSCTX_ACTIVATE_32_BIT_SERVER = 0x40000
3621 CLSCTX_ACTIVATE_64_BIT_SERVER = 0x80000
3622 CLSCTX_ENABLE_CLOAKING = 0x100000
3623 CLSCTX_APPCONTAINER = 0x400000
3624 CLSCTX_ACTIVATE_AAA_AS_IU = 0x800000
3625 CLSCTX_PS_DLL = 0x80000000
3626
3627 COINIT_MULTITHREADED = 0x0
3628 COINIT_APARTMENTTHREADED = 0x2
3629 COINIT_DISABLE_OLE1DDE = 0x4
3630 COINIT_SPEED_OVER_MEMORY = 0x8
3631 )
3632
3633 // Flag for QueryFullProcessImageName.
3634 const PROCESS_NAME_NATIVE = 1
3635
3636 type ModuleInfo struct {
3637 BaseOfDll uintptr
3638 SizeOfImage uint32
3639 EntryPoint uintptr
3640 }
3641
3642 const ALL_PROCESSOR_GROUPS = 0xFFFF
3643
3644 type Rect struct {
3645 Left int32
3646 Top int32
3647 Right int32
3648 Bottom int32
3649 }
3650
3651 type GUIThreadInfo struct {
3652 Size uint32
3653 Flags uint32
3654 Active HWND
3655 Focus HWND
3656 Capture HWND
3657 MenuOwner HWND
3658 MoveSize HWND
3659 CaretHandle HWND
3660 CaretRect Rect
3661 }
3662
3663 const (
3664 DWMWA_NCRENDERING_ENABLED = 1
3665 DWMWA_NCRENDERING_POLICY = 2
3666 DWMWA_TRANSITIONS_FORCEDISABLED = 3
3667 DWMWA_ALLOW_NCPAINT = 4
3668 DWMWA_CAPTION_BUTTON_BOUNDS = 5
3669 DWMWA_NONCLIENT_RTL_LAYOUT = 6
3670 DWMWA_FORCE_ICONIC_REPRESENTATION = 7
3671 DWMWA_FLIP3D_POLICY = 8
3672 DWMWA_EXTENDED_FRAME_BOUNDS = 9
3673 DWMWA_HAS_ICONIC_BITMAP = 10
3674 DWMWA_DISALLOW_PEEK = 11
3675 DWMWA_EXCLUDED_FROM_PEEK = 12
3676 DWMWA_CLOAK = 13
3677 DWMWA_CLOAKED = 14
3678 DWMWA_FREEZE_REPRESENTATION = 15
3679 DWMWA_PASSIVE_UPDATE_MODE = 16
3680 DWMWA_USE_HOSTBACKDROPBRUSH = 17
3681 DWMWA_USE_IMMERSIVE_DARK_MODE = 20
3682 DWMWA_WINDOW_CORNER_PREFERENCE = 33
3683 DWMWA_BORDER_COLOR = 34
3684 DWMWA_CAPTION_COLOR = 35
3685 DWMWA_TEXT_COLOR = 36
3686 DWMWA_VISIBLE_FRAME_BORDER_THICKNESS = 37
3687 )
3688
3689 type WSAQUERYSET struct {
3690 Size uint32
3691 ServiceInstanceName *uint16
3692 ServiceClassId *GUID
3693 Version *WSAVersion
3694 Comment *uint16
3695 NameSpace uint32
3696 NSProviderId *GUID
3697 Context *uint16
3698 NumberOfProtocols uint32
3699 AfpProtocols *AFProtocols
3700 QueryString *uint16
3701 NumberOfCsAddrs uint32
3702 SaBuffer *CSAddrInfo
3703 OutputFlags uint32
3704 Blob *BLOB
3705 }
3706
3707 type WSAVersion struct {
3708 Version uint32
3709 EnumerationOfComparison int32
3710 }
3711
3712 type AFProtocols struct {
3713 AddressFamily int32
3714 Protocol int32
3715 }
3716
3717 type CSAddrInfo struct {
3718 LocalAddr SocketAddress
3719 RemoteAddr SocketAddress
3720 SocketType int32
3721 Protocol int32
3722 }
3723
3724 type BLOB struct {
3725 Size uint32
3726 BlobData *byte
3727 }
3728
3729 type ComStat struct {
3730 Flags uint32
3731 CBInQue uint32
3732 CBOutQue uint32
3733 }
3734
3735 type DCB struct {
3736 DCBlength uint32
3737 BaudRate uint32
3738 Flags uint32
3739 wReserved uint16
3740 XonLim uint16
3741 XoffLim uint16
3742 ByteSize uint8
3743 Parity uint8
3744 StopBits uint8
3745 XonChar byte
3746 XoffChar byte
3747 ErrorChar byte
3748 EofChar byte
3749 EvtChar byte
3750 wReserved1 uint16
3751 }
3752
3753 // Keyboard Layout Flags.
3754 // See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadkeyboardlayoutw
3755 const (
3756 KLF_ACTIVATE = 0x00000001
3757 KLF_SUBSTITUTE_OK = 0x00000002
3758 KLF_REORDER = 0x00000008
3759 KLF_REPLACELANG = 0x00000010
3760 KLF_NOTELLSHELL = 0x00000080
3761 KLF_SETFORPROCESS = 0x00000100
3762 )
3763
3764 // Virtual Key codes
3765 // https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
3766 const (
3767 VK_LBUTTON = 0x01
3768 VK_RBUTTON = 0x02
3769 VK_CANCEL = 0x03
3770 VK_MBUTTON = 0x04
3771 VK_XBUTTON1 = 0x05
3772 VK_XBUTTON2 = 0x06
3773 VK_BACK = 0x08
3774 VK_TAB = 0x09
3775 VK_CLEAR = 0x0C
3776 VK_RETURN = 0x0D
3777 VK_SHIFT = 0x10
3778 VK_CONTROL = 0x11
3779 VK_MENU = 0x12
3780 VK_PAUSE = 0x13
3781 VK_CAPITAL = 0x14
3782 VK_KANA = 0x15
3783 VK_HANGEUL = 0x15
3784 VK_HANGUL = 0x15
3785 VK_IME_ON = 0x16
3786 VK_JUNJA = 0x17
3787 VK_FINAL = 0x18
3788 VK_HANJA = 0x19
3789 VK_KANJI = 0x19
3790 VK_IME_OFF = 0x1A
3791 VK_ESCAPE = 0x1B
3792 VK_CONVERT = 0x1C
3793 VK_NONCONVERT = 0x1D
3794 VK_ACCEPT = 0x1E
3795 VK_MODECHANGE = 0x1F
3796 VK_SPACE = 0x20
3797 VK_PRIOR = 0x21
3798 VK_NEXT = 0x22
3799 VK_END = 0x23
3800 VK_HOME = 0x24
3801 VK_LEFT = 0x25
3802 VK_UP = 0x26
3803 VK_RIGHT = 0x27
3804 VK_DOWN = 0x28
3805 VK_SELECT = 0x29
3806 VK_PRINT = 0x2A
3807 VK_EXECUTE = 0x2B
3808 VK_SNAPSHOT = 0x2C
3809 VK_INSERT = 0x2D
3810 VK_DELETE = 0x2E
3811 VK_HELP = 0x2F
3812 VK_LWIN = 0x5B
3813 VK_RWIN = 0x5C
3814 VK_APPS = 0x5D
3815 VK_SLEEP = 0x5F
3816 VK_NUMPAD0 = 0x60
3817 VK_NUMPAD1 = 0x61
3818 VK_NUMPAD2 = 0x62
3819 VK_NUMPAD3 = 0x63
3820 VK_NUMPAD4 = 0x64
3821 VK_NUMPAD5 = 0x65
3822 VK_NUMPAD6 = 0x66
3823 VK_NUMPAD7 = 0x67
3824 VK_NUMPAD8 = 0x68
3825 VK_NUMPAD9 = 0x69
3826 VK_MULTIPLY = 0x6A
3827 VK_ADD = 0x6B
3828 VK_SEPARATOR = 0x6C
3829 VK_SUBTRACT = 0x6D
3830 VK_DECIMAL = 0x6E
3831 VK_DIVIDE = 0x6F
3832 VK_F1 = 0x70
3833 VK_F2 = 0x71
3834 VK_F3 = 0x72
3835 VK_F4 = 0x73
3836 VK_F5 = 0x74
3837 VK_F6 = 0x75
3838 VK_F7 = 0x76
3839 VK_F8 = 0x77
3840 VK_F9 = 0x78
3841 VK_F10 = 0x79
3842 VK_F11 = 0x7A
3843 VK_F12 = 0x7B
3844 VK_F13 = 0x7C
3845 VK_F14 = 0x7D
3846 VK_F15 = 0x7E
3847 VK_F16 = 0x7F
3848 VK_F17 = 0x80
3849 VK_F18 = 0x81
3850 VK_F19 = 0x82
3851 VK_F20 = 0x83
3852 VK_F21 = 0x84
3853 VK_F22 = 0x85
3854 VK_F23 = 0x86
3855 VK_F24 = 0x87
3856 VK_NUMLOCK = 0x90
3857 VK_SCROLL = 0x91
3858 VK_OEM_NEC_EQUAL = 0x92
3859 VK_OEM_FJ_JISHO = 0x92
3860 VK_OEM_FJ_MASSHOU = 0x93
3861 VK_OEM_FJ_TOUROKU = 0x94
3862 VK_OEM_FJ_LOYA = 0x95
3863 VK_OEM_FJ_ROYA = 0x96
3864 VK_LSHIFT = 0xA0
3865 VK_RSHIFT = 0xA1
3866 VK_LCONTROL = 0xA2
3867 VK_RCONTROL = 0xA3
3868 VK_LMENU = 0xA4
3869 VK_RMENU = 0xA5
3870 VK_BROWSER_BACK = 0xA6
3871 VK_BROWSER_FORWARD = 0xA7
3872 VK_BROWSER_REFRESH = 0xA8
3873 VK_BROWSER_STOP = 0xA9
3874 VK_BROWSER_SEARCH = 0xAA
3875 VK_BROWSER_FAVORITES = 0xAB
3876 VK_BROWSER_HOME = 0xAC
3877 VK_VOLUME_MUTE = 0xAD
3878 VK_VOLUME_DOWN = 0xAE
3879 VK_VOLUME_UP = 0xAF
3880 VK_MEDIA_NEXT_TRACK = 0xB0
3881 VK_MEDIA_PREV_TRACK = 0xB1
3882 VK_MEDIA_STOP = 0xB2
3883 VK_MEDIA_PLAY_PAUSE = 0xB3
3884 VK_LAUNCH_MAIL = 0xB4
3885 VK_LAUNCH_MEDIA_SELECT = 0xB5
3886 VK_LAUNCH_APP1 = 0xB6
3887 VK_LAUNCH_APP2 = 0xB7
3888 VK_OEM_1 = 0xBA
3889 VK_OEM_PLUS = 0xBB
3890 VK_OEM_COMMA = 0xBC
3891 VK_OEM_MINUS = 0xBD
3892 VK_OEM_PERIOD = 0xBE
3893 VK_OEM_2 = 0xBF
3894 VK_OEM_3 = 0xC0
3895 VK_OEM_4 = 0xDB
3896 VK_OEM_5 = 0xDC
3897 VK_OEM_6 = 0xDD
3898 VK_OEM_7 = 0xDE
3899 VK_OEM_8 = 0xDF
3900 VK_OEM_AX = 0xE1
3901 VK_OEM_102 = 0xE2
3902 VK_ICO_HELP = 0xE3
3903 VK_ICO_00 = 0xE4
3904 VK_PROCESSKEY = 0xE5
3905 VK_ICO_CLEAR = 0xE6
3906 VK_OEM_RESET = 0xE9
3907 VK_OEM_JUMP = 0xEA
3908 VK_OEM_PA1 = 0xEB
3909 VK_OEM_PA2 = 0xEC
3910 VK_OEM_PA3 = 0xED
3911 VK_OEM_WSCTRL = 0xEE
3912 VK_OEM_CUSEL = 0xEF
3913 VK_OEM_ATTN = 0xF0
3914 VK_OEM_FINISH = 0xF1
3915 VK_OEM_COPY = 0xF2
3916 VK_OEM_AUTO = 0xF3
3917 VK_OEM_ENLW = 0xF4
3918 VK_OEM_BACKTAB = 0xF5
3919 VK_ATTN = 0xF6
3920 VK_CRSEL = 0xF7
3921 VK_EXSEL = 0xF8
3922 VK_EREOF = 0xF9
3923 VK_PLAY = 0xFA
3924 VK_ZOOM = 0xFB
3925 VK_NONAME = 0xFC
3926 VK_PA1 = 0xFD
3927 VK_OEM_CLEAR = 0xFE
3928 )
3929
3930 // Mouse button constants.
3931 // https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
3932 const (
3933 FROM_LEFT_1ST_BUTTON_PRESSED = 0x0001
3934 RIGHTMOST_BUTTON_PRESSED = 0x0002
3935 FROM_LEFT_2ND_BUTTON_PRESSED = 0x0004
3936 FROM_LEFT_3RD_BUTTON_PRESSED = 0x0008
3937 FROM_LEFT_4TH_BUTTON_PRESSED = 0x0010
3938 )
3939
3940 // Control key state constaints.
3941 // https://docs.microsoft.com/en-us/windows/console/key-event-record-str
3942 // https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
3943 const (
3944 CAPSLOCK_ON = 0x0080
3945 ENHANCED_KEY = 0x0100
3946 LEFT_ALT_PRESSED = 0x0002
3947 LEFT_CTRL_PRESSED = 0x0008
3948 NUMLOCK_ON = 0x0020
3949 RIGHT_ALT_PRESSED = 0x0001
3950 RIGHT_CTRL_PRESSED = 0x0004
3951 SCROLLLOCK_ON = 0x0040
3952 SHIFT_PRESSED = 0x0010
3953 )
3954
3955 // Mouse event record event flags.
3956 // https://docs.microsoft.com/en-us/windows/console/mouse-event-record-str
3957 const (
3958 MOUSE_MOVED = 0x0001
3959 DOUBLE_CLICK = 0x0002
3960 MOUSE_WHEELED = 0x0004
3961 MOUSE_HWHEELED = 0x0008
3962 )
3963
3964 // Input Record Event Types
3965 // https://learn.microsoft.com/en-us/windows/console/input-record-str
3966 const (
3967 FOCUS_EVENT = 0x0010
3968 KEY_EVENT = 0x0001
3969 MENU_EVENT = 0x0008
3970 MOUSE_EVENT = 0x0002
3971 WINDOW_BUFFER_SIZE_EVENT = 0x0004
3972 )
3973
3974 // The processor features to be tested for IsProcessorFeaturePresent, see
3975 // https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
3976 const (
3977 PF_ARM_64BIT_LOADSTORE_ATOMIC = 25
3978 PF_ARM_DIVIDE_INSTRUCTION_AVAILABLE = 24
3979 PF_ARM_EXTERNAL_CACHE_AVAILABLE = 26
3980 PF_ARM_FMAC_INSTRUCTIONS_AVAILABLE = 27
3981 PF_ARM_VFP_32_REGISTERS_AVAILABLE = 18
3982 PF_3DNOW_INSTRUCTIONS_AVAILABLE = 7
3983 PF_CHANNELS_ENABLED = 16
3984 PF_COMPARE_EXCHANGE_DOUBLE = 2
3985 PF_COMPARE_EXCHANGE128 = 14
3986 PF_COMPARE64_EXCHANGE128 = 15
3987 PF_FASTFAIL_AVAILABLE = 23
3988 PF_FLOATING_POINT_EMULATED = 1
3989 PF_FLOATING_POINT_PRECISION_ERRATA = 0
3990 PF_MMX_INSTRUCTIONS_AVAILABLE = 3
3991 PF_NX_ENABLED = 12
3992 PF_PAE_ENABLED = 9
3993 PF_RDTSC_INSTRUCTION_AVAILABLE = 8
3994 PF_RDWRFSGSBASE_AVAILABLE = 22
3995 PF_SECOND_LEVEL_ADDRESS_TRANSLATION = 20
3996 PF_SSE3_INSTRUCTIONS_AVAILABLE = 13
3997 PF_SSSE3_INSTRUCTIONS_AVAILABLE = 36
3998 PF_SSE4_1_INSTRUCTIONS_AVAILABLE = 37
3999 PF_SSE4_2_INSTRUCTIONS_AVAILABLE = 38
4000 PF_AVX_INSTRUCTIONS_AVAILABLE = 39
4001 PF_AVX2_INSTRUCTIONS_AVAILABLE = 40
4002 PF_AVX512F_INSTRUCTIONS_AVAILABLE = 41
4003 PF_VIRT_FIRMWARE_ENABLED = 21
4004 PF_XMMI_INSTRUCTIONS_AVAILABLE = 6
4005 PF_XMMI64_INSTRUCTIONS_AVAILABLE = 10
4006 PF_XSAVE_ENABLED = 17
4007 PF_ARM_V8_INSTRUCTIONS_AVAILABLE = 29
4008 PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE = 30
4009 PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE = 31
4010 PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE = 34
4011 PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE = 43
4012 PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE = 44
4013 PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE = 45
4014 PF_ARM_SVE_INSTRUCTIONS_AVAILABLE = 46
4015 PF_ARM_SVE2_INSTRUCTIONS_AVAILABLE = 47
4016 PF_ARM_SVE2_1_INSTRUCTIONS_AVAILABLE = 48
4017 PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE = 49
4018 PF_ARM_SVE_PMULL128_INSTRUCTIONS_AVAILABLE = 50
4019 PF_ARM_SVE_BITPERM_INSTRUCTIONS_AVAILABLE = 51
4020 PF_ARM_SVE_BF16_INSTRUCTIONS_AVAILABLE = 52
4021 PF_ARM_SVE_EBF16_INSTRUCTIONS_AVAILABLE = 53
4022 PF_ARM_SVE_B16B16_INSTRUCTIONS_AVAILABLE = 54
4023 PF_ARM_SVE_SHA3_INSTRUCTIONS_AVAILABLE = 55
4024 PF_ARM_SVE_SM4_INSTRUCTIONS_AVAILABLE = 56
4025 PF_ARM_SVE_I8MM_INSTRUCTIONS_AVAILABLE = 57
4026 PF_ARM_SVE_F32MM_INSTRUCTIONS_AVAILABLE = 58
4027 PF_ARM_SVE_F64MM_INSTRUCTIONS_AVAILABLE = 59
4028 PF_BMI2_INSTRUCTIONS_AVAILABLE = 60
4029 PF_MOVDIR64B_INSTRUCTION_AVAILABLE = 61
4030 PF_ARM_LSE2_AVAILABLE = 62
4031 PF_ARM_SHA3_INSTRUCTIONS_AVAILABLE = 64
4032 PF_ARM_SHA512_INSTRUCTIONS_AVAILABLE = 65
4033 PF_ARM_V82_I8MM_INSTRUCTIONS_AVAILABLE = 66
4034 PF_ARM_V82_FP16_INSTRUCTIONS_AVAILABLE = 67
4035 PF_ARM_V86_BF16_INSTRUCTIONS_AVAILABLE = 68
4036 PF_ARM_V86_EBF16_INSTRUCTIONS_AVAILABLE = 69
4037 PF_ARM_SME_INSTRUCTIONS_AVAILABLE = 70
4038 PF_ARM_SME2_INSTRUCTIONS_AVAILABLE = 71
4039 PF_ARM_SME2_1_INSTRUCTIONS_AVAILABLE = 72
4040 PF_ARM_SME2_2_INSTRUCTIONS_AVAILABLE = 73
4041 PF_ARM_SME_AES_INSTRUCTIONS_AVAILABLE = 74
4042 PF_ARM_SME_SBITPERM_INSTRUCTIONS_AVAILABLE = 75
4043 PF_ARM_SME_SF8MM4_INSTRUCTIONS_AVAILABLE = 76
4044 PF_ARM_SME_SF8MM8_INSTRUCTIONS_AVAILABLE = 77
4045 PF_ARM_SME_SF8DP2_INSTRUCTIONS_AVAILABLE = 78
4046 PF_ARM_SME_SF8DP4_INSTRUCTIONS_AVAILABLE = 79
4047 PF_ARM_SME_SF8FMA_INSTRUCTIONS_AVAILABLE = 80
4048 PF_ARM_SME_F8F32_INSTRUCTIONS_AVAILABLE = 81
4049 PF_ARM_SME_F8F16_INSTRUCTIONS_AVAILABLE = 82
4050 PF_ARM_SME_F16F16_INSTRUCTIONS_AVAILABLE = 83
4051 PF_ARM_SME_B16B16_INSTRUCTIONS_AVAILABLE = 84
4052 PF_ARM_SME_F64F64_INSTRUCTIONS_AVAILABLE = 85
4053 PF_ARM_SME_I16I64_INSTRUCTIONS_AVAILABLE = 86
4054 PF_ARM_SME_LUTv2_INSTRUCTIONS_AVAILABLE = 87
4055 PF_ARM_SME_FA64_INSTRUCTIONS_AVAILABLE = 88
4056 PF_UMONITOR_INSTRUCTION_AVAILABLE = 89
4057 )