github.com/tidwall/go@v0.0.0-20170415222209-6694a6888b7d/src/syscall/ztypes_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 syscall 6 7 const ( 8 // Windows errors. 9 ERROR_FILE_NOT_FOUND Errno = 2 10 ERROR_PATH_NOT_FOUND Errno = 3 11 ERROR_ACCESS_DENIED Errno = 5 12 ERROR_NO_MORE_FILES Errno = 18 13 ERROR_HANDLE_EOF Errno = 38 14 ERROR_NETNAME_DELETED Errno = 64 15 ERROR_FILE_EXISTS Errno = 80 16 ERROR_BROKEN_PIPE Errno = 109 17 ERROR_BUFFER_OVERFLOW Errno = 111 18 ERROR_INSUFFICIENT_BUFFER Errno = 122 19 ERROR_MOD_NOT_FOUND Errno = 126 20 ERROR_PROC_NOT_FOUND Errno = 127 21 ERROR_DIR_NOT_EMPTY Errno = 145 22 ERROR_ALREADY_EXISTS Errno = 183 23 ERROR_ENVVAR_NOT_FOUND Errno = 203 24 ERROR_MORE_DATA Errno = 234 25 ERROR_OPERATION_ABORTED Errno = 995 26 ERROR_IO_PENDING Errno = 997 27 ERROR_NOT_FOUND Errno = 1168 28 ERROR_PRIVILEGE_NOT_HELD Errno = 1314 29 WSAEACCES Errno = 10013 30 WSAECONNABORTED Errno = 10053 31 WSAECONNRESET Errno = 10054 32 ) 33 34 const ( 35 // Invented values to support what package os expects. 36 O_RDONLY = 0x00000 37 O_WRONLY = 0x00001 38 O_RDWR = 0x00002 39 O_CREAT = 0x00040 40 O_EXCL = 0x00080 41 O_NOCTTY = 0x00100 42 O_TRUNC = 0x00200 43 O_NONBLOCK = 0x00800 44 O_APPEND = 0x00400 45 O_SYNC = 0x01000 46 O_ASYNC = 0x02000 47 O_CLOEXEC = 0x80000 48 ) 49 50 const ( 51 // More invented values for signals 52 SIGHUP = Signal(0x1) 53 SIGINT = Signal(0x2) 54 SIGQUIT = Signal(0x3) 55 SIGILL = Signal(0x4) 56 SIGTRAP = Signal(0x5) 57 SIGABRT = Signal(0x6) 58 SIGBUS = Signal(0x7) 59 SIGFPE = Signal(0x8) 60 SIGKILL = Signal(0x9) 61 SIGSEGV = Signal(0xb) 62 SIGPIPE = Signal(0xd) 63 SIGALRM = Signal(0xe) 64 SIGTERM = Signal(0xf) 65 ) 66 67 var signals = [...]string{ 68 1: "hangup", 69 2: "interrupt", 70 3: "quit", 71 4: "illegal instruction", 72 5: "trace/breakpoint trap", 73 6: "aborted", 74 7: "bus error", 75 8: "floating point exception", 76 9: "killed", 77 10: "user defined signal 1", 78 11: "segmentation fault", 79 12: "user defined signal 2", 80 13: "broken pipe", 81 14: "alarm clock", 82 15: "terminated", 83 } 84 85 const ( 86 GENERIC_READ = 0x80000000 87 GENERIC_WRITE = 0x40000000 88 GENERIC_EXECUTE = 0x20000000 89 GENERIC_ALL = 0x10000000 90 91 FILE_LIST_DIRECTORY = 0x00000001 92 FILE_APPEND_DATA = 0x00000004 93 FILE_WRITE_ATTRIBUTES = 0x00000100 94 95 FILE_SHARE_READ = 0x00000001 96 FILE_SHARE_WRITE = 0x00000002 97 FILE_SHARE_DELETE = 0x00000004 98 FILE_ATTRIBUTE_READONLY = 0x00000001 99 FILE_ATTRIBUTE_HIDDEN = 0x00000002 100 FILE_ATTRIBUTE_SYSTEM = 0x00000004 101 FILE_ATTRIBUTE_DIRECTORY = 0x00000010 102 FILE_ATTRIBUTE_ARCHIVE = 0x00000020 103 FILE_ATTRIBUTE_NORMAL = 0x00000080 104 FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400 105 106 INVALID_FILE_ATTRIBUTES = 0xffffffff 107 108 CREATE_NEW = 1 109 CREATE_ALWAYS = 2 110 OPEN_EXISTING = 3 111 OPEN_ALWAYS = 4 112 TRUNCATE_EXISTING = 5 113 114 FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000 115 FILE_FLAG_BACKUP_SEMANTICS = 0x02000000 116 FILE_FLAG_OVERLAPPED = 0x40000000 117 118 HANDLE_FLAG_INHERIT = 0x00000001 119 STARTF_USESTDHANDLES = 0x00000100 120 STARTF_USESHOWWINDOW = 0x00000001 121 DUPLICATE_CLOSE_SOURCE = 0x00000001 122 DUPLICATE_SAME_ACCESS = 0x00000002 123 124 STD_INPUT_HANDLE = -10 125 STD_OUTPUT_HANDLE = -11 126 STD_ERROR_HANDLE = -12 127 128 FILE_BEGIN = 0 129 FILE_CURRENT = 1 130 FILE_END = 2 131 132 LANG_ENGLISH = 0x09 133 SUBLANG_ENGLISH_US = 0x01 134 135 FORMAT_MESSAGE_ALLOCATE_BUFFER = 256 136 FORMAT_MESSAGE_IGNORE_INSERTS = 512 137 FORMAT_MESSAGE_FROM_STRING = 1024 138 FORMAT_MESSAGE_FROM_HMODULE = 2048 139 FORMAT_MESSAGE_FROM_SYSTEM = 4096 140 FORMAT_MESSAGE_ARGUMENT_ARRAY = 8192 141 FORMAT_MESSAGE_MAX_WIDTH_MASK = 255 142 143 MAX_PATH = 260 144 MAX_LONG_PATH = 32768 145 146 MAX_COMPUTERNAME_LENGTH = 15 147 148 TIME_ZONE_ID_UNKNOWN = 0 149 TIME_ZONE_ID_STANDARD = 1 150 151 TIME_ZONE_ID_DAYLIGHT = 2 152 IGNORE = 0 153 INFINITE = 0xffffffff 154 155 WAIT_TIMEOUT = 258 156 WAIT_ABANDONED = 0x00000080 157 WAIT_OBJECT_0 = 0x00000000 158 WAIT_FAILED = 0xFFFFFFFF 159 160 CREATE_NEW_PROCESS_GROUP = 0x00000200 161 CREATE_UNICODE_ENVIRONMENT = 0x00000400 162 163 PROCESS_TERMINATE = 1 164 PROCESS_QUERY_INFORMATION = 0x00000400 165 SYNCHRONIZE = 0x00100000 166 167 PAGE_READONLY = 0x02 168 PAGE_READWRITE = 0x04 169 PAGE_WRITECOPY = 0x08 170 PAGE_EXECUTE_READ = 0x20 171 PAGE_EXECUTE_READWRITE = 0x40 172 PAGE_EXECUTE_WRITECOPY = 0x80 173 174 FILE_MAP_COPY = 0x01 175 FILE_MAP_WRITE = 0x02 176 FILE_MAP_READ = 0x04 177 FILE_MAP_EXECUTE = 0x20 178 179 CTRL_C_EVENT = 0 180 CTRL_BREAK_EVENT = 1 181 ) 182 183 const ( 184 // flags for CreateToolhelp32Snapshot 185 TH32CS_SNAPHEAPLIST = 0x01 186 TH32CS_SNAPPROCESS = 0x02 187 TH32CS_SNAPTHREAD = 0x04 188 TH32CS_SNAPMODULE = 0x08 189 TH32CS_SNAPMODULE32 = 0x10 190 TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST | TH32CS_SNAPMODULE | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD 191 TH32CS_INHERIT = 0x80000000 192 ) 193 194 const ( 195 // do not reorder 196 FILE_NOTIFY_CHANGE_FILE_NAME = 1 << iota 197 FILE_NOTIFY_CHANGE_DIR_NAME 198 FILE_NOTIFY_CHANGE_ATTRIBUTES 199 FILE_NOTIFY_CHANGE_SIZE 200 FILE_NOTIFY_CHANGE_LAST_WRITE 201 FILE_NOTIFY_CHANGE_LAST_ACCESS 202 FILE_NOTIFY_CHANGE_CREATION 203 ) 204 205 const ( 206 // do not reorder 207 FILE_ACTION_ADDED = iota + 1 208 FILE_ACTION_REMOVED 209 FILE_ACTION_MODIFIED 210 FILE_ACTION_RENAMED_OLD_NAME 211 FILE_ACTION_RENAMED_NEW_NAME 212 ) 213 214 const ( 215 // wincrypt.h 216 PROV_RSA_FULL = 1 217 PROV_RSA_SIG = 2 218 PROV_DSS = 3 219 PROV_FORTEZZA = 4 220 PROV_MS_EXCHANGE = 5 221 PROV_SSL = 6 222 PROV_RSA_SCHANNEL = 12 223 PROV_DSS_DH = 13 224 PROV_EC_ECDSA_SIG = 14 225 PROV_EC_ECNRA_SIG = 15 226 PROV_EC_ECDSA_FULL = 16 227 PROV_EC_ECNRA_FULL = 17 228 PROV_DH_SCHANNEL = 18 229 PROV_SPYRUS_LYNKS = 20 230 PROV_RNG = 21 231 PROV_INTEL_SEC = 22 232 PROV_REPLACE_OWF = 23 233 PROV_RSA_AES = 24 234 CRYPT_VERIFYCONTEXT = 0xF0000000 235 CRYPT_NEWKEYSET = 0x00000008 236 CRYPT_DELETEKEYSET = 0x00000010 237 CRYPT_MACHINE_KEYSET = 0x00000020 238 CRYPT_SILENT = 0x00000040 239 CRYPT_DEFAULT_CONTAINER_OPTIONAL = 0x00000080 240 241 USAGE_MATCH_TYPE_AND = 0 242 USAGE_MATCH_TYPE_OR = 1 243 244 X509_ASN_ENCODING = 0x00000001 245 PKCS_7_ASN_ENCODING = 0x00010000 246 247 CERT_STORE_PROV_MEMORY = 2 248 249 CERT_STORE_ADD_ALWAYS = 4 250 251 CERT_STORE_DEFER_CLOSE_UNTIL_LAST_FREE_FLAG = 0x00000004 252 253 CERT_TRUST_NO_ERROR = 0x00000000 254 CERT_TRUST_IS_NOT_TIME_VALID = 0x00000001 255 CERT_TRUST_IS_REVOKED = 0x00000004 256 CERT_TRUST_IS_NOT_SIGNATURE_VALID = 0x00000008 257 CERT_TRUST_IS_NOT_VALID_FOR_USAGE = 0x00000010 258 CERT_TRUST_IS_UNTRUSTED_ROOT = 0x00000020 259 CERT_TRUST_REVOCATION_STATUS_UNKNOWN = 0x00000040 260 CERT_TRUST_IS_CYCLIC = 0x00000080 261 CERT_TRUST_INVALID_EXTENSION = 0x00000100 262 CERT_TRUST_INVALID_POLICY_CONSTRAINTS = 0x00000200 263 CERT_TRUST_INVALID_BASIC_CONSTRAINTS = 0x00000400 264 CERT_TRUST_INVALID_NAME_CONSTRAINTS = 0x00000800 265 CERT_TRUST_HAS_NOT_SUPPORTED_NAME_CONSTRAINT = 0x00001000 266 CERT_TRUST_HAS_NOT_DEFINED_NAME_CONSTRAINT = 0x00002000 267 CERT_TRUST_HAS_NOT_PERMITTED_NAME_CONSTRAINT = 0x00004000 268 CERT_TRUST_HAS_EXCLUDED_NAME_CONSTRAINT = 0x00008000 269 CERT_TRUST_IS_OFFLINE_REVOCATION = 0x01000000 270 CERT_TRUST_NO_ISSUANCE_CHAIN_POLICY = 0x02000000 271 CERT_TRUST_IS_EXPLICIT_DISTRUST = 0x04000000 272 CERT_TRUST_HAS_NOT_SUPPORTED_CRITICAL_EXT = 0x08000000 273 274 CERT_CHAIN_POLICY_BASE = 1 275 CERT_CHAIN_POLICY_AUTHENTICODE = 2 276 CERT_CHAIN_POLICY_AUTHENTICODE_TS = 3 277 CERT_CHAIN_POLICY_SSL = 4 278 CERT_CHAIN_POLICY_BASIC_CONSTRAINTS = 5 279 CERT_CHAIN_POLICY_NT_AUTH = 6 280 CERT_CHAIN_POLICY_MICROSOFT_ROOT = 7 281 CERT_CHAIN_POLICY_EV = 8 282 283 CERT_E_EXPIRED = 0x800B0101 284 CERT_E_ROLE = 0x800B0103 285 CERT_E_PURPOSE = 0x800B0106 286 CERT_E_UNTRUSTEDROOT = 0x800B0109 287 CERT_E_CN_NO_MATCH = 0x800B010F 288 289 AUTHTYPE_CLIENT = 1 290 AUTHTYPE_SERVER = 2 291 ) 292 293 var ( 294 OID_PKIX_KP_SERVER_AUTH = []byte("1.3.6.1.5.5.7.3.1\x00") 295 OID_SERVER_GATED_CRYPTO = []byte("1.3.6.1.4.1.311.10.3.3\x00") 296 OID_SGC_NETSCAPE = []byte("2.16.840.1.113730.4.1\x00") 297 ) 298 299 // Invented values to support what package os expects. 300 type Timeval struct { 301 Sec int32 302 Usec int32 303 } 304 305 func (tv *Timeval) Nanoseconds() int64 { 306 return (int64(tv.Sec)*1e6 + int64(tv.Usec)) * 1e3 307 } 308 309 func NsecToTimeval(nsec int64) (tv Timeval) { 310 tv.Sec = int32(nsec / 1e9) 311 tv.Usec = int32(nsec % 1e9 / 1e3) 312 return 313 } 314 315 type SecurityAttributes struct { 316 Length uint32 317 SecurityDescriptor uintptr 318 InheritHandle uint32 319 } 320 321 type Overlapped struct { 322 Internal uintptr 323 InternalHigh uintptr 324 Offset uint32 325 OffsetHigh uint32 326 HEvent Handle 327 } 328 329 type FileNotifyInformation struct { 330 NextEntryOffset uint32 331 Action uint32 332 FileNameLength uint32 333 FileName uint16 334 } 335 336 type Filetime struct { 337 LowDateTime uint32 338 HighDateTime uint32 339 } 340 341 // Nanoseconds returns Filetime ft in nanoseconds 342 // since Epoch (00:00:00 UTC, January 1, 1970). 343 func (ft *Filetime) Nanoseconds() int64 { 344 // 100-nanosecond intervals since January 1, 1601 345 nsec := int64(ft.HighDateTime)<<32 + int64(ft.LowDateTime) 346 // change starting time to the Epoch (00:00:00 UTC, January 1, 1970) 347 nsec -= 116444736000000000 348 // convert into nanoseconds 349 nsec *= 100 350 return nsec 351 } 352 353 func NsecToFiletime(nsec int64) (ft Filetime) { 354 // convert into 100-nanosecond 355 nsec /= 100 356 // change starting time to January 1, 1601 357 nsec += 116444736000000000 358 // split into high / low 359 ft.LowDateTime = uint32(nsec & 0xffffffff) 360 ft.HighDateTime = uint32(nsec >> 32 & 0xffffffff) 361 return ft 362 } 363 364 type Win32finddata struct { 365 FileAttributes uint32 366 CreationTime Filetime 367 LastAccessTime Filetime 368 LastWriteTime Filetime 369 FileSizeHigh uint32 370 FileSizeLow uint32 371 Reserved0 uint32 372 Reserved1 uint32 373 FileName [MAX_PATH - 1]uint16 374 AlternateFileName [13]uint16 375 } 376 377 // This is the actual system call structure. 378 // Win32finddata is what we committed to in Go 1. 379 type win32finddata1 struct { 380 FileAttributes uint32 381 CreationTime Filetime 382 LastAccessTime Filetime 383 LastWriteTime Filetime 384 FileSizeHigh uint32 385 FileSizeLow uint32 386 Reserved0 uint32 387 Reserved1 uint32 388 FileName [MAX_PATH]uint16 389 AlternateFileName [14]uint16 390 } 391 392 func copyFindData(dst *Win32finddata, src *win32finddata1) { 393 dst.FileAttributes = src.FileAttributes 394 dst.CreationTime = src.CreationTime 395 dst.LastAccessTime = src.LastAccessTime 396 dst.LastWriteTime = src.LastWriteTime 397 dst.FileSizeHigh = src.FileSizeHigh 398 dst.FileSizeLow = src.FileSizeLow 399 dst.Reserved0 = src.Reserved0 400 dst.Reserved1 = src.Reserved1 401 402 // The src is 1 element bigger than dst, but it must be NUL. 403 copy(dst.FileName[:], src.FileName[:]) 404 copy(dst.AlternateFileName[:], src.AlternateFileName[:]) 405 } 406 407 type ByHandleFileInformation struct { 408 FileAttributes uint32 409 CreationTime Filetime 410 LastAccessTime Filetime 411 LastWriteTime Filetime 412 VolumeSerialNumber uint32 413 FileSizeHigh uint32 414 FileSizeLow uint32 415 NumberOfLinks uint32 416 FileIndexHigh uint32 417 FileIndexLow uint32 418 } 419 420 const ( 421 GetFileExInfoStandard = 0 422 GetFileExMaxInfoLevel = 1 423 ) 424 425 type Win32FileAttributeData struct { 426 FileAttributes uint32 427 CreationTime Filetime 428 LastAccessTime Filetime 429 LastWriteTime Filetime 430 FileSizeHigh uint32 431 FileSizeLow uint32 432 } 433 434 // ShowWindow constants 435 const ( 436 // winuser.h 437 SW_HIDE = 0 438 SW_NORMAL = 1 439 SW_SHOWNORMAL = 1 440 SW_SHOWMINIMIZED = 2 441 SW_SHOWMAXIMIZED = 3 442 SW_MAXIMIZE = 3 443 SW_SHOWNOACTIVATE = 4 444 SW_SHOW = 5 445 SW_MINIMIZE = 6 446 SW_SHOWMINNOACTIVE = 7 447 SW_SHOWNA = 8 448 SW_RESTORE = 9 449 SW_SHOWDEFAULT = 10 450 SW_FORCEMINIMIZE = 11 451 ) 452 453 type StartupInfo struct { 454 Cb uint32 455 _ *uint16 456 Desktop *uint16 457 Title *uint16 458 X uint32 459 Y uint32 460 XSize uint32 461 YSize uint32 462 XCountChars uint32 463 YCountChars uint32 464 FillAttribute uint32 465 Flags uint32 466 ShowWindow uint16 467 _ uint16 468 _ *byte 469 StdInput Handle 470 StdOutput Handle 471 StdErr Handle 472 } 473 474 type ProcessInformation struct { 475 Process Handle 476 Thread Handle 477 ProcessId uint32 478 ThreadId uint32 479 } 480 481 type ProcessEntry32 struct { 482 Size uint32 483 Usage uint32 484 ProcessID uint32 485 DefaultHeapID uintptr 486 ModuleID uint32 487 Threads uint32 488 ParentProcessID uint32 489 PriClassBase int32 490 Flags uint32 491 ExeFile [MAX_PATH]uint16 492 } 493 494 type Systemtime struct { 495 Year uint16 496 Month uint16 497 DayOfWeek uint16 498 Day uint16 499 Hour uint16 500 Minute uint16 501 Second uint16 502 Milliseconds uint16 503 } 504 505 type Timezoneinformation struct { 506 Bias int32 507 StandardName [32]uint16 508 StandardDate Systemtime 509 StandardBias int32 510 DaylightName [32]uint16 511 DaylightDate Systemtime 512 DaylightBias int32 513 } 514 515 // Socket related. 516 517 const ( 518 AF_UNSPEC = 0 519 AF_UNIX = 1 520 AF_INET = 2 521 AF_INET6 = 23 522 AF_NETBIOS = 17 523 524 SOCK_STREAM = 1 525 SOCK_DGRAM = 2 526 SOCK_RAW = 3 527 SOCK_SEQPACKET = 5 528 529 IPPROTO_IP = 0 530 IPPROTO_IPV6 = 0x29 531 IPPROTO_TCP = 6 532 IPPROTO_UDP = 17 533 534 SOL_SOCKET = 0xffff 535 SO_REUSEADDR = 4 536 SO_KEEPALIVE = 8 537 SO_DONTROUTE = 16 538 SO_BROADCAST = 32 539 SO_LINGER = 128 540 SO_RCVBUF = 0x1002 541 SO_SNDBUF = 0x1001 542 SO_UPDATE_ACCEPT_CONTEXT = 0x700b 543 SO_UPDATE_CONNECT_CONTEXT = 0x7010 544 545 IOC_OUT = 0x40000000 546 IOC_IN = 0x80000000 547 IOC_VENDOR = 0x18000000 548 IOC_INOUT = IOC_IN | IOC_OUT 549 IOC_WS2 = 0x08000000 550 SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6 551 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4 552 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12 553 554 // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460 555 556 IP_TOS = 0x3 557 IP_TTL = 0x4 558 IP_MULTICAST_IF = 0x9 559 IP_MULTICAST_TTL = 0xa 560 IP_MULTICAST_LOOP = 0xb 561 IP_ADD_MEMBERSHIP = 0xc 562 IP_DROP_MEMBERSHIP = 0xd 563 564 IPV6_V6ONLY = 0x1b 565 IPV6_UNICAST_HOPS = 0x4 566 IPV6_MULTICAST_IF = 0x9 567 IPV6_MULTICAST_HOPS = 0xa 568 IPV6_MULTICAST_LOOP = 0xb 569 IPV6_JOIN_GROUP = 0xc 570 IPV6_LEAVE_GROUP = 0xd 571 572 SOMAXCONN = 0x7fffffff 573 574 TCP_NODELAY = 1 575 576 SHUT_RD = 0 577 SHUT_WR = 1 578 SHUT_RDWR = 2 579 580 WSADESCRIPTION_LEN = 256 581 WSASYS_STATUS_LEN = 128 582 ) 583 584 type WSABuf struct { 585 Len uint32 586 Buf *byte 587 } 588 589 // Invented values to support what package os expects. 590 const ( 591 S_IFMT = 0x1f000 592 S_IFIFO = 0x1000 593 S_IFCHR = 0x2000 594 S_IFDIR = 0x4000 595 S_IFBLK = 0x6000 596 S_IFREG = 0x8000 597 S_IFLNK = 0xa000 598 S_IFSOCK = 0xc000 599 S_ISUID = 0x800 600 S_ISGID = 0x400 601 S_ISVTX = 0x200 602 S_IRUSR = 0x100 603 S_IWRITE = 0x80 604 S_IWUSR = 0x80 605 S_IXUSR = 0x40 606 ) 607 608 const ( 609 FILE_TYPE_CHAR = 0x0002 610 FILE_TYPE_DISK = 0x0001 611 FILE_TYPE_PIPE = 0x0003 612 FILE_TYPE_REMOTE = 0x8000 613 FILE_TYPE_UNKNOWN = 0x0000 614 ) 615 616 type Hostent struct { 617 Name *byte 618 Aliases **byte 619 AddrType uint16 620 Length uint16 621 AddrList **byte 622 } 623 624 type Protoent struct { 625 Name *byte 626 Aliases **byte 627 Proto uint16 628 } 629 630 const ( 631 DNS_TYPE_A = 0x0001 632 DNS_TYPE_NS = 0x0002 633 DNS_TYPE_MD = 0x0003 634 DNS_TYPE_MF = 0x0004 635 DNS_TYPE_CNAME = 0x0005 636 DNS_TYPE_SOA = 0x0006 637 DNS_TYPE_MB = 0x0007 638 DNS_TYPE_MG = 0x0008 639 DNS_TYPE_MR = 0x0009 640 DNS_TYPE_NULL = 0x000a 641 DNS_TYPE_WKS = 0x000b 642 DNS_TYPE_PTR = 0x000c 643 DNS_TYPE_HINFO = 0x000d 644 DNS_TYPE_MINFO = 0x000e 645 DNS_TYPE_MX = 0x000f 646 DNS_TYPE_TEXT = 0x0010 647 DNS_TYPE_RP = 0x0011 648 DNS_TYPE_AFSDB = 0x0012 649 DNS_TYPE_X25 = 0x0013 650 DNS_TYPE_ISDN = 0x0014 651 DNS_TYPE_RT = 0x0015 652 DNS_TYPE_NSAP = 0x0016 653 DNS_TYPE_NSAPPTR = 0x0017 654 DNS_TYPE_SIG = 0x0018 655 DNS_TYPE_KEY = 0x0019 656 DNS_TYPE_PX = 0x001a 657 DNS_TYPE_GPOS = 0x001b 658 DNS_TYPE_AAAA = 0x001c 659 DNS_TYPE_LOC = 0x001d 660 DNS_TYPE_NXT = 0x001e 661 DNS_TYPE_EID = 0x001f 662 DNS_TYPE_NIMLOC = 0x0020 663 DNS_TYPE_SRV = 0x0021 664 DNS_TYPE_ATMA = 0x0022 665 DNS_TYPE_NAPTR = 0x0023 666 DNS_TYPE_KX = 0x0024 667 DNS_TYPE_CERT = 0x0025 668 DNS_TYPE_A6 = 0x0026 669 DNS_TYPE_DNAME = 0x0027 670 DNS_TYPE_SINK = 0x0028 671 DNS_TYPE_OPT = 0x0029 672 DNS_TYPE_DS = 0x002B 673 DNS_TYPE_RRSIG = 0x002E 674 DNS_TYPE_NSEC = 0x002F 675 DNS_TYPE_DNSKEY = 0x0030 676 DNS_TYPE_DHCID = 0x0031 677 DNS_TYPE_UINFO = 0x0064 678 DNS_TYPE_UID = 0x0065 679 DNS_TYPE_GID = 0x0066 680 DNS_TYPE_UNSPEC = 0x0067 681 DNS_TYPE_ADDRS = 0x00f8 682 DNS_TYPE_TKEY = 0x00f9 683 DNS_TYPE_TSIG = 0x00fa 684 DNS_TYPE_IXFR = 0x00fb 685 DNS_TYPE_AXFR = 0x00fc 686 DNS_TYPE_MAILB = 0x00fd 687 DNS_TYPE_MAILA = 0x00fe 688 DNS_TYPE_ALL = 0x00ff 689 DNS_TYPE_ANY = 0x00ff 690 DNS_TYPE_WINS = 0xff01 691 DNS_TYPE_WINSR = 0xff02 692 DNS_TYPE_NBSTAT = 0xff01 693 ) 694 695 const ( 696 DNS_INFO_NO_RECORDS = 0x251D 697 ) 698 699 const ( 700 // flags inside DNSRecord.Dw 701 DnsSectionQuestion = 0x0000 702 DnsSectionAnswer = 0x0001 703 DnsSectionAuthority = 0x0002 704 DnsSectionAdditional = 0x0003 705 ) 706 707 type DNSSRVData struct { 708 Target *uint16 709 Priority uint16 710 Weight uint16 711 Port uint16 712 Pad uint16 713 } 714 715 type DNSPTRData struct { 716 Host *uint16 717 } 718 719 type DNSMXData struct { 720 NameExchange *uint16 721 Preference uint16 722 Pad uint16 723 } 724 725 type DNSTXTData struct { 726 StringCount uint16 727 StringArray [1]*uint16 728 } 729 730 type DNSRecord struct { 731 Next *DNSRecord 732 Name *uint16 733 Type uint16 734 Length uint16 735 Dw uint32 736 Ttl uint32 737 Reserved uint32 738 Data [40]byte 739 } 740 741 const ( 742 TF_DISCONNECT = 1 743 TF_REUSE_SOCKET = 2 744 TF_WRITE_BEHIND = 4 745 TF_USE_DEFAULT_WORKER = 0 746 TF_USE_SYSTEM_THREAD = 16 747 TF_USE_KERNEL_APC = 32 748 ) 749 750 type TransmitFileBuffers struct { 751 Head uintptr 752 HeadLength uint32 753 Tail uintptr 754 TailLength uint32 755 } 756 757 const ( 758 IFF_UP = 1 759 IFF_BROADCAST = 2 760 IFF_LOOPBACK = 4 761 IFF_POINTTOPOINT = 8 762 IFF_MULTICAST = 16 763 ) 764 765 const SIO_GET_INTERFACE_LIST = 0x4004747F 766 767 // TODO(mattn): SockaddrGen is union of sockaddr/sockaddr_in/sockaddr_in6_old. 768 // will be fixed to change variable type as suitable. 769 770 type SockaddrGen [24]byte 771 772 type InterfaceInfo struct { 773 Flags uint32 774 Address SockaddrGen 775 BroadcastAddress SockaddrGen 776 Netmask SockaddrGen 777 } 778 779 type IpAddressString struct { 780 String [16]byte 781 } 782 783 type IpMaskString IpAddressString 784 785 type IpAddrString struct { 786 Next *IpAddrString 787 IpAddress IpAddressString 788 IpMask IpMaskString 789 Context uint32 790 } 791 792 const MAX_ADAPTER_NAME_LENGTH = 256 793 const MAX_ADAPTER_DESCRIPTION_LENGTH = 128 794 const MAX_ADAPTER_ADDRESS_LENGTH = 8 795 796 type IpAdapterInfo struct { 797 Next *IpAdapterInfo 798 ComboIndex uint32 799 AdapterName [MAX_ADAPTER_NAME_LENGTH + 4]byte 800 Description [MAX_ADAPTER_DESCRIPTION_LENGTH + 4]byte 801 AddressLength uint32 802 Address [MAX_ADAPTER_ADDRESS_LENGTH]byte 803 Index uint32 804 Type uint32 805 DhcpEnabled uint32 806 CurrentIpAddress *IpAddrString 807 IpAddressList IpAddrString 808 GatewayList IpAddrString 809 DhcpServer IpAddrString 810 HaveWins bool 811 PrimaryWinsServer IpAddrString 812 SecondaryWinsServer IpAddrString 813 LeaseObtained int64 814 LeaseExpires int64 815 } 816 817 const MAXLEN_PHYSADDR = 8 818 const MAX_INTERFACE_NAME_LEN = 256 819 const MAXLEN_IFDESCR = 256 820 821 type MibIfRow struct { 822 Name [MAX_INTERFACE_NAME_LEN]uint16 823 Index uint32 824 Type uint32 825 Mtu uint32 826 Speed uint32 827 PhysAddrLen uint32 828 PhysAddr [MAXLEN_PHYSADDR]byte 829 AdminStatus uint32 830 OperStatus uint32 831 LastChange uint32 832 InOctets uint32 833 InUcastPkts uint32 834 InNUcastPkts uint32 835 InDiscards uint32 836 InErrors uint32 837 InUnknownProtos uint32 838 OutOctets uint32 839 OutUcastPkts uint32 840 OutNUcastPkts uint32 841 OutDiscards uint32 842 OutErrors uint32 843 OutQLen uint32 844 DescrLen uint32 845 Descr [MAXLEN_IFDESCR]byte 846 } 847 848 type CertContext struct { 849 EncodingType uint32 850 EncodedCert *byte 851 Length uint32 852 CertInfo uintptr 853 Store Handle 854 } 855 856 type CertChainContext struct { 857 Size uint32 858 TrustStatus CertTrustStatus 859 ChainCount uint32 860 Chains **CertSimpleChain 861 LowerQualityChainCount uint32 862 LowerQualityChains **CertChainContext 863 HasRevocationFreshnessTime uint32 864 RevocationFreshnessTime uint32 865 } 866 867 type CertSimpleChain struct { 868 Size uint32 869 TrustStatus CertTrustStatus 870 NumElements uint32 871 Elements **CertChainElement 872 TrustListInfo uintptr 873 HasRevocationFreshnessTime uint32 874 RevocationFreshnessTime uint32 875 } 876 877 type CertChainElement struct { 878 Size uint32 879 CertContext *CertContext 880 TrustStatus CertTrustStatus 881 RevocationInfo *CertRevocationInfo 882 IssuanceUsage *CertEnhKeyUsage 883 ApplicationUsage *CertEnhKeyUsage 884 ExtendedErrorInfo *uint16 885 } 886 887 type CertRevocationInfo struct { 888 Size uint32 889 RevocationResult uint32 890 RevocationOid *byte 891 OidSpecificInfo uintptr 892 HasFreshnessTime uint32 893 FreshnessTime uint32 894 CrlInfo uintptr // *CertRevocationCrlInfo 895 } 896 897 type CertTrustStatus struct { 898 ErrorStatus uint32 899 InfoStatus uint32 900 } 901 902 type CertUsageMatch struct { 903 Type uint32 904 Usage CertEnhKeyUsage 905 } 906 907 type CertEnhKeyUsage struct { 908 Length uint32 909 UsageIdentifiers **byte 910 } 911 912 type CertChainPara struct { 913 Size uint32 914 RequestedUsage CertUsageMatch 915 RequstedIssuancePolicy CertUsageMatch 916 URLRetrievalTimeout uint32 917 CheckRevocationFreshnessTime uint32 918 RevocationFreshnessTime uint32 919 CacheResync *Filetime 920 } 921 922 type CertChainPolicyPara struct { 923 Size uint32 924 Flags uint32 925 ExtraPolicyPara uintptr 926 } 927 928 type SSLExtraCertChainPolicyPara struct { 929 Size uint32 930 AuthType uint32 931 Checks uint32 932 ServerName *uint16 933 } 934 935 type CertChainPolicyStatus struct { 936 Size uint32 937 Error uint32 938 ChainIndex uint32 939 ElementIndex uint32 940 ExtraPolicyStatus uintptr 941 } 942 943 const ( 944 // do not reorder 945 HKEY_CLASSES_ROOT = 0x80000000 + iota 946 HKEY_CURRENT_USER 947 HKEY_LOCAL_MACHINE 948 HKEY_USERS 949 HKEY_PERFORMANCE_DATA 950 HKEY_CURRENT_CONFIG 951 HKEY_DYN_DATA 952 953 KEY_QUERY_VALUE = 1 954 KEY_SET_VALUE = 2 955 KEY_CREATE_SUB_KEY = 4 956 KEY_ENUMERATE_SUB_KEYS = 8 957 KEY_NOTIFY = 16 958 KEY_CREATE_LINK = 32 959 KEY_WRITE = 0x20006 960 KEY_EXECUTE = 0x20019 961 KEY_READ = 0x20019 962 KEY_WOW64_64KEY = 0x0100 963 KEY_WOW64_32KEY = 0x0200 964 KEY_ALL_ACCESS = 0xf003f 965 ) 966 967 const ( 968 // do not reorder 969 REG_NONE = iota 970 REG_SZ 971 REG_EXPAND_SZ 972 REG_BINARY 973 REG_DWORD_LITTLE_ENDIAN 974 REG_DWORD_BIG_ENDIAN 975 REG_LINK 976 REG_MULTI_SZ 977 REG_RESOURCE_LIST 978 REG_FULL_RESOURCE_DESCRIPTOR 979 REG_RESOURCE_REQUIREMENTS_LIST 980 REG_QWORD_LITTLE_ENDIAN 981 REG_DWORD = REG_DWORD_LITTLE_ENDIAN 982 REG_QWORD = REG_QWORD_LITTLE_ENDIAN 983 ) 984 985 type AddrinfoW struct { 986 Flags int32 987 Family int32 988 Socktype int32 989 Protocol int32 990 Addrlen uintptr 991 Canonname *uint16 992 Addr uintptr 993 Next *AddrinfoW 994 } 995 996 const ( 997 AI_PASSIVE = 1 998 AI_CANONNAME = 2 999 AI_NUMERICHOST = 4 1000 ) 1001 1002 type GUID struct { 1003 Data1 uint32 1004 Data2 uint16 1005 Data3 uint16 1006 Data4 [8]byte 1007 } 1008 1009 var WSAID_CONNECTEX = GUID{ 1010 0x25a207b9, 1011 0xddf3, 1012 0x4660, 1013 [8]byte{0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}, 1014 } 1015 1016 const ( 1017 FILE_SKIP_COMPLETION_PORT_ON_SUCCESS = 1 1018 FILE_SKIP_SET_EVENT_ON_HANDLE = 2 1019 ) 1020 1021 const ( 1022 WSAPROTOCOL_LEN = 255 1023 MAX_PROTOCOL_CHAIN = 7 1024 BASE_PROTOCOL = 1 1025 LAYERED_PROTOCOL = 0 1026 1027 XP1_CONNECTIONLESS = 0x00000001 1028 XP1_GUARANTEED_DELIVERY = 0x00000002 1029 XP1_GUARANTEED_ORDER = 0x00000004 1030 XP1_MESSAGE_ORIENTED = 0x00000008 1031 XP1_PSEUDO_STREAM = 0x00000010 1032 XP1_GRACEFUL_CLOSE = 0x00000020 1033 XP1_EXPEDITED_DATA = 0x00000040 1034 XP1_CONNECT_DATA = 0x00000080 1035 XP1_DISCONNECT_DATA = 0x00000100 1036 XP1_SUPPORT_BROADCAST = 0x00000200 1037 XP1_SUPPORT_MULTIPOINT = 0x00000400 1038 XP1_MULTIPOINT_CONTROL_PLANE = 0x00000800 1039 XP1_MULTIPOINT_DATA_PLANE = 0x00001000 1040 XP1_QOS_SUPPORTED = 0x00002000 1041 XP1_UNI_SEND = 0x00008000 1042 XP1_UNI_RECV = 0x00010000 1043 XP1_IFS_HANDLES = 0x00020000 1044 XP1_PARTIAL_MESSAGE = 0x00040000 1045 XP1_SAN_SUPPORT_SDP = 0x00080000 1046 1047 PFL_MULTIPLE_PROTO_ENTRIES = 0x00000001 1048 PFL_RECOMMENDED_PROTO_ENTRY = 0x00000002 1049 PFL_HIDDEN = 0x00000004 1050 PFL_MATCHES_PROTOCOL_ZERO = 0x00000008 1051 PFL_NETWORKDIRECT_PROVIDER = 0x00000010 1052 ) 1053 1054 type WSAProtocolInfo struct { 1055 ServiceFlags1 uint32 1056 ServiceFlags2 uint32 1057 ServiceFlags3 uint32 1058 ServiceFlags4 uint32 1059 ProviderFlags uint32 1060 ProviderId GUID 1061 CatalogEntryId uint32 1062 ProtocolChain WSAProtocolChain 1063 Version int32 1064 AddressFamily int32 1065 MaxSockAddr int32 1066 MinSockAddr int32 1067 SocketType int32 1068 Protocol int32 1069 ProtocolMaxOffset int32 1070 NetworkByteOrder int32 1071 SecurityScheme int32 1072 MessageSize uint32 1073 ProviderReserved uint32 1074 ProtocolName [WSAPROTOCOL_LEN + 1]uint16 1075 } 1076 1077 type WSAProtocolChain struct { 1078 ChainLen int32 1079 ChainEntries [MAX_PROTOCOL_CHAIN]uint32 1080 } 1081 1082 type TCPKeepalive struct { 1083 OnOff uint32 1084 Time uint32 1085 Interval uint32 1086 } 1087 1088 type symbolicLinkReparseBuffer struct { 1089 SubstituteNameOffset uint16 1090 SubstituteNameLength uint16 1091 PrintNameOffset uint16 1092 PrintNameLength uint16 1093 Flags uint32 1094 PathBuffer [1]uint16 1095 } 1096 1097 type mountPointReparseBuffer struct { 1098 SubstituteNameOffset uint16 1099 SubstituteNameLength uint16 1100 PrintNameOffset uint16 1101 PrintNameLength uint16 1102 PathBuffer [1]uint16 1103 } 1104 1105 type reparseDataBuffer struct { 1106 ReparseTag uint32 1107 ReparseDataLength uint16 1108 Reserved uint16 1109 1110 // GenericReparseBuffer 1111 reparseBuffer byte 1112 } 1113 1114 const ( 1115 FSCTL_GET_REPARSE_POINT = 0x900A8 1116 MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16 * 1024 1117 _IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003 1118 IO_REPARSE_TAG_SYMLINK = 0xA000000C 1119 SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1 1120 _SYMLINK_FLAG_RELATIVE = 1 1121 )