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