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