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