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