You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1367 lines
33 KiB

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