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