types_windows.mx raw

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