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