Source file src/syscall/types_windows.go

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

View as plain text