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