github.com/fletavendor/sys@v0.0.0-20181107165924-66b7b1311ac8/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 "syscall" 8 9 const ( 10 // Windows errors. 11 ERROR_FILE_NOT_FOUND syscall.Errno = 2 12 ERROR_PATH_NOT_FOUND syscall.Errno = 3 13 ERROR_ACCESS_DENIED syscall.Errno = 5 14 ERROR_NO_MORE_FILES syscall.Errno = 18 15 ERROR_HANDLE_EOF syscall.Errno = 38 16 ERROR_NETNAME_DELETED syscall.Errno = 64 17 ERROR_FILE_EXISTS syscall.Errno = 80 18 ERROR_BROKEN_PIPE syscall.Errno = 109 19 ERROR_BUFFER_OVERFLOW syscall.Errno = 111 20 ERROR_INSUFFICIENT_BUFFER syscall.Errno = 122 21 ERROR_MOD_NOT_FOUND syscall.Errno = 126 22 ERROR_PROC_NOT_FOUND syscall.Errno = 127 23 ERROR_ALREADY_EXISTS syscall.Errno = 183 24 ERROR_ENVVAR_NOT_FOUND syscall.Errno = 203 25 ERROR_MORE_DATA syscall.Errno = 234 26 ERROR_OPERATION_ABORTED syscall.Errno = 995 27 ERROR_IO_PENDING syscall.Errno = 997 28 ERROR_SERVICE_SPECIFIC_ERROR syscall.Errno = 1066 29 ERROR_NOT_FOUND syscall.Errno = 1168 30 ERROR_PRIVILEGE_NOT_HELD syscall.Errno = 1314 31 WSAEACCES syscall.Errno = 10013 32 WSAEMSGSIZE syscall.Errno = 10040 33 WSAECONNRESET syscall.Errno = 10054 34 ) 35 36 const ( 37 // Invented values to support what package os expects. 38 O_RDONLY = 0x00000 39 O_WRONLY = 0x00001 40 O_RDWR = 0x00002 41 O_CREAT = 0x00040 42 O_EXCL = 0x00080 43 O_NOCTTY = 0x00100 44 O_TRUNC = 0x00200 45 O_NONBLOCK = 0x00800 46 O_APPEND = 0x00400 47 O_SYNC = 0x01000 48 O_ASYNC = 0x02000 49 O_CLOEXEC = 0x80000 50 ) 51 52 const ( 53 // More invented values for signals 54 SIGHUP = Signal(0x1) 55 SIGINT = Signal(0x2) 56 SIGQUIT = Signal(0x3) 57 SIGILL = Signal(0x4) 58 SIGTRAP = Signal(0x5) 59 SIGABRT = Signal(0x6) 60 SIGBUS = Signal(0x7) 61 SIGFPE = Signal(0x8) 62 SIGKILL = Signal(0x9) 63 SIGSEGV = Signal(0xb) 64 SIGPIPE = Signal(0xd) 65 SIGALRM = Signal(0xe) 66 SIGTERM = Signal(0xf) 67 ) 68 69 var signals = [...]string{ 70 1: "hangup", 71 2: "interrupt", 72 3: "quit", 73 4: "illegal instruction", 74 5: "trace/breakpoint trap", 75 6: "aborted", 76 7: "bus error", 77 8: "floating point exception", 78 9: "killed", 79 10: "user defined signal 1", 80 11: "segmentation fault", 81 12: "user defined signal 2", 82 13: "broken pipe", 83 14: "alarm clock", 84 15: "terminated", 85 } 86 87 const ( 88 GENERIC_READ = 0x80000000 89 GENERIC_WRITE = 0x40000000 90 GENERIC_EXECUTE = 0x20000000 91 GENERIC_ALL = 0x10000000 92 93 FILE_LIST_DIRECTORY = 0x00000001 94 FILE_APPEND_DATA = 0x00000004 95 FILE_WRITE_ATTRIBUTES = 0x00000100 96 97 FILE_SHARE_READ = 0x00000001 98 FILE_SHARE_WRITE = 0x00000002 99 FILE_SHARE_DELETE = 0x00000004 100 101 FILE_ATTRIBUTE_READONLY = 0x00000001 102 FILE_ATTRIBUTE_HIDDEN = 0x00000002 103 FILE_ATTRIBUTE_SYSTEM = 0x00000004 104 FILE_ATTRIBUTE_DIRECTORY = 0x00000010 105 FILE_ATTRIBUTE_ARCHIVE = 0x00000020 106 FILE_ATTRIBUTE_DEVICE = 0x00000040 107 FILE_ATTRIBUTE_NORMAL = 0x00000080 108 FILE_ATTRIBUTE_TEMPORARY = 0x00000100 109 FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200 110 FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400 111 FILE_ATTRIBUTE_COMPRESSED = 0x00000800 112 FILE_ATTRIBUTE_OFFLINE = 0x00001000 113 FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000 114 FILE_ATTRIBUTE_ENCRYPTED = 0x00004000 115 FILE_ATTRIBUTE_INTEGRITY_STREAM = 0x00008000 116 FILE_ATTRIBUTE_VIRTUAL = 0x00010000 117 FILE_ATTRIBUTE_NO_SCRUB_DATA = 0x00020000 118 FILE_ATTRIBUTE_RECALL_ON_OPEN = 0x00040000 119 FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS = 0x00400000 120 121 INVALID_FILE_ATTRIBUTES = 0xffffffff 122 123 CREATE_NEW = 1 124 CREATE_ALWAYS = 2 125 OPEN_EXISTING = 3 126 OPEN_ALWAYS = 4 127 TRUNCATE_EXISTING = 5 128 129 FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000 130 FILE_FLAG_BACKUP_SEMANTICS = 0x02000000 131 FILE_FLAG_OVERLAPPED = 0x40000000 132 133 HANDLE_FLAG_INHERIT = 0x00000001 134 STARTF_USESTDHANDLES = 0x00000100 135 STARTF_USESHOWWINDOW = 0x00000001 136 DUPLICATE_CLOSE_SOURCE = 0x00000001 137 DUPLICATE_SAME_ACCESS = 0x00000002 138 139 STD_INPUT_HANDLE = -10 & (1<<32 - 1) 140 STD_OUTPUT_HANDLE = -11 & (1<<32 - 1) 141 STD_ERROR_HANDLE = -12 & (1<<32 - 1) 142 143 FILE_BEGIN = 0 144 FILE_CURRENT = 1 145 FILE_END = 2 146 147 LANG_ENGLISH = 0x09 148 SUBLANG_ENGLISH_US = 0x01 149 150 FORMAT_MESSAGE_ALLOCATE_BUFFER = 256 151 FORMAT_MESSAGE_IGNORE_INSERTS = 512 152 FORMAT_MESSAGE_FROM_STRING = 1024 153 FORMAT_MESSAGE_FROM_HMODULE = 2048 154 FORMAT_MESSAGE_FROM_SYSTEM = 4096 155 FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192 156 FORMAT_MESSAGE_MAX_WIDTH_MASK = 255 157 158 MAX_PATH = 260 159 MAX_LONG_PATH = 32768 160 161 MAX_COMPUTERNAME_LENGTH = 15 162 163 TIME_ZONE_ID_UNKNOWN = 0 164 TIME_ZONE_ID_STANDARD = 1 165 166 TIME_ZONE_ID_DAYLIGHT = 2 167 IGNORE = 0 168 INFINITE = 0xffffffff 169 170 WAIT_TIMEOUT = 258 171 WAIT_ABANDONED = 0x00000080 172 WAIT_OBJECT_0 = 0x00000000 173 WAIT_FAILED = 0xFFFFFFFF 174 175 PROCESS_TERMINATE = 1 176 PROCESS_QUERY_INFORMATION = 0x00000400 177 SYNCHRONIZE = 0x00100000 178 179 FILE_MAP_COPY = 0x01 180 FILE_MAP_WRITE = 0x02 181 FILE_MAP_READ = 0x04 182 FILE_MAP_EXECUTE = 0x20 183 184 CTRL_C_EVENT = 0 185 CTRL_BREAK_EVENT = 1 186 187 // Windows reserves errors >= 1<<29 for application use. 188 APPLICATION_ERROR = 1 << 29 189 ) 190 191 const ( 192 // Process creation flags. 193 CREATE_BREAKAWAY_FROM_JOB = 0x01000000 194 CREATE_DEFAULT_ERROR_MODE = 0x04000000 195 CREATE_NEW_CONSOLE = 0x00000010 196 CREATE_NEW_PROCESS_GROUP = 0x00000200 197 CREATE_NO_WINDOW = 0x08000000 198 CREATE_PROTECTED_PROCESS = 0x00040000 199 CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000 200 CREATE_SEPARATE_WOW_VDM = 0x00000800 201 CREATE_SHARED_WOW_VDM = 0x00001000 202 CREATE_SUSPENDED = 0x00000004 203 CREATE_UNICODE_ENVIRONMENT = 0x00000400 204 DEBUG_ONLY_THIS_PROCESS = 0x00000002 205 DEBUG_PROCESS = 0x00000001 206 DETACHED_PROCESS = 0x00000008 207 EXTENDED_STARTUPINFO_PRESENT = 0x00080000 208 INHERIT_PARENT_AFFINITY = 0x00010000 209 ) 210 211 const ( 212 // flags for CreateToolhelp32Snapshot 213 TH32CS_SNAPHEAPLIST = 0x01 214 TH32CS_SNAPPROCESS = 0x02 215 TH32CS_SNAPTHREAD = 0x04 216 TH32CS_SNAPMODULE = 0x08 217 TH32CS_SNAPMODULE32 = 0x10 218 TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD 219 TH32CS_INHERIT = 0x80000000 220 ) 221 222 const ( 223 // filters for ReadDirectoryChangesW 224 FILE_NOTIFY_CHANGE_FILE_NAME = 0x001 225 FILE_NOTIFY_CHANGE_DIR_NAME = 0x002 226 FILE_NOTIFY_CHANGE_ATTRIBUTES = 0x004 227 FILE_NOTIFY_CHANGE_SIZE = 0x008 228 FILE_NOTIFY_CHANGE_LAST_WRITE = 0x010 229 FILE_NOTIFY_CHANGE_LAST_ACCESS = 0x020 230 FILE_NOTIFY_CHANGE_CREATION = 0x040 231 FILE_NOTIFY_CHANGE_SECURITY = 0x100 232 ) 233 234 const ( 235 // do not reorder 236 FILE_ACTION_ADDED = iota + 1 237 FILE_ACTION_REMOVED 238 FILE_ACTION_MODIFIED 239 FILE_ACTION_RENAMED_OLD_NAME 240 FILE_ACTION_RENAMED_NEW_NAME 241 ) 242 243 const ( 244 // wincrypt.h 245 PROV_RSA_FULL = 1 246 PROV_RSA_SIG = 2 247 PROV_DSS = 3 248 PROV_FORTEZZA = 4 249 PROV_MS_EXCHANGE = 5 250 PROV_SSL = 6 251 PROV_RSA_SCHANNEL = 12 252 PROV_DSS_DH = 13 253 PROV_EC_ECDSA_SIG = 14 254 PROV_EC_ECNRA_SIG = 15 255 PROV_EC_ECDSA_FULL = 16 256 PROV_EC_ECNRA_FULL = 17 257 PROV_DH_SCHANNEL = 18 258 PROV_SPYRUS_LYNKS = 20 259 PROV_RNG = 21 260 PROV_INTEL_SEC = 22 261 PROV_REPLACE_OWF = 23 262 PROV_RSA_AES = 24 263 CRYPT_VERIFYCONTEXT = 0xF0000000 264 CRYPT_NEWKEYSET = 0x00000008 265 CRYPT_DELETEKEYSET = 0x00000010 266 CRYPT_MACHINE_KEYSET = 0x00000020 267 CRYPT_SILENT = 0x00000040 268 CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080 269 270 USAGE_MATCH_TYPE_AND = 0 271 USAGE_MATCH_TYPE_OR = 1 272 273 /* msgAndCertEncodingType values for CertOpenStore function */ 274 X509_ASN_ENCODING = 0x00000001 275 PKCS_7_ASN_ENCODING = 0x00010000 276 277 /* storeProvider values for CertOpenStore function */ 278 CERT_STORE_PROV_MSG = 1 279 CERT_STORE_PROV_MEMORY = 2 280 CERT_STORE_PROV_FILE = 3 281 CERT_STORE_PROV_REG = 4 282 CERT_STORE_PROV_PKCS7 = 5 283 CERT_STORE_PROV_SERIALIZED = 6 284 CERT_STORE_PROV_FILENAME_A = 7 285 CERT_STORE_PROV_FILENAME_W = 8 286 CERT_STORE_PROV_FILENAME = CERT_STORE_PROV_FILENAME_W 287 CERT_STORE_PROV_SYSTEM_A = 9 288 CERT_STORE_PROV_SYSTEM_W = 10 289 CERT_STORE_PROV_SYSTEM = CERT_STORE_PROV_SYSTEM_W 290 CERT_STORE_PROV_COLLECTION = 11 291 CERT_STORE_PROV_SYSTEM_REGISTRY_A = 12 292 CERT_STORE_PROV_SYSTEM_REGISTRY_W = 13 293 CERT_STORE_PROV_SYSTEM_REGISTRY = CERT_STORE_PROV_SYSTEM_REGISTRY_W 294 CERT_STORE_PROV_PHYSICAL_W = 14 295 CERT_STORE_PROV_PHYSICAL = CERT_STORE_PROV_PHYSICAL_W 296 CERT_STORE_PROV_SMART_CARD_W = 15 297 CERT_STORE_PROV_SMART_CARD = CERT_STORE_PROV_SMART_CARD_W 298 CERT_STORE_PROV_LDAP_W = 16 299 CERT_STORE_PROV_LDAP = CERT_STORE_PROV_LDAP_W 300 CERT_STORE_PROV_PKCS12 = 17 301 302 /* store characteristics (low WORD of flag) for CertOpenStore function */ 303 CERT_STORE_NO_CRYPT_RELEASE_FLAG = 0x00000001 304 CERT_STORE_SET_LOCALIZED_NAME_FLAG = 0x00000002 305 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004 306 CERT_STORE_DELETE_FLAG = 0x00000010 307 CERT_STORE_UNSAFE_PHYSICAL_FLAG = 0x00000020 308 CERT_STORE_SHARE_STORE_FLAG = 0x00000040 309 CERT_STORE_SHARE_CONTEXT_FLAG = 0x00000080 310 CERT_STORE_MANIFOLD_FLAG = 0x00000100 311 CERT_STORE_ENUM_ARCHIVED_FLAG = 0x00000200 312 CERT_STORE_UPDATE_KEYID_FLAG = 0x00000400 313 CERT_STORE_BACKUP_RESTORE_FLAG = 0x00000800 314 CERT_STORE_MAXIMUM_ALLOWED_FLAG = 0x00001000 315 CERT_STORE_CREATE_NEW_FLAG = 0x00002000 316 CERT_STORE_OPEN_EXISTING_FLAG = 0x00004000 317 CERT_STORE_READONLY_FLAG = 0x00008000 318 319 /* store locations (high WORD of flag) for CertOpenStore function */ 320 CERT_SYSTEM_STORE_CURRENT_USER = 0x00010000 321 CERT_SYSTEM_STORE_LOCAL_MACHINE = 0x00020000 322 CERT_SYSTEM_STORE_CURRENT_SERVICE = 0x00040000 323 CERT_SYSTEM_STORE_SERVICES = 0x00050000 324 CERT_SYSTEM_STORE_USERS = 0x00060000 325 CERT_SYSTEM_STORE_CURRENT_USER_GROUP_POLICY = 0x00070000 326 CERT_SYSTEM_STORE_LOCAL_MACHINE_GROUP_POLICY = 0x00080000 327 CERT_SYSTEM_STORE_LOCAL_MACHINE_ENTERPRISE = 0x00090000 328 CERT_SYSTEM_STORE_UNPROTECTED_FLAG = 0x40000000 329 CERT_SYSTEM_STORE_RELOCATE_FLAG = 0x80000000 330 331 /* Miscellaneous high-WORD flags for CertOpenStore function */ 332 CERT_REGISTRY_STORE_REMOTE_FLAG = 0x00010000 333 CERT_REGISTRY_STORE_SERIALIZED_FLAG = 0x00020000 334 CERT_REGISTRY_STORE_ROAMING_FLAG = 0x00040000 335 CERT_REGISTRY_STORE_MY_IE_DIRTY_FLAG = 0x00080000 336 CERT_REGISTRY_STORE_LM_GPT_FLAG = 0x01000000 337 CERT_REGISTRY_STORE_CLIENT_GPT_FLAG = 0x80000000 338 CERT_FILE_STORE_COMMIT_ENABLE_FLAG = 0x00010000 339 CERT_LDAP_STORE_SIGN_FLAG = 0x00010000 340 CERT_LDAP_STORE_AREC_EXCLUSIVE_FLAG = 0x00020000 341 CERT_LDAP_STORE_OPENED_FLAG = 0x00040000 342 CERT_LDAP_STORE_UNBIND_FLAG = 0x00080000 343 344 /* addDisposition values for CertAddCertificateContextToStore function */ 345 CERT_STORE_ADD_NEW = 1 346 CERT_STORE_ADD_USE_EXISTING = 2 347 CERT_STORE_ADD_REPLACE_EXISTING = 3 348 CERT_STORE_ADD_ALWAYS = 4 349 CERT_STORE_ADD_REPLACE_EXISTING_INHERIT_PROPERTIES = 5 350 CERT_STORE_ADD_NEWER = 6 351 CERT_STORE_ADD_NEWER_INHERIT_PROPERTIES = 7 352 353 /* ErrorStatus values for CertTrustStatus struct */ 354 CERT_TRUST_NO_ERROR = 0x00000000 355 CERT_TRUST_IS_NOT_TIME_VALID = 0x00000001 356 CERT_TRUST_IS_REVOKED = 0x00000004 357 CERT_TRUST_IS_NOT_SIGNATURE_VALID = 0x00000008 358 CERT_TRUST_IS_NOT_VALID_FOR_USAGE = 0x00000010 359 CERT_TRUST_IS_UNTRUSTED_ROOT = 0x00000020 360 CERT_TRUST_REVOCATION_STATUS_UNKNOWN = 0x00000040 361 CERT_TRUST_IS_CYCLIC = 0x00000080 362 CERT_TRUST_INVALID_EXTENSION = 0x00000100 363 CERT_TRUST_INVALID_POLICY_CONSTRAINTS = 0x00000200 364 CERT_TRUST_INVALID_BASIC_CONSTRAINTS = 0x00000400 365 CERT_TRUST_INVALID_NAME_CONSTRAINTS = 0x00000800 366 CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000 367 CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT = 0x00002000 368 CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000 369 CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT = 0x00008000 370 CERT_TRUST_IS_PARTIAL_CHAIN = 0x00010000 371 CERT_TRUST_CTL_IS_NOT_TIME_VALID = 0x00020000 372 CERT_TRUST_CTL_IS_NOT_SIGNATURE_VALID = 0x00040000 373 CERT_TRUST_CTL_IS_NOT_VALID_FOR_USAGE = 0x00080000 374 CERT_TRUST_HAS_WEAK_SIGNATURE = 0x00100000 375 CERT_TRUST_IS_OFFLINE_REVOCATION = 0x01000000 376 CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY = 0x02000000 377 CERT_TRUST_IS_EXPLICIT_DISTRUST = 0x04000000 378 CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT = 0x08000000 379 380 /* InfoStatus values for CertTrustStatus struct */ 381 CERT_TRUST_HAS_EXACT_MATCH_ISSUER = 0x00000001 382 CERT_TRUST_HAS_KEY_MATCH_ISSUER = 0x00000002 383 CERT_TRUST_HAS_NAME_MATCH_ISSUER = 0x00000004 384 CERT_TRUST_IS_SELF_SIGNED = 0x00000008 385 CERT_TRUST_HAS_PREFERRED_ISSUER = 0x00000100 386 CERT_TRUST_HAS_ISSUANCE_CHAIN_POLICY = 0x00000400 387 CERT_TRUST_HAS_VALID_NAME_CONSTRAINTS = 0x00000400 388 CERT_TRUST_IS_PEER_TRUSTED = 0x00000800 389 CERT_TRUST_HAS_CRL_VALIDITY_EXTENDED = 0x00001000 390 CERT_TRUST_IS_FROM_EXCLUSIVE_TRUST_STORE = 0x00002000 391 CERT_TRUST_IS_CA_TRUSTED = 0x00004000 392 CERT_TRUST_IS_COMPLEX_CHAIN = 0x00010000 393 394 /* policyOID values for CertVerifyCertificateChainPolicy function */ 395 CERT_CHAIN_POLICY_BASE = 1 396 CERT_CHAIN_POLICY_AUTHENTICODE = 2 397 CERT_CHAIN_POLICY_AUTHENTICODE_TS = 3 398 CERT_CHAIN_POLICY_SSL = 4 399 CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5 400 CERT_CHAIN_POLICY_NT_AUTH = 6 401 CERT_CHAIN_POLICY_MICROSOFT_ROOT = 7 402 CERT_CHAIN_POLICY_EV = 8 403 CERT_CHAIN_POLICY_SSL_F12 = 9 404 405 CERT_E_EXPIRED = 0x800B0101 406 CERT_E_ROLE = 0x800B0103 407 CERT_E_PURPOSE = 0x800B0106 408 CERT_E_UNTRUSTEDROOT = 0x800B0109 409 CERT_E_CN_NO_MATCH = 0x800B010F 410 411 /* AuthType values for SSLExtraCertChainPolicyPara struct */ 412 AUTHTYPE_CLIENT = 1 413 AUTHTYPE_SERVER = 2 414 415 /* Checks values for SSLExtraCertChainPolicyPara struct */ 416 SECURITY_FLAG_IGNORE_REVOCATION = 0x00000080 417 SECURITY_FLAG_IGNORE_UNKNOWN_CA = 0x00000100 418 SECURITY_FLAG_IGNORE_WRONG_USAGE = 0x00000200 419 SECURITY_FLAG_IGNORE_CERT_CN_INVALID = 0x00001000 420 SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = 0x00002000 421 ) 422 423 var ( 424 OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00") 425 OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00") 426 OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00") 427 ) 428 429 // Pointer represents a pointer to an arbitrary Windows type. 430 // 431 // Pointer-typed fields may point to one of many different types. It's 432 // up to the caller to provide a pointer to the appropriate type, cast 433 // to Pointer. The caller must obey the unsafe.Pointer rules while 434 // doing so. 435 type Pointer *struct{} 436 437 // Invented values to support what package os expects. 438 type Timeval struct { 439 Sec int32 440 Usec int32 441 } 442 443 func (tv *Timeval) Nanoseconds() int64 { 444 return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3 445 } 446 447 func NsecToTimeval(nsec int64) (tv Timeval) { 448 tv.Sec = int32(nsec / 1e9) 449 tv.Usec = int32(nsec % 1e9 / 1e3) 450 return 451 } 452 453 type SecurityAttributes struct { 454 Length uint32 455 SecurityDescriptor uintptr 456 InheritHandle uint32 457 } 458 459 type Overlapped struct { 460 Internal uintptr 461 InternalHigh uintptr 462 Offset uint32 463 OffsetHigh uint32 464 HEvent Handle 465 } 466 467 type FileNotifyInformation struct { 468 NextEntryOffset uint32 469 Action uint32 470 FileNameLength uint32 471 FileName uint16 472 } 473 474 type Filetime struct { 475 LowDateTime uint32 476 HighDateTime uint32 477 } 478 479 // Nanoseconds returns Filetime ft in nanoseconds 480 // since Epoch (00:00:00 UTC, January 1, 1970). 481 func (ft *Filetime) Nanoseconds() int64 { 482 // 100-nanosecond intervals since January 1, 1601 483 nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime) 484 // change starting time to the Epoch (00:00:00 UTC, January 1, 1970) 485 nsec -= 116444736000000000 486 // convert into nanoseconds 487 nsec *= 100 488 return nsec 489 } 490 491 func NsecToFiletime(nsec int64) (ft Filetime) { 492 // convert into 100-nanosecond 493 nsec /= 100 494 // change starting time to January 1, 1601 495 nsec += 116444736000000000 496 // split into high / low 497 ft.LowDateTime = uint32(nsec & 0xffffffff) 498 ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff) 499 return ft 500 } 501 502 type Win32finddata struct { 503 FileAttributes uint32 504 CreationTime Filetime 505 LastAccessTime Filetime 506 LastWriteTime Filetime 507 FileSizeHigh uint32 508 FileSizeLow uint32 509 Reserved0 uint32 510 Reserved1 uint32 511 FileName [MAX_PATH - 1]uint16 512 AlternateFileName [13]uint16 513 } 514 515 // This is the actual system call structure. 516 // Win32finddata is what we committed to in Go 1. 517 type win32finddata1 struct { 518 FileAttributes uint32 519 CreationTime Filetime 520 LastAccessTime Filetime 521 LastWriteTime Filetime 522 FileSizeHigh uint32 523 FileSizeLow uint32 524 Reserved0 uint32 525 Reserved1 uint32 526 FileName [MAX_PATH]uint16 527 AlternateFileName [14]uint16 528 } 529 530 func copyFindData(dst *Win32finddata, src *win32finddata1) { 531 dst.FileAttributes = src.FileAttributes 532 dst.CreationTime = src.CreationTime 533 dst.LastAccessTime = src.LastAccessTime 534 dst.LastWriteTime = src.LastWriteTime 535 dst.FileSizeHigh = src.FileSizeHigh 536 dst.FileSizeLow = src.FileSizeLow 537 dst.Reserved0 = src.Reserved0 538 dst.Reserved1 = src.Reserved1 539 540 // The src is 1 element bigger than dst, but it must be NUL. 541 copy(dst.FileName[:], src.FileName[:]) 542 copy(dst.AlternateFileName[:], src.AlternateFileName[:]) 543 } 544 545 type ByHandleFileInformation struct { 546 FileAttributes uint32 547 CreationTime Filetime 548 LastAccessTime Filetime 549 LastWriteTime Filetime 550 VolumeSerialNumber uint32 551 FileSizeHigh uint32 552 FileSizeLow uint32 553 NumberOfLinks uint32 554 FileIndexHigh uint32 555 FileIndexLow uint32 556 } 557 558 const ( 559 GetFileExInfoStandard = 0 560 GetFileExMaxInfoLevel = 1 561 ) 562 563 type Win32FileAttributeData struct { 564 FileAttributes uint32 565 CreationTime Filetime 566 LastAccessTime Filetime 567 LastWriteTime Filetime 568 FileSizeHigh uint32 569 FileSizeLow uint32 570 } 571 572 // ShowWindow constants 573 const ( 574 // winuser.h 575 SW_HIDE = 0 576 SW_NORMAL = 1 577 SW_SHOWNORMAL = 1 578 SW_SHOWMINIMIZED = 2 579 SW_SHOWMAXIMIZED = 3 580 SW_MAXIMIZE = 3 581 SW_SHOWNOACTIVATE = 4 582 SW_SHOW = 5 583 SW_MINIMIZE = 6 584 SW_SHOWMINNOACTIVE = 7 585 SW_SHOWNA = 8 586 SW_RESTORE = 9 587 SW_SHOWDEFAULT = 10 588 SW_FORCEMINIMIZE = 11 589 ) 590 591 type StartupInfo struct { 592 Cb uint32 593 _ *uint16 594 Desktop *uint16 595 Title *uint16 596 X uint32 597 Y uint32 598 XSize uint32 599 YSize uint32 600 XCountChars uint32 601 YCountChars uint32 602 FillAttribute uint32 603 Flags uint32 604 ShowWindow uint16 605 _ uint16 606 _ *byte 607 StdInput Handle 608 StdOutput Handle 609 StdErr Handle 610 } 611 612 type ProcessInformation struct { 613 Process Handle 614 Thread Handle 615 ProcessId uint32 616 ThreadId uint32 617 } 618 619 type ProcessEntry32 struct { 620 Size uint32 621 Usage uint32 622 ProcessID uint32 623 DefaultHeapID uintptr 624 ModuleID uint32 625 Threads uint32 626 ParentProcessID uint32 627 PriClassBase int32 628 Flags uint32 629 ExeFile [MAX_PATH]uint16 630 } 631 632 type Systemtime struct { 633 Year uint16 634 Month uint16 635 DayOfWeek uint16 636 Day uint16 637 Hour uint16 638 Minute uint16 639 Second uint16 640 Milliseconds uint16 641 } 642 643 type Timezoneinformation struct { 644 Bias int32 645 StandardName [32]uint16 646 StandardDate Systemtime 647 StandardBias int32 648 DaylightName [32]uint16 649 DaylightDate Systemtime 650 DaylightBias int32 651 } 652 653 // Socket related. 654 655 const ( 656 AF_UNSPEC = 0 657 AF_UNIX = 1 658 AF_INET = 2 659 AF_INET6 = 23 660 AF_NETBIOS = 17 661 662 SOCK_STREAM = 1 663 SOCK_DGRAM = 2 664 SOCK_RAW = 3 665 SOCK_SEQPACKET = 5 666 667 IPPROTO_IP = 0 668 IPPROTO_IPV6 = 0x29 669 IPPROTO_TCP = 6 670 IPPROTO_UDP = 17 671 672 SOL_SOCKET = 0xffff 673 SO_REUSEADDR = 4 674 SO_KEEPALIVE = 8 675 SO_DONTROUTE = 16 676 SO_BROADCAST = 32 677 SO_LINGER = 128 678 SO_RCVBUF = 0x1002 679 SO_SNDBUF = 0x1001 680 SO_UPDATE_ACCEPT_CONTEXT = 0x700b 681 SO_UPDATE_CONNECT_CONTEXT = 0x7010 682 683 IOC_OUT = 0x40000000 684 IOC_IN = 0x80000000 685 IOC_VENDOR = 0x18000000 686 IOC_INOUT = IOC_IN | IOC_OUT 687 IOC_WS2 = 0x08000000 688 SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6 689 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4 690 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12 691 692 // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460 693 694 IP_TOS = 0x3 695 IP_TTL = 0x4 696 IP_MULTICAST_IF = 0x9 697 IP_MULTICAST_TTL = 0xa 698 IP_MULTICAST_LOOP = 0xb 699 IP_ADD_MEMBERSHIP = 0xc 700 IP_DROP_MEMBERSHIP = 0xd 701 702 IPV6_V6ONLY = 0x1b 703 IPV6_UNICAST_HOPS = 0x4 704 IPV6_MULTICAST_IF = 0x9 705 IPV6_MULTICAST_HOPS = 0xa 706 IPV6_MULTICAST_LOOP = 0xb 707 IPV6_JOIN_GROUP = 0xc 708 IPV6_LEAVE_GROUP = 0xd 709 710 MSG_OOB = 0x1 711 MSG_PEEK = 0x2 712 MSG_DONTROUTE = 0x4 713 MSG_WAITALL = 0x8 714 715 MSG_TRUNC = 0x0100 716 MSG_CTRUNC = 0x0200 717 MSG_BCAST = 0x0400 718 MSG_MCAST = 0x0800 719 720 SOMAXCONN = 0x7fffffff 721 722 TCP_NODELAY = 1 723 724 SHUT_RD = 0 725 SHUT_WR = 1 726 SHUT_RDWR = 2 727 728 WSADESCRIPTION_LEN = 256 729 WSASYS_STATUS_LEN = 128 730 ) 731 732 type WSABuf struct { 733 Len uint32 734 Buf *byte 735 } 736 737 type WSAMsg struct { 738 Name *syscall.RawSockaddrAny 739 Namelen int32 740 Buffers *WSABuf 741 BufferCount uint32 742 Control WSABuf 743 Flags uint32 744 } 745 746 // Invented values to support what package os expects. 747 const ( 748 S_IFMT = 0x1f000 749 S_IFIFO = 0x1000 750 S_IFCHR = 0x2000 751 S_IFDIR = 0x4000 752 S_IFBLK = 0x6000 753 S_IFREG = 0x8000 754 S_IFLNK = 0xa000 755 S_IFSOCK = 0xc000 756 S_ISUID = 0x800 757 S_ISGID = 0x400 758 S_ISVTX = 0x200 759 S_IRUSR = 0x100 760 S_IWRITE = 0x80 761 S_IWUSR = 0x80 762 S_IXUSR = 0x40 763 ) 764 765 const ( 766 FILE_TYPE_CHAR = 0x0002 767 FILE_TYPE_DISK = 0x0001 768 FILE_TYPE_PIPE = 0x0003 769 FILE_TYPE_REMOTE = 0x8000 770 FILE_TYPE_UNKNOWN = 0x0000 771 ) 772 773 type Hostent struct { 774 Name *byte 775 Aliases **byte 776 AddrType uint16 777 Length uint16 778 AddrList **byte 779 } 780 781 type Protoent struct { 782 Name *byte 783 Aliases **byte 784 Proto uint16 785 } 786 787 const ( 788 DNS_TYPE_A = 0x0001 789 DNS_TYPE_NS = 0x0002 790 DNS_TYPE_MD = 0x0003 791 DNS_TYPE_MF = 0x0004 792 DNS_TYPE_CNAME = 0x0005 793 DNS_TYPE_SOA = 0x0006 794 DNS_TYPE_MB = 0x0007 795 DNS_TYPE_MG = 0x0008 796 DNS_TYPE_MR = 0x0009 797 DNS_TYPE_NULL = 0x000a 798 DNS_TYPE_WKS = 0x000b 799 DNS_TYPE_PTR = 0x000c 800 DNS_TYPE_HINFO = 0x000d 801 DNS_TYPE_MINFO = 0x000e 802 DNS_TYPE_MX = 0x000f 803 DNS_TYPE_TEXT = 0x0010 804 DNS_TYPE_RP = 0x0011 805 DNS_TYPE_AFSDB = 0x0012 806 DNS_TYPE_X25 = 0x0013 807 DNS_TYPE_ISDN = 0x0014 808 DNS_TYPE_RT = 0x0015 809 DNS_TYPE_NSAP = 0x0016 810 DNS_TYPE_NSAPPTR = 0x0017 811 DNS_TYPE_SIG = 0x0018 812 DNS_TYPE_KEY = 0x0019 813 DNS_TYPE_PX = 0x001a 814 DNS_TYPE_GPOS = 0x001b 815 DNS_TYPE_AAAA = 0x001c 816 DNS_TYPE_LOC = 0x001d 817 DNS_TYPE_NXT = 0x001e 818 DNS_TYPE_EID = 0x001f 819 DNS_TYPE_NIMLOC = 0x0020 820 DNS_TYPE_SRV = 0x0021 821 DNS_TYPE_ATMA = 0x0022 822 DNS_TYPE_NAPTR = 0x0023 823 DNS_TYPE_KX = 0x0024 824 DNS_TYPE_CERT = 0x0025 825 DNS_TYPE_A6 = 0x0026 826 DNS_TYPE_DNAME = 0x0027 827 DNS_TYPE_SINK = 0x0028 828 DNS_TYPE_OPT = 0x0029 829 DNS_TYPE_DS = 0x002B 830 DNS_TYPE_RRSIG = 0x002E 831 DNS_TYPE_NSEC = 0x002F 832 DNS_TYPE_DNSKEY = 0x0030 833 DNS_TYPE_DHCID = 0x0031 834 DNS_TYPE_UINFO = 0x0064 835 DNS_TYPE_UID = 0x0065 836 DNS_TYPE_GID = 0x0066 837 DNS_TYPE_UNSPEC = 0x0067 838 DNS_TYPE_ADDRS = 0x00f8 839 DNS_TYPE_TKEY = 0x00f9 840 DNS_TYPE_TSIG = 0x00fa 841 DNS_TYPE_IXFR = 0x00fb 842 DNS_TYPE_AXFR = 0x00fc 843 DNS_TYPE_MAILB = 0x00fd 844 DNS_TYPE_MAILA = 0x00fe 845 DNS_TYPE_ALL = 0x00ff 846 DNS_TYPE_ANY = 0x00ff 847 DNS_TYPE_WINS = 0xff01 848 DNS_TYPE_WINSR = 0xff02 849 DNS_TYPE_NBSTAT = 0xff01 850 ) 851 852 const ( 853 DNS_INFO_NO_RECORDS = 0x251D 854 ) 855 856 const ( 857 // flags inside DNSRecord.Dw 858 DnsSectionQuestion = 0x0000 859 DnsSectionAnswer = 0x0001 860 DnsSectionAuthority = 0x0002 861 DnsSectionAdditional = 0x0003 862 ) 863 864 type DNSSRVData struct { 865 Target *uint16 866 Priority uint16 867 Weight uint16 868 Port uint16 869 Pad uint16 870 } 871 872 type DNSPTRData struct { 873 Host *uint16 874 } 875 876 type DNSMXData struct { 877 NameExchange *uint16 878 Preference uint16 879 Pad uint16 880 } 881 882 type DNSTXTData struct { 883 StringCount uint16 884 StringArray [1]*uint16 885 } 886 887 type DNSRecord struct { 888 Next *DNSRecord 889 Name *uint16 890 Type uint16 891 Length uint16 892 Dw uint32 893 Ttl uint32 894 Reserved uint32 895 Data [40]byte 896 } 897 898 const ( 899 TF_DISCONNECT = 1 900 TF_REUSE_SOCKET = 2 901 TF_WRITE_BEHIND = 4 902 TF_USE_DEFAULT_WORKER = 0 903 TF_USE_SYSTEM_THREAD = 16 904 TF_USE_KERNEL_APC = 32 905 ) 906 907 type TransmitFileBuffers struct { 908 Head uintptr 909 HeadLength uint32 910 Tail uintptr 911 TailLength uint32 912 } 913 914 const ( 915 IFF_UP = 1 916 IFF_BROADCAST = 2 917 IFF_LOOPBACK = 4 918 IFF_POINTTOPOINT = 8 919 IFF_MULTICAST = 16 920 ) 921 922 const SIO_GET_INTERFACE_LIST = 0x4004747F 923 924 // TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old. 925 // will be fixed to change variable type as suitable. 926 927 type SockaddrGen [24]byte 928 929 type InterfaceInfo struct { 930 Flags uint32 931 Address SockaddrGen 932 BroadcastAddress SockaddrGen 933 Netmask SockaddrGen 934 } 935 936 type IpAddressString struct { 937 String [16]byte 938 } 939 940 type IpMaskString IpAddressString 941 942 type IpAddrString struct { 943 Next *IpAddrString 944 IpAddress IpAddressString 945 IpMask IpMaskString 946 Context uint32 947 } 948 949 const MAX_ADAPTER_NAME_LENGTH = 256 950 const MAX_ADAPTER_DESCRIPTION_LENGTH = 128 951 const MAX_ADAPTER_ADDRESS_LENGTH = 8 952 953 type IpAdapterInfo struct { 954 Next *IpAdapterInfo 955 ComboIndex uint32 956 AdapterName [MAX_ADAPTER_NAME_LENGTH + 4]byte 957 Description [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte 958 AddressLength uint32 959 Address [MAX_ADAPTER_ADDRESS_LENGTH]byte 960 Index uint32 961 Type uint32 962 DhcpEnabled uint32 963 CurrentIpAddress *IpAddrString 964 IpAddressList IpAddrString 965 GatewayList IpAddrString 966 DhcpServer IpAddrString 967 HaveWins bool 968 PrimaryWinsServer IpAddrString 969 SecondaryWinsServer IpAddrString 970 LeaseObtained int64 971 LeaseExpires int64 972 } 973 974 const MAXLEN_PHYSADDR = 8 975 const MAX_INTERFACE_NAME_LEN = 256 976 const MAXLEN_IFDESCR = 256 977 978 type MibIfRow struct { 979 Name [MAX_INTERFACE_NAME_LEN]uint16 980 Index uint32 981 Type uint32 982 Mtu uint32 983 Speed uint32 984 PhysAddrLen uint32 985 PhysAddr [MAXLEN_PHYSADDR]byte 986 AdminStatus uint32 987 OperStatus uint32 988 LastChange uint32 989 InOctets uint32 990 InUcastPkts uint32 991 InNUcastPkts uint32 992 InDiscards uint32 993 InErrors uint32 994 InUnknownProtos uint32 995 OutOctets uint32 996 OutUcastPkts uint32 997 OutNUcastPkts uint32 998 OutDiscards uint32 999 OutErrors uint32 1000 OutQLen uint32 1001 DescrLen uint32 1002 Descr [MAXLEN_IFDESCR]byte 1003 } 1004 1005 type CertInfo struct { 1006 // Not implemented 1007 } 1008 1009 type CertContext struct { 1010 EncodingType uint32 1011 EncodedCert *byte 1012 Length uint32 1013 CertInfo *CertInfo 1014 Store Handle 1015 } 1016 1017 type CertChainContext struct { 1018 Size uint32 1019 TrustStatus CertTrustStatus 1020 ChainCount uint32 1021 Chains **CertSimpleChain 1022 LowerQualityChainCount uint32 1023 LowerQualityChains **CertChainContext 1024 HasRevocationFreshnessTime uint32 1025 RevocationFreshnessTime uint32 1026 } 1027 1028 type CertTrustListInfo struct { 1029 // Not implemented 1030 } 1031 1032 type CertSimpleChain struct { 1033 Size uint32 1034 TrustStatus CertTrustStatus 1035 NumElements uint32 1036 Elements **CertChainElement 1037 TrustListInfo *CertTrustListInfo 1038 HasRevocationFreshnessTime uint32 1039 RevocationFreshnessTime uint32 1040 } 1041 1042 type CertChainElement struct { 1043 Size uint32 1044 CertContext *CertContext 1045 TrustStatus CertTrustStatus 1046 RevocationInfo *CertRevocationInfo 1047 IssuanceUsage *CertEnhKeyUsage 1048 ApplicationUsage *CertEnhKeyUsage 1049 ExtendedErrorInfo *uint16 1050 } 1051 1052 type CertRevocationCrlInfo struct { 1053 // Not implemented 1054 } 1055 1056 type CertRevocationInfo struct { 1057 Size uint32 1058 RevocationResult uint32 1059 RevocationOid *byte 1060 OidSpecificInfo Pointer 1061 HasFreshnessTime uint32 1062 FreshnessTime uint32 1063 CrlInfo *CertRevocationCrlInfo 1064 } 1065 1066 type CertTrustStatus struct { 1067 ErrorStatus uint32 1068 InfoStatus uint32 1069 } 1070 1071 type CertUsageMatch struct { 1072 Type uint32 1073 Usage CertEnhKeyUsage 1074 } 1075 1076 type CertEnhKeyUsage struct { 1077 Length uint32 1078 UsageIdentifiers **byte 1079 } 1080 1081 type CertChainPara struct { 1082 Size uint32 1083 RequestedUsage CertUsageMatch 1084 RequstedIssuancePolicy CertUsageMatch 1085 URLRetrievalTimeout uint32 1086 CheckRevocationFreshnessTime uint32 1087 RevocationFreshnessTime uint32 1088 CacheResync *Filetime 1089 } 1090 1091 type CertChainPolicyPara struct { 1092 Size uint32 1093 Flags uint32 1094 ExtraPolicyPara Pointer 1095 } 1096 1097 type SSLExtraCertChainPolicyPara struct { 1098 Size uint32 1099 AuthType uint32 1100 Checks uint32 1101 ServerName *uint16 1102 } 1103 1104 type CertChainPolicyStatus struct { 1105 Size uint32 1106 Error uint32 1107 ChainIndex uint32 1108 ElementIndex uint32 1109 ExtraPolicyStatus Pointer 1110 } 1111 1112 const ( 1113 // do not reorder 1114 HKEY_CLASSES_ROOT = 0x80000000 + iota 1115 HKEY_CURRENT_USER 1116 HKEY_LOCAL_MACHINE 1117 HKEY_USERS 1118 HKEY_PERFORMANCE_DATA 1119 HKEY_CURRENT_CONFIG 1120 HKEY_DYN_DATA 1121 1122 KEY_QUERY_VALUE = 1 1123 KEY_SET_VALUE = 2 1124 KEY_CREATE_SUB_KEY = 4 1125 KEY_ENUMERATE_SUB_KEYS = 8 1126 KEY_NOTIFY = 16 1127 KEY_CREATE_LINK = 32 1128 KEY_WRITE = 0x20006 1129 KEY_EXECUTE = 0x20019 1130 KEY_READ = 0x20019 1131 KEY_WOW64_64KEY = 0x0100 1132 KEY_WOW64_32KEY = 0x0200 1133 KEY_ALL_ACCESS = 0xf003f 1134 ) 1135 1136 const ( 1137 // do not reorder 1138 REG_NONE = iota 1139 REG_SZ 1140 REG_EXPAND_SZ 1141 REG_BINARY 1142 REG_DWORD_LITTLE_ENDIAN 1143 REG_DWORD_BIG_ENDIAN 1144 REG_LINK 1145 REG_MULTI_SZ 1146 REG_RESOURCE_LIST 1147 REG_FULL_RESOURCE_DESCRIPTOR 1148 REG_RESOURCE_REQUIREMENTS_LIST 1149 REG_QWORD_LITTLE_ENDIAN 1150 REG_DWORD = REG_DWORD_LITTLE_ENDIAN 1151 REG_QWORD = REG_QWORD_LITTLE_ENDIAN 1152 ) 1153 1154 type AddrinfoW struct { 1155 Flags int32 1156 Family int32 1157 Socktype int32 1158 Protocol int32 1159 Addrlen uintptr 1160 Canonname *uint16 1161 Addr uintptr 1162 Next *AddrinfoW 1163 } 1164 1165 const ( 1166 AI_PASSIVE = 1 1167 AI_CANONNAME = 2 1168 AI_NUMERICHOST = 4 1169 ) 1170 1171 type GUID struct { 1172 Data1 uint32 1173 Data2 uint16 1174 Data3 uint16 1175 Data4 [8]byte 1176 } 1177 1178 var WSAID_CONNECTEX = GUID{ 1179 0x25a207b9, 1180 0xddf3, 1181 0x4660, 1182 [8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}, 1183 } 1184 1185 var WSAID_WSASENDMSG = GUID{ 1186 0xa441e712, 1187 0x754f, 1188 0x43ca, 1189 [8]byte{0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d}, 1190 } 1191 1192 var WSAID_WSARECVMSG = GUID{ 1193 0xf689d7c8, 1194 0x6f1f, 1195 0x436b, 1196 [8]byte{0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22}, 1197 } 1198 1199 const ( 1200 FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1 1201 FILE_SKIP_SET_EVENT_ON_HANDLE = 2 1202 ) 1203 1204 const ( 1205 WSAPROTOCOL_LEN = 255 1206 MAX_PROTOCOL_CHAIN = 7 1207 BASE_PROTOCOL = 1 1208 LAYERED_PROTOCOL = 0 1209 1210 XP1_CONNECTIONLESS = 0x00000001 1211 XP1_GUARANTEED_DELIVERY = 0x00000002 1212 XP1_GUARANTEED_ORDER = 0x00000004 1213 XP1_MESSAGE_ORIENTED = 0x00000008 1214 XP1_PSEUDO_STREAM = 0x00000010 1215 XP1_GRACEFUL_CLOSE = 0x00000020 1216 XP1_EXPEDITED_DATA = 0x00000040 1217 XP1_CONNECT_DATA = 0x00000080 1218 XP1_DISCONNECT_DATA = 0x00000100 1219 XP1_SUPPORT_BROADCAST = 0x00000200 1220 XP1_SUPPORT_MULTIPOINT = 0x00000400 1221 XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800 1222 XP1_MULTIPOINT_DATA_PLANE = 0x00001000 1223 XP1_QOS_SUPPORTED = 0x00002000 1224 XP1_UNI_SEND = 0x00008000 1225 XP1_UNI_RECV = 0x00010000 1226 XP1_IFS_HANDLES = 0x00020000 1227 XP1_PARTIAL_MESSAGE = 0x00040000 1228 XP1_SAN_SUPPORT_SDP = 0x00080000 1229 1230 PFL_MULTIPLE_PROTO_ENTRIES = 0x00000001 1231 PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002 1232 PFL_HIDDEN = 0x00000004 1233 PFL_MATCHES_PROTOCOL_ZERO = 0x00000008 1234 PFL_NETWORKDIRECT_PROVIDER = 0x00000010 1235 ) 1236 1237 type WSAProtocolInfo struct { 1238 ServiceFlags1 uint32 1239 ServiceFlags2 uint32 1240 ServiceFlags3 uint32 1241 ServiceFlags4 uint32 1242 ProviderFlags uint32 1243 ProviderId GUID 1244 CatalogEntryId uint32 1245 ProtocolChain WSAProtocolChain 1246 Version int32 1247 AddressFamily int32 1248 MaxSockAddr int32 1249 MinSockAddr int32 1250 SocketType int32 1251 Protocol int32 1252 ProtocolMaxOffset int32 1253 NetworkByteOrder int32 1254 SecurityScheme int32 1255 MessageSize uint32 1256 ProviderReserved uint32 1257 ProtocolName [WSAPROTOCOL_LEN + 1]uint16 1258 } 1259 1260 type WSAProtocolChain struct { 1261 ChainLen int32 1262 ChainEntries [MAX_PROTOCOL_CHAIN]uint32 1263 } 1264 1265 type TCPKeepalive struct { 1266 OnOff uint32 1267 Time uint32 1268 Interval uint32 1269 } 1270 1271 type symbolicLinkReparseBuffer struct { 1272 SubstituteNameOffset uint16 1273 SubstituteNameLength uint16 1274 PrintNameOffset uint16 1275 PrintNameLength uint16 1276 Flags uint32 1277 PathBuffer [1]uint16 1278 } 1279 1280 type mountPointReparseBuffer struct { 1281 SubstituteNameOffset uint16 1282 SubstituteNameLength uint16 1283 PrintNameOffset uint16 1284 PrintNameLength uint16 1285 PathBuffer [1]uint16 1286 } 1287 1288 type reparseDataBuffer struct { 1289 ReparseTag uint32 1290 ReparseDataLength uint16 1291 Reserved uint16 1292 1293 // GenericReparseBuffer 1294 reparseBuffer byte 1295 } 1296 1297 const ( 1298 FSCTL_GET_REPARSE_POINT = 0x900A8 1299 MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024 1300 IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003 1301 IO_REPARSE_TAG_SYMLINK = 0xA000000C 1302 SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1 1303 ) 1304 1305 const ( 1306 ComputerNameNetBIOS = 0 1307 ComputerNameDnsHostname = 1 1308 ComputerNameDnsDomain = 2 1309 ComputerNameDnsFullyQualified = 3 1310 ComputerNamePhysicalNetBIOS = 4 1311 ComputerNamePhysicalDnsHostname = 5 1312 ComputerNamePhysicalDnsDomain = 6 1313 ComputerNamePhysicalDnsFullyQualified = 7 1314 ComputerNameMax = 8 1315 ) 1316 1317 const ( 1318 MOVEFILE_REPLACE_EXISTING = 0x1 1319 MOVEFILE_COPY_ALLOWED = 0x2 1320 MOVEFILE_DELAY_UNTIL_REBOOT = 0x4 1321 MOVEFILE_WRITE_THROUGH = 0x8 1322 MOVEFILE_CREATE_HARDLINK = 0x10 1323 MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x20 1324 ) 1325 1326 const GAA_FLAG_INCLUDE_PREFIX = 0x00000010 1327 1328 const ( 1329 IF_TYPE_OTHER = 1 1330 IF_TYPE_ETHERNET_CSMACD = 6 1331 IF_TYPE_ISO88025_TOKENRING = 9 1332 IF_TYPE_PPP = 23 1333 IF_TYPE_SOFTWARE_LOOPBACK = 24 1334 IF_TYPE_ATM = 37 1335 IF_TYPE_IEEE80211 = 71 1336 IF_TYPE_TUNNEL = 131 1337 IF_TYPE_IEEE1394 = 144 1338 ) 1339 1340 type SocketAddress struct { 1341 Sockaddr *syscall.RawSockaddrAny 1342 SockaddrLength int32 1343 } 1344 1345 type IpAdapterUnicastAddress struct { 1346 Length uint32 1347 Flags uint32 1348 Next *IpAdapterUnicastAddress 1349 Address SocketAddress 1350 PrefixOrigin int32 1351 SuffixOrigin int32 1352 DadState int32 1353 ValidLifetime uint32 1354 PreferredLifetime uint32 1355 LeaseLifetime uint32 1356 OnLinkPrefixLength uint8 1357 } 1358 1359 type IpAdapterAnycastAddress struct { 1360 Length uint32 1361 Flags uint32 1362 Next *IpAdapterAnycastAddress 1363 Address SocketAddress 1364 } 1365 1366 type IpAdapterMulticastAddress struct { 1367 Length uint32 1368 Flags uint32 1369 Next *IpAdapterMulticastAddress 1370 Address SocketAddress 1371 } 1372 1373 type IpAdapterDnsServerAdapter struct { 1374 Length uint32 1375 Reserved uint32 1376 Next *IpAdapterDnsServerAdapter 1377 Address SocketAddress 1378 } 1379 1380 type IpAdapterPrefix struct { 1381 Length uint32 1382 Flags uint32 1383 Next *IpAdapterPrefix 1384 Address SocketAddress 1385 PrefixLength uint32 1386 } 1387 1388 type IpAdapterAddresses struct { 1389 Length uint32 1390 IfIndex uint32 1391 Next *IpAdapterAddresses 1392 AdapterName *byte 1393 FirstUnicastAddress *IpAdapterUnicastAddress 1394 FirstAnycastAddress *IpAdapterAnycastAddress 1395 FirstMulticastAddress *IpAdapterMulticastAddress 1396 FirstDnsServerAddress *IpAdapterDnsServerAdapter 1397 DnsSuffix *uint16 1398 Description *uint16 1399 FriendlyName *uint16 1400 PhysicalAddress [syscall.MAX_ADAPTER_ADDRESS_LENGTH]byte 1401 PhysicalAddressLength uint32 1402 Flags uint32 1403 Mtu uint32 1404 IfType uint32 1405 OperStatus uint32 1406 Ipv6IfIndex uint32 1407 ZoneIndices [16]uint32 1408 FirstPrefix *IpAdapterPrefix 1409 /* more fields might be present here. */ 1410 } 1411 1412 const ( 1413 IfOperStatusUp = 1 1414 IfOperStatusDown = 2 1415 IfOperStatusTesting = 3 1416 IfOperStatusUnknown = 4 1417 IfOperStatusDormant = 5 1418 IfOperStatusNotPresent = 6 1419 IfOperStatusLowerLayerDown = 7 1420 ) 1421 1422 // Console related constants used for the mode parameter to SetConsoleMode. See 1423 // https://docs.microsoft.com/en-us/windows/console/setconsolemode for details. 1424 1425 const ( 1426 ENABLE_PROCESSED_INPUT = 0x1 1427 ENABLE_LINE_INPUT = 0x2 1428 ENABLE_ECHO_INPUT = 0x4 1429 ENABLE_WINDOW_INPUT = 0x8 1430 ENABLE_MOUSE_INPUT = 0x10 1431 ENABLE_INSERT_MODE = 0x20 1432 ENABLE_QUICK_EDIT_MODE = 0x40 1433 ENABLE_EXTENDED_FLAGS = 0x80 1434 ENABLE_AUTO_POSITION = 0x100 1435 ENABLE_VIRTUAL_TERMINAL_INPUT = 0x200 1436 1437 ENABLE_PROCESSED_OUTPUT = 0x1 1438 ENABLE_WRAP_AT_EOL_OUTPUT = 0x2 1439 ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4 1440 DISABLE_NEWLINE_AUTO_RETURN = 0x8 1441 ENABLE_LVB_GRID_WORLDWIDE = 0x10 1442 ) 1443 1444 type Coord struct { 1445 X int16 1446 Y int16 1447 } 1448 1449 type SmallRect struct { 1450 Left int16 1451 Top int16 1452 Right int16 1453 Bottom int16 1454 } 1455 1456 // Used with GetConsoleScreenBuffer to retrieve information about a console 1457 // screen buffer. See 1458 // https://docs.microsoft.com/en-us/windows/console/console-screen-buffer-info-str 1459 // for details. 1460 1461 type ConsoleScreenBufferInfo struct { 1462 Size Coord 1463 CursorPosition Coord 1464 Attributes uint16 1465 Window SmallRect 1466 MaximumWindowSize Coord 1467 } 1468 1469 const UNIX_PATH_MAX = 108 // defined in afunix.h