zsyscall_windows.mx raw

   1  // Code generated by 'go generate'; DO NOT EDIT.
   2  
   3  package syscall
   4  
   5  import (
   6  	"internal/syscall/windows/sysdll"
   7  	"unsafe"
   8  )
   9  
  10  var _ unsafe.Pointer
  11  
  12  // Do the interface allocations only once for common
  13  // Errno values.
  14  const (
  15  	errnoERROR_IO_PENDING = 997
  16  )
  17  
  18  var (
  19  	errERROR_IO_PENDING error = Errno(errnoERROR_IO_PENDING)
  20  	errERROR_EINVAL     error = EINVAL
  21  )
  22  
  23  // errnoErr returns common boxed Errno values, to prevent
  24  // allocations at runtime.
  25  func errnoErr(e Errno) error {
  26  	switch e {
  27  	case 0:
  28  		return errERROR_EINVAL
  29  	case errnoERROR_IO_PENDING:
  30  		return errERROR_IO_PENDING
  31  	}
  32  	// TODO: add more here, after collecting data on the common
  33  	// error values see on Windows. (perhaps when running
  34  	// all.bat?)
  35  	return e
  36  }
  37  
  38  var (
  39  	modadvapi32 = NewLazyDLL(sysdll.Add("advapi32.dll"))
  40  	modcrypt32  = NewLazyDLL(sysdll.Add("crypt32.dll"))
  41  	moddnsapi   = NewLazyDLL(sysdll.Add("dnsapi.dll"))
  42  	modiphlpapi = NewLazyDLL(sysdll.Add("iphlpapi.dll"))
  43  	modkernel32 = NewLazyDLL(sysdll.Add("kernel32.dll"))
  44  	modmswsock  = NewLazyDLL(sysdll.Add("mswsock.dll"))
  45  	modnetapi32 = NewLazyDLL(sysdll.Add("netapi32.dll"))
  46  	modsecur32  = NewLazyDLL(sysdll.Add("secur32.dll"))
  47  	modshell32  = NewLazyDLL(sysdll.Add("shell32.dll"))
  48  	moduserenv  = NewLazyDLL(sysdll.Add("userenv.dll"))
  49  	modws2_32   = NewLazyDLL(sysdll.Add("ws2_32.dll"))
  50  
  51  	procConvertSidToStringSidW             = modadvapi32.NewProc("ConvertSidToStringSidW")
  52  	procConvertStringSidToSidW             = modadvapi32.NewProc("ConvertStringSidToSidW")
  53  	procCopySid                            = modadvapi32.NewProc("CopySid")
  54  	procCreateProcessAsUserW               = modadvapi32.NewProc("CreateProcessAsUserW")
  55  	procCryptAcquireContextW               = modadvapi32.NewProc("CryptAcquireContextW")
  56  	procCryptGenRandom                     = modadvapi32.NewProc("CryptGenRandom")
  57  	procCryptReleaseContext                = modadvapi32.NewProc("CryptReleaseContext")
  58  	procGetLengthSid                       = modadvapi32.NewProc("GetLengthSid")
  59  	procGetTokenInformation                = modadvapi32.NewProc("GetTokenInformation")
  60  	procLookupAccountNameW                 = modadvapi32.NewProc("LookupAccountNameW")
  61  	procLookupAccountSidW                  = modadvapi32.NewProc("LookupAccountSidW")
  62  	procOpenProcessToken                   = modadvapi32.NewProc("OpenProcessToken")
  63  	procRegCloseKey                        = modadvapi32.NewProc("RegCloseKey")
  64  	procRegEnumKeyExW                      = modadvapi32.NewProc("RegEnumKeyExW")
  65  	procRegOpenKeyExW                      = modadvapi32.NewProc("RegOpenKeyExW")
  66  	procRegQueryInfoKeyW                   = modadvapi32.NewProc("RegQueryInfoKeyW")
  67  	procRegQueryValueExW                   = modadvapi32.NewProc("RegQueryValueExW")
  68  	procCertAddCertificateContextToStore   = modcrypt32.NewProc("CertAddCertificateContextToStore")
  69  	procCertCloseStore                     = modcrypt32.NewProc("CertCloseStore")
  70  	procCertCreateCertificateContext       = modcrypt32.NewProc("CertCreateCertificateContext")
  71  	procCertEnumCertificatesInStore        = modcrypt32.NewProc("CertEnumCertificatesInStore")
  72  	procCertFreeCertificateChain           = modcrypt32.NewProc("CertFreeCertificateChain")
  73  	procCertFreeCertificateContext         = modcrypt32.NewProc("CertFreeCertificateContext")
  74  	procCertGetCertificateChain            = modcrypt32.NewProc("CertGetCertificateChain")
  75  	procCertOpenStore                      = modcrypt32.NewProc("CertOpenStore")
  76  	procCertOpenSystemStoreW               = modcrypt32.NewProc("CertOpenSystemStoreW")
  77  	procCertVerifyCertificateChainPolicy   = modcrypt32.NewProc("CertVerifyCertificateChainPolicy")
  78  	procDnsNameCompare_W                   = moddnsapi.NewProc("DnsNameCompare_W")
  79  	procDnsQuery_W                         = moddnsapi.NewProc("DnsQuery_W")
  80  	procDnsRecordListFree                  = moddnsapi.NewProc("DnsRecordListFree")
  81  	procGetAdaptersInfo                    = modiphlpapi.NewProc("GetAdaptersInfo")
  82  	procGetIfEntry                         = modiphlpapi.NewProc("GetIfEntry")
  83  	procCancelIo                           = modkernel32.NewProc("CancelIo")
  84  	procCancelIoEx                         = modkernel32.NewProc("CancelIoEx")
  85  	procCloseHandle                        = modkernel32.NewProc("CloseHandle")
  86  	procCreateDirectoryW                   = modkernel32.NewProc("CreateDirectoryW")
  87  	procCreateFileMappingW                 = modkernel32.NewProc("CreateFileMappingW")
  88  	procCreateFileW                        = modkernel32.NewProc("CreateFileW")
  89  	procCreateHardLinkW                    = modkernel32.NewProc("CreateHardLinkW")
  90  	procCreateIoCompletionPort             = modkernel32.NewProc("CreateIoCompletionPort")
  91  	procCreatePipe                         = modkernel32.NewProc("CreatePipe")
  92  	procCreateProcessW                     = modkernel32.NewProc("CreateProcessW")
  93  	procCreateSymbolicLinkW                = modkernel32.NewProc("CreateSymbolicLinkW")
  94  	procCreateToolhelp32Snapshot           = modkernel32.NewProc("CreateToolhelp32Snapshot")
  95  	procDeleteFileW                        = modkernel32.NewProc("DeleteFileW")
  96  	procDeleteProcThreadAttributeList      = modkernel32.NewProc("DeleteProcThreadAttributeList")
  97  	procDeviceIoControl                    = modkernel32.NewProc("DeviceIoControl")
  98  	procDuplicateHandle                    = modkernel32.NewProc("DuplicateHandle")
  99  	procExitProcess                        = modkernel32.NewProc("ExitProcess")
 100  	procFindClose                          = modkernel32.NewProc("FindClose")
 101  	procFindFirstFileW                     = modkernel32.NewProc("FindFirstFileW")
 102  	procFindNextFileW                      = modkernel32.NewProc("FindNextFileW")
 103  	procFlushFileBuffers                   = modkernel32.NewProc("FlushFileBuffers")
 104  	procFlushViewOfFile                    = modkernel32.NewProc("FlushViewOfFile")
 105  	procFormatMessageW                     = modkernel32.NewProc("FormatMessageW")
 106  	procFreeEnvironmentStringsW            = modkernel32.NewProc("FreeEnvironmentStringsW")
 107  	procFreeLibrary                        = modkernel32.NewProc("FreeLibrary")
 108  	procGetCommandLineW                    = modkernel32.NewProc("GetCommandLineW")
 109  	procGetComputerNameW                   = modkernel32.NewProc("GetComputerNameW")
 110  	procGetConsoleMode                     = modkernel32.NewProc("GetConsoleMode")
 111  	procGetCurrentDirectoryW               = modkernel32.NewProc("GetCurrentDirectoryW")
 112  	procGetCurrentProcess                  = modkernel32.NewProc("GetCurrentProcess")
 113  	procGetCurrentProcessId                = modkernel32.NewProc("GetCurrentProcessId")
 114  	procGetEnvironmentStringsW             = modkernel32.NewProc("GetEnvironmentStringsW")
 115  	procGetEnvironmentVariableW            = modkernel32.NewProc("GetEnvironmentVariableW")
 116  	procGetExitCodeProcess                 = modkernel32.NewProc("GetExitCodeProcess")
 117  	procGetFileAttributesExW               = modkernel32.NewProc("GetFileAttributesExW")
 118  	procGetFileAttributesW                 = modkernel32.NewProc("GetFileAttributesW")
 119  	procGetFileInformationByHandle         = modkernel32.NewProc("GetFileInformationByHandle")
 120  	procGetFileType                        = modkernel32.NewProc("GetFileType")
 121  	procGetFinalPathNameByHandleW          = modkernel32.NewProc("GetFinalPathNameByHandleW")
 122  	procGetFullPathNameW                   = modkernel32.NewProc("GetFullPathNameW")
 123  	procGetLastError                       = modkernel32.NewProc("GetLastError")
 124  	procGetLongPathNameW                   = modkernel32.NewProc("GetLongPathNameW")
 125  	procGetProcAddress                     = modkernel32.NewProc("GetProcAddress")
 126  	procGetProcessTimes                    = modkernel32.NewProc("GetProcessTimes")
 127  	procGetQueuedCompletionStatus          = modkernel32.NewProc("GetQueuedCompletionStatus")
 128  	procGetShortPathNameW                  = modkernel32.NewProc("GetShortPathNameW")
 129  	procGetStartupInfoW                    = modkernel32.NewProc("GetStartupInfoW")
 130  	procGetStdHandle                       = modkernel32.NewProc("GetStdHandle")
 131  	procGetSystemTimeAsFileTime            = modkernel32.NewProc("GetSystemTimeAsFileTime")
 132  	procGetTempPathW                       = modkernel32.NewProc("GetTempPathW")
 133  	procGetTimeZoneInformation             = modkernel32.NewProc("GetTimeZoneInformation")
 134  	procGetVersion                         = modkernel32.NewProc("GetVersion")
 135  	procInitializeProcThreadAttributeList  = modkernel32.NewProc("InitializeProcThreadAttributeList")
 136  	procLoadLibraryW                       = modkernel32.NewProc("LoadLibraryW")
 137  	procLocalAlloc                         = modkernel32.NewProc("LocalAlloc")
 138  	procLocalFree                          = modkernel32.NewProc("LocalFree")
 139  	procMapViewOfFile                      = modkernel32.NewProc("MapViewOfFile")
 140  	procMoveFileW                          = modkernel32.NewProc("MoveFileW")
 141  	procOpenProcess                        = modkernel32.NewProc("OpenProcess")
 142  	procPostQueuedCompletionStatus         = modkernel32.NewProc("PostQueuedCompletionStatus")
 143  	procProcess32FirstW                    = modkernel32.NewProc("Process32FirstW")
 144  	procProcess32NextW                     = modkernel32.NewProc("Process32NextW")
 145  	procReadConsoleW                       = modkernel32.NewProc("ReadConsoleW")
 146  	procReadDirectoryChangesW              = modkernel32.NewProc("ReadDirectoryChangesW")
 147  	procReadFile                           = modkernel32.NewProc("ReadFile")
 148  	procRemoveDirectoryW                   = modkernel32.NewProc("RemoveDirectoryW")
 149  	procSetCurrentDirectoryW               = modkernel32.NewProc("SetCurrentDirectoryW")
 150  	procSetEndOfFile                       = modkernel32.NewProc("SetEndOfFile")
 151  	procSetEnvironmentVariableW            = modkernel32.NewProc("SetEnvironmentVariableW")
 152  	procSetFileAttributesW                 = modkernel32.NewProc("SetFileAttributesW")
 153  	procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
 154  	procSetFileInformationByHandle         = modkernel32.NewProc("SetFileInformationByHandle")
 155  	procSetFilePointer                     = modkernel32.NewProc("SetFilePointer")
 156  	procSetFileTime                        = modkernel32.NewProc("SetFileTime")
 157  	procSetHandleInformation               = modkernel32.NewProc("SetHandleInformation")
 158  	procTerminateProcess                   = modkernel32.NewProc("TerminateProcess")
 159  	procUnmapViewOfFile                    = modkernel32.NewProc("UnmapViewOfFile")
 160  	procUpdateProcThreadAttribute          = modkernel32.NewProc("UpdateProcThreadAttribute")
 161  	procVirtualLock                        = modkernel32.NewProc("VirtualLock")
 162  	procVirtualUnlock                      = modkernel32.NewProc("VirtualUnlock")
 163  	procWaitForSingleObject                = modkernel32.NewProc("WaitForSingleObject")
 164  	procWriteConsoleW                      = modkernel32.NewProc("WriteConsoleW")
 165  	procWriteFile                          = modkernel32.NewProc("WriteFile")
 166  	procAcceptEx                           = modmswsock.NewProc("AcceptEx")
 167  	procGetAcceptExSockaddrs               = modmswsock.NewProc("GetAcceptExSockaddrs")
 168  	procTransmitFile                       = modmswsock.NewProc("TransmitFile")
 169  	procNetApiBufferFree                   = modnetapi32.NewProc("NetApiBufferFree")
 170  	procNetGetJoinInformation              = modnetapi32.NewProc("NetGetJoinInformation")
 171  	procNetUserGetInfo                     = modnetapi32.NewProc("NetUserGetInfo")
 172  	procGetUserNameExW                     = modsecur32.NewProc("GetUserNameExW")
 173  	procTranslateNameW                     = modsecur32.NewProc("TranslateNameW")
 174  	procCommandLineToArgvW                 = modshell32.NewProc("CommandLineToArgvW")
 175  	procGetUserProfileDirectoryW           = moduserenv.NewProc("GetUserProfileDirectoryW")
 176  	procFreeAddrInfoW                      = modws2_32.NewProc("FreeAddrInfoW")
 177  	procGetAddrInfoW                       = modws2_32.NewProc("GetAddrInfoW")
 178  	procWSACleanup                         = modws2_32.NewProc("WSACleanup")
 179  	procWSAEnumProtocolsW                  = modws2_32.NewProc("WSAEnumProtocolsW")
 180  	procWSAIoctl                           = modws2_32.NewProc("WSAIoctl")
 181  	procWSARecv                            = modws2_32.NewProc("WSARecv")
 182  	procWSARecvFrom                        = modws2_32.NewProc("WSARecvFrom")
 183  	procWSASend                            = modws2_32.NewProc("WSASend")
 184  	procWSASendTo                          = modws2_32.NewProc("WSASendTo")
 185  	procWSAStartup                         = modws2_32.NewProc("WSAStartup")
 186  	procbind                               = modws2_32.NewProc("bind")
 187  	procclosesocket                        = modws2_32.NewProc("closesocket")
 188  	procconnect                            = modws2_32.NewProc("connect")
 189  	procgethostbyname                      = modws2_32.NewProc("gethostbyname")
 190  	procgetpeername                        = modws2_32.NewProc("getpeername")
 191  	procgetprotobyname                     = modws2_32.NewProc("getprotobyname")
 192  	procgetservbyname                      = modws2_32.NewProc("getservbyname")
 193  	procgetsockname                        = modws2_32.NewProc("getsockname")
 194  	procgetsockopt                         = modws2_32.NewProc("getsockopt")
 195  	proclisten                             = modws2_32.NewProc("listen")
 196  	procntohs                              = modws2_32.NewProc("ntohs")
 197  	procsetsockopt                         = modws2_32.NewProc("setsockopt")
 198  	procshutdown                           = modws2_32.NewProc("shutdown")
 199  	procsocket                             = modws2_32.NewProc("socket")
 200  )
 201  
 202  func ConvertSidToStringSid(sid *SID, stringSid **uint16) (err error) {
 203  	r1, _, e1 := Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(stringSid)), 0)
 204  	if r1 == 0 {
 205  		err = errnoErr(e1)
 206  	}
 207  	return
 208  }
 209  
 210  func ConvertStringSidToSid(stringSid *uint16, sid **SID) (err error) {
 211  	r1, _, e1 := Syscall(procConvertStringSidToSidW.Addr(), 2, uintptr(unsafe.Pointer(stringSid)), uintptr(unsafe.Pointer(sid)), 0)
 212  	if r1 == 0 {
 213  		err = errnoErr(e1)
 214  	}
 215  	return
 216  }
 217  
 218  func CopySid(destSidLen uint32, destSid *SID, srcSid *SID) (err error) {
 219  	r1, _, e1 := Syscall(procCopySid.Addr(), 3, uintptr(destSidLen), uintptr(unsafe.Pointer(destSid)), uintptr(unsafe.Pointer(srcSid)))
 220  	if r1 == 0 {
 221  		err = errnoErr(e1)
 222  	}
 223  	return
 224  }
 225  
 226  func CreateProcessAsUser(token Token, appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
 227  	var _p0 uint32
 228  	if inheritHandles {
 229  		_p0 = 1
 230  	}
 231  	r1, _, e1 := Syscall12(procCreateProcessAsUserW.Addr(), 11, uintptr(token), uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0)
 232  	if r1 == 0 {
 233  		err = errnoErr(e1)
 234  	}
 235  	return
 236  }
 237  
 238  func CryptAcquireContext(provhandle *Handle, container *uint16, provider *uint16, provtype uint32, flags uint32) (err error) {
 239  	r1, _, e1 := Syscall6(procCryptAcquireContextW.Addr(), 5, uintptr(unsafe.Pointer(provhandle)), uintptr(unsafe.Pointer(container)), uintptr(unsafe.Pointer(provider)), uintptr(provtype), uintptr(flags), 0)
 240  	if r1 == 0 {
 241  		err = errnoErr(e1)
 242  	}
 243  	return
 244  }
 245  
 246  func CryptGenRandom(provhandle Handle, buflen uint32, buf *byte) (err error) {
 247  	r1, _, e1 := Syscall(procCryptGenRandom.Addr(), 3, uintptr(provhandle), uintptr(buflen), uintptr(unsafe.Pointer(buf)))
 248  	if r1 == 0 {
 249  		err = errnoErr(e1)
 250  	}
 251  	return
 252  }
 253  
 254  func CryptReleaseContext(provhandle Handle, flags uint32) (err error) {
 255  	r1, _, e1 := Syscall(procCryptReleaseContext.Addr(), 2, uintptr(provhandle), uintptr(flags), 0)
 256  	if r1 == 0 {
 257  		err = errnoErr(e1)
 258  	}
 259  	return
 260  }
 261  
 262  func GetLengthSid(sid *SID) (len uint32) {
 263  	r0, _, _ := Syscall(procGetLengthSid.Addr(), 1, uintptr(unsafe.Pointer(sid)), 0, 0)
 264  	len = uint32(r0)
 265  	return
 266  }
 267  
 268  func GetTokenInformation(t Token, infoClass uint32, info *byte, infoLen uint32, returnedLen *uint32) (err error) {
 269  	r1, _, e1 := Syscall6(procGetTokenInformation.Addr(), 5, uintptr(t), uintptr(infoClass), uintptr(unsafe.Pointer(info)), uintptr(infoLen), uintptr(unsafe.Pointer(returnedLen)), 0)
 270  	if r1 == 0 {
 271  		err = errnoErr(e1)
 272  	}
 273  	return
 274  }
 275  
 276  func LookupAccountName(systemName *uint16, accountName *uint16, sid *SID, sidLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
 277  	r1, _, e1 := Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
 278  	if r1 == 0 {
 279  		err = errnoErr(e1)
 280  	}
 281  	return
 282  }
 283  
 284  func LookupAccountSid(systemName *uint16, sid *SID, name *uint16, nameLen *uint32, refdDomainName *uint16, refdDomainNameLen *uint32, use *uint32) (err error) {
 285  	r1, _, e1 := Syscall9(procLookupAccountSidW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(refdDomainName)), uintptr(unsafe.Pointer(refdDomainNameLen)), uintptr(unsafe.Pointer(use)), 0, 0)
 286  	if r1 == 0 {
 287  		err = errnoErr(e1)
 288  	}
 289  	return
 290  }
 291  
 292  func OpenProcessToken(h Handle, access uint32, token *Token) (err error) {
 293  	r1, _, e1 := Syscall(procOpenProcessToken.Addr(), 3, uintptr(h), uintptr(access), uintptr(unsafe.Pointer(token)))
 294  	if r1 == 0 {
 295  		err = errnoErr(e1)
 296  	}
 297  	return
 298  }
 299  
 300  func RegCloseKey(key Handle) (regerrno error) {
 301  	r0, _, _ := Syscall(procRegCloseKey.Addr(), 1, uintptr(key), 0, 0)
 302  	if r0 != 0 {
 303  		regerrno = Errno(r0)
 304  	}
 305  	return
 306  }
 307  
 308  func regEnumKeyEx(key Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, class *uint16, classLen *uint32, lastWriteTime *Filetime) (regerrno error) {
 309  	r0, _, _ := Syscall9(procRegEnumKeyExW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(lastWriteTime)), 0)
 310  	if r0 != 0 {
 311  		regerrno = Errno(r0)
 312  	}
 313  	return
 314  }
 315  
 316  func RegOpenKeyEx(key Handle, subkey *uint16, options uint32, desiredAccess uint32, result *Handle) (regerrno error) {
 317  	r0, _, _ := Syscall6(procRegOpenKeyExW.Addr(), 5, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(options), uintptr(desiredAccess), uintptr(unsafe.Pointer(result)), 0)
 318  	if r0 != 0 {
 319  		regerrno = Errno(r0)
 320  	}
 321  	return
 322  }
 323  
 324  func RegQueryInfoKey(key Handle, class *uint16, classLen *uint32, reserved *uint32, subkeysLen *uint32, maxSubkeyLen *uint32, maxClassLen *uint32, valuesLen *uint32, maxValueNameLen *uint32, maxValueLen *uint32, saLen *uint32, lastWriteTime *Filetime) (regerrno error) {
 325  	r0, _, _ := Syscall12(procRegQueryInfoKeyW.Addr(), 12, uintptr(key), uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(classLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(subkeysLen)), uintptr(unsafe.Pointer(maxSubkeyLen)), uintptr(unsafe.Pointer(maxClassLen)), uintptr(unsafe.Pointer(valuesLen)), uintptr(unsafe.Pointer(maxValueNameLen)), uintptr(unsafe.Pointer(maxValueLen)), uintptr(unsafe.Pointer(saLen)), uintptr(unsafe.Pointer(lastWriteTime)))
 326  	if r0 != 0 {
 327  		regerrno = Errno(r0)
 328  	}
 329  	return
 330  }
 331  
 332  func RegQueryValueEx(key Handle, name *uint16, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
 333  	r0, _, _ := Syscall6(procRegQueryValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen)))
 334  	if r0 != 0 {
 335  		regerrno = Errno(r0)
 336  	}
 337  	return
 338  }
 339  
 340  func CertAddCertificateContextToStore(store Handle, certContext *CertContext, addDisposition uint32, storeContext **CertContext) (err error) {
 341  	r1, _, e1 := Syscall6(procCertAddCertificateContextToStore.Addr(), 4, uintptr(store), uintptr(unsafe.Pointer(certContext)), uintptr(addDisposition), uintptr(unsafe.Pointer(storeContext)), 0, 0)
 342  	if r1 == 0 {
 343  		err = errnoErr(e1)
 344  	}
 345  	return
 346  }
 347  
 348  func CertCloseStore(store Handle, flags uint32) (err error) {
 349  	r1, _, e1 := Syscall(procCertCloseStore.Addr(), 2, uintptr(store), uintptr(flags), 0)
 350  	if r1 == 0 {
 351  		err = errnoErr(e1)
 352  	}
 353  	return
 354  }
 355  
 356  func CertCreateCertificateContext(certEncodingType uint32, certEncoded *byte, encodedLen uint32) (context *CertContext, err error) {
 357  	r0, _, e1 := Syscall(procCertCreateCertificateContext.Addr(), 3, uintptr(certEncodingType), uintptr(unsafe.Pointer(certEncoded)), uintptr(encodedLen))
 358  	context = (*CertContext)(unsafe.Pointer(r0))
 359  	if context == nil {
 360  		err = errnoErr(e1)
 361  	}
 362  	return
 363  }
 364  
 365  func CertEnumCertificatesInStore(store Handle, prevContext *CertContext) (context *CertContext, err error) {
 366  	r0, _, e1 := Syscall(procCertEnumCertificatesInStore.Addr(), 2, uintptr(store), uintptr(unsafe.Pointer(prevContext)), 0)
 367  	context = (*CertContext)(unsafe.Pointer(r0))
 368  	if context == nil {
 369  		err = errnoErr(e1)
 370  	}
 371  	return
 372  }
 373  
 374  func CertFreeCertificateChain(ctx *CertChainContext) {
 375  	Syscall(procCertFreeCertificateChain.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
 376  	return
 377  }
 378  
 379  func CertFreeCertificateContext(ctx *CertContext) (err error) {
 380  	r1, _, e1 := Syscall(procCertFreeCertificateContext.Addr(), 1, uintptr(unsafe.Pointer(ctx)), 0, 0)
 381  	if r1 == 0 {
 382  		err = errnoErr(e1)
 383  	}
 384  	return
 385  }
 386  
 387  func CertGetCertificateChain(engine Handle, leaf *CertContext, time *Filetime, additionalStore Handle, para *CertChainPara, flags uint32, reserved uintptr, chainCtx **CertChainContext) (err error) {
 388  	r1, _, e1 := Syscall9(procCertGetCertificateChain.Addr(), 8, uintptr(engine), uintptr(unsafe.Pointer(leaf)), uintptr(unsafe.Pointer(time)), uintptr(additionalStore), uintptr(unsafe.Pointer(para)), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(chainCtx)), 0)
 389  	if r1 == 0 {
 390  		err = errnoErr(e1)
 391  	}
 392  	return
 393  }
 394  
 395  func CertOpenStore(storeProvider uintptr, msgAndCertEncodingType uint32, cryptProv uintptr, flags uint32, para uintptr) (handle Handle, err error) {
 396  	r0, _, e1 := Syscall6(procCertOpenStore.Addr(), 5, uintptr(storeProvider), uintptr(msgAndCertEncodingType), uintptr(cryptProv), uintptr(flags), uintptr(para), 0)
 397  	handle = Handle(r0)
 398  	if handle == 0 {
 399  		err = errnoErr(e1)
 400  	}
 401  	return
 402  }
 403  
 404  func CertOpenSystemStore(hprov Handle, name *uint16) (store Handle, err error) {
 405  	r0, _, e1 := Syscall(procCertOpenSystemStoreW.Addr(), 2, uintptr(hprov), uintptr(unsafe.Pointer(name)), 0)
 406  	store = Handle(r0)
 407  	if store == 0 {
 408  		err = errnoErr(e1)
 409  	}
 410  	return
 411  }
 412  
 413  func CertVerifyCertificateChainPolicy(policyOID uintptr, chain *CertChainContext, para *CertChainPolicyPara, status *CertChainPolicyStatus) (err error) {
 414  	r1, _, e1 := Syscall6(procCertVerifyCertificateChainPolicy.Addr(), 4, uintptr(policyOID), uintptr(unsafe.Pointer(chain)), uintptr(unsafe.Pointer(para)), uintptr(unsafe.Pointer(status)), 0, 0)
 415  	if r1 == 0 {
 416  		err = errnoErr(e1)
 417  	}
 418  	return
 419  }
 420  
 421  func DnsNameCompare(name1 *uint16, name2 *uint16) (same bool) {
 422  	r0, _, _ := Syscall(procDnsNameCompare_W.Addr(), 2, uintptr(unsafe.Pointer(name1)), uintptr(unsafe.Pointer(name2)), 0)
 423  	same = r0 != 0
 424  	return
 425  }
 426  
 427  func DnsQuery(name string, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
 428  	var _p0 *uint16
 429  	_p0, status = UTF16PtrFromString(name)
 430  	if status != nil {
 431  		return
 432  	}
 433  	return _DnsQuery(_p0, qtype, options, extra, qrs, pr)
 434  }
 435  
 436  func _DnsQuery(name *uint16, qtype uint16, options uint32, extra *byte, qrs **DNSRecord, pr *byte) (status error) {
 437  	r0, _, _ := Syscall6(procDnsQuery_W.Addr(), 6, uintptr(unsafe.Pointer(name)), uintptr(qtype), uintptr(options), uintptr(unsafe.Pointer(extra)), uintptr(unsafe.Pointer(qrs)), uintptr(unsafe.Pointer(pr)))
 438  	if r0 != 0 {
 439  		status = Errno(r0)
 440  	}
 441  	return
 442  }
 443  
 444  func DnsRecordListFree(rl *DNSRecord, freetype uint32) {
 445  	Syscall(procDnsRecordListFree.Addr(), 2, uintptr(unsafe.Pointer(rl)), uintptr(freetype), 0)
 446  	return
 447  }
 448  
 449  func GetAdaptersInfo(ai *IpAdapterInfo, ol *uint32) (errcode error) {
 450  	r0, _, _ := Syscall(procGetAdaptersInfo.Addr(), 2, uintptr(unsafe.Pointer(ai)), uintptr(unsafe.Pointer(ol)), 0)
 451  	if r0 != 0 {
 452  		errcode = Errno(r0)
 453  	}
 454  	return
 455  }
 456  
 457  func GetIfEntry(pIfRow *MibIfRow) (errcode error) {
 458  	r0, _, _ := Syscall(procGetIfEntry.Addr(), 1, uintptr(unsafe.Pointer(pIfRow)), 0, 0)
 459  	if r0 != 0 {
 460  		errcode = Errno(r0)
 461  	}
 462  	return
 463  }
 464  
 465  func CancelIo(s Handle) (err error) {
 466  	r1, _, e1 := Syscall(procCancelIo.Addr(), 1, uintptr(s), 0, 0)
 467  	if r1 == 0 {
 468  		err = errnoErr(e1)
 469  	}
 470  	return
 471  }
 472  
 473  func CancelIoEx(s Handle, o *Overlapped) (err error) {
 474  	r1, _, e1 := Syscall(procCancelIoEx.Addr(), 2, uintptr(s), uintptr(unsafe.Pointer(o)), 0)
 475  	if r1 == 0 {
 476  		err = errnoErr(e1)
 477  	}
 478  	return
 479  }
 480  
 481  func CloseHandle(handle Handle) (err error) {
 482  	r1, _, e1 := Syscall(procCloseHandle.Addr(), 1, uintptr(handle), 0, 0)
 483  	if r1 == 0 {
 484  		err = errnoErr(e1)
 485  	}
 486  	return
 487  }
 488  
 489  func CreateDirectory(path *uint16, sa *SecurityAttributes) (err error) {
 490  	r1, _, e1 := Syscall(procCreateDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(sa)), 0)
 491  	if r1 == 0 {
 492  		err = errnoErr(e1)
 493  	}
 494  	return
 495  }
 496  
 497  func CreateFileMapping(fhandle Handle, sa *SecurityAttributes, prot uint32, maxSizeHigh uint32, maxSizeLow uint32, name *uint16) (handle Handle, err error) {
 498  	r0, _, e1 := Syscall6(procCreateFileMappingW.Addr(), 6, uintptr(fhandle), uintptr(unsafe.Pointer(sa)), uintptr(prot), uintptr(maxSizeHigh), uintptr(maxSizeLow), uintptr(unsafe.Pointer(name)))
 499  	handle = Handle(r0)
 500  	if handle == 0 {
 501  		err = errnoErr(e1)
 502  	}
 503  	return
 504  }
 505  
 506  func createFile(name *uint16, access uint32, mode uint32, sa *SecurityAttributes, createmode uint32, attrs uint32, templatefile int32) (handle Handle, err error) {
 507  	r0, _, e1 := Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0)
 508  	handle = Handle(r0)
 509  	if handle == InvalidHandle || e1 == ERROR_ALREADY_EXISTS {
 510  		err = errnoErr(e1)
 511  	}
 512  	return
 513  }
 514  
 515  func CreateHardLink(filename *uint16, existingfilename *uint16, reserved uintptr) (err error) {
 516  	r1, _, e1 := Syscall(procCreateHardLinkW.Addr(), 3, uintptr(unsafe.Pointer(filename)), uintptr(unsafe.Pointer(existingfilename)), uintptr(reserved))
 517  	if r1&0xff == 0 {
 518  		err = errnoErr(e1)
 519  	}
 520  	return
 521  }
 522  
 523  func createIoCompletionPort(filehandle Handle, cphandle Handle, key uintptr, threadcnt uint32) (handle Handle, err error) {
 524  	r0, _, e1 := Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(filehandle), uintptr(cphandle), uintptr(key), uintptr(threadcnt), 0, 0)
 525  	handle = Handle(r0)
 526  	if handle == 0 {
 527  		err = errnoErr(e1)
 528  	}
 529  	return
 530  }
 531  
 532  func CreatePipe(readhandle *Handle, writehandle *Handle, sa *SecurityAttributes, size uint32) (err error) {
 533  	r1, _, e1 := Syscall6(procCreatePipe.Addr(), 4, uintptr(unsafe.Pointer(readhandle)), uintptr(unsafe.Pointer(writehandle)), uintptr(unsafe.Pointer(sa)), uintptr(size), 0, 0)
 534  	if r1 == 0 {
 535  		err = errnoErr(e1)
 536  	}
 537  	return
 538  }
 539  
 540  func CreateProcess(appName *uint16, commandLine *uint16, procSecurity *SecurityAttributes, threadSecurity *SecurityAttributes, inheritHandles bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo *StartupInfo, outProcInfo *ProcessInformation) (err error) {
 541  	var _p0 uint32
 542  	if inheritHandles {
 543  		_p0 = 1
 544  	}
 545  	r1, _, e1 := Syscall12(procCreateProcessW.Addr(), 10, uintptr(unsafe.Pointer(appName)), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(procSecurity)), uintptr(unsafe.Pointer(threadSecurity)), uintptr(_p0), uintptr(creationFlags), uintptr(unsafe.Pointer(env)), uintptr(unsafe.Pointer(currentDir)), uintptr(unsafe.Pointer(startupInfo)), uintptr(unsafe.Pointer(outProcInfo)), 0, 0)
 546  	if r1 == 0 {
 547  		err = errnoErr(e1)
 548  	}
 549  	return
 550  }
 551  
 552  func CreateSymbolicLink(symlinkfilename *uint16, targetfilename *uint16, flags uint32) (err error) {
 553  	r1, _, e1 := Syscall(procCreateSymbolicLinkW.Addr(), 3, uintptr(unsafe.Pointer(symlinkfilename)), uintptr(unsafe.Pointer(targetfilename)), uintptr(flags))
 554  	if r1&0xff == 0 {
 555  		err = errnoErr(e1)
 556  	}
 557  	return
 558  }
 559  
 560  func CreateToolhelp32Snapshot(flags uint32, processId uint32) (handle Handle, err error) {
 561  	r0, _, e1 := Syscall(procCreateToolhelp32Snapshot.Addr(), 2, uintptr(flags), uintptr(processId), 0)
 562  	handle = Handle(r0)
 563  	if handle == InvalidHandle {
 564  		err = errnoErr(e1)
 565  	}
 566  	return
 567  }
 568  
 569  func DeleteFile(path *uint16) (err error) {
 570  	r1, _, e1 := Syscall(procDeleteFileW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
 571  	if r1 == 0 {
 572  		err = errnoErr(e1)
 573  	}
 574  	return
 575  }
 576  
 577  func deleteProcThreadAttributeList(attrlist *_PROC_THREAD_ATTRIBUTE_LIST) {
 578  	Syscall(procDeleteProcThreadAttributeList.Addr(), 1, uintptr(unsafe.Pointer(attrlist)), 0, 0)
 579  	return
 580  }
 581  
 582  func DeviceIoControl(handle Handle, ioControlCode uint32, inBuffer *byte, inBufferSize uint32, outBuffer *byte, outBufferSize uint32, bytesReturned *uint32, overlapped *Overlapped) (err error) {
 583  	r1, _, e1 := Syscall9(procDeviceIoControl.Addr(), 8, uintptr(handle), uintptr(ioControlCode), uintptr(unsafe.Pointer(inBuffer)), uintptr(inBufferSize), uintptr(unsafe.Pointer(outBuffer)), uintptr(outBufferSize), uintptr(unsafe.Pointer(bytesReturned)), uintptr(unsafe.Pointer(overlapped)), 0)
 584  	if r1 == 0 {
 585  		err = errnoErr(e1)
 586  	}
 587  	return
 588  }
 589  
 590  func DuplicateHandle(hSourceProcessHandle Handle, hSourceHandle Handle, hTargetProcessHandle Handle, lpTargetHandle *Handle, dwDesiredAccess uint32, bInheritHandle bool, dwOptions uint32) (err error) {
 591  	var _p0 uint32
 592  	if bInheritHandle {
 593  		_p0 = 1
 594  	}
 595  	r1, _, e1 := Syscall9(procDuplicateHandle.Addr(), 7, uintptr(hSourceProcessHandle), uintptr(hSourceHandle), uintptr(hTargetProcessHandle), uintptr(unsafe.Pointer(lpTargetHandle)), uintptr(dwDesiredAccess), uintptr(_p0), uintptr(dwOptions), 0, 0)
 596  	if r1 == 0 {
 597  		err = errnoErr(e1)
 598  	}
 599  	return
 600  }
 601  
 602  func ExitProcess(exitcode uint32) {
 603  	Syscall(procExitProcess.Addr(), 1, uintptr(exitcode), 0, 0)
 604  	return
 605  }
 606  
 607  func FindClose(handle Handle) (err error) {
 608  	r1, _, e1 := Syscall(procFindClose.Addr(), 1, uintptr(handle), 0, 0)
 609  	if r1 == 0 {
 610  		err = errnoErr(e1)
 611  	}
 612  	return
 613  }
 614  
 615  func findFirstFile1(name *uint16, data *win32finddata1) (handle Handle, err error) {
 616  	r0, _, e1 := Syscall(procFindFirstFileW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(data)), 0)
 617  	handle = Handle(r0)
 618  	if handle == InvalidHandle {
 619  		err = errnoErr(e1)
 620  	}
 621  	return
 622  }
 623  
 624  func findNextFile1(handle Handle, data *win32finddata1) (err error) {
 625  	r1, _, e1 := Syscall(procFindNextFileW.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
 626  	if r1 == 0 {
 627  		err = errnoErr(e1)
 628  	}
 629  	return
 630  }
 631  
 632  func FlushFileBuffers(handle Handle) (err error) {
 633  	r1, _, e1 := Syscall(procFlushFileBuffers.Addr(), 1, uintptr(handle), 0, 0)
 634  	if r1 == 0 {
 635  		err = errnoErr(e1)
 636  	}
 637  	return
 638  }
 639  
 640  func FlushViewOfFile(addr uintptr, length uintptr) (err error) {
 641  	r1, _, e1 := Syscall(procFlushViewOfFile.Addr(), 2, uintptr(addr), uintptr(length), 0)
 642  	if r1 == 0 {
 643  		err = errnoErr(e1)
 644  	}
 645  	return
 646  }
 647  
 648  func formatMessage(flags uint32, msgsrc uintptr, msgid uint32, langid uint32, buf []uint16, args *byte) (n uint32, err error) {
 649  	var _p0 *uint16
 650  	if len(buf) > 0 {
 651  		_p0 = &buf[0]
 652  	}
 653  	r0, _, e1 := Syscall9(procFormatMessageW.Addr(), 7, uintptr(flags), uintptr(msgsrc), uintptr(msgid), uintptr(langid), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(args)), 0, 0)
 654  	n = uint32(r0)
 655  	if n == 0 {
 656  		err = errnoErr(e1)
 657  	}
 658  	return
 659  }
 660  
 661  func FreeEnvironmentStrings(envs *uint16) (err error) {
 662  	r1, _, e1 := Syscall(procFreeEnvironmentStringsW.Addr(), 1, uintptr(unsafe.Pointer(envs)), 0, 0)
 663  	if r1 == 0 {
 664  		err = errnoErr(e1)
 665  	}
 666  	return
 667  }
 668  
 669  func FreeLibrary(handle Handle) (err error) {
 670  	r1, _, e1 := Syscall(procFreeLibrary.Addr(), 1, uintptr(handle), 0, 0)
 671  	if r1 == 0 {
 672  		err = errnoErr(e1)
 673  	}
 674  	return
 675  }
 676  
 677  func GetCommandLine() (cmd *uint16) {
 678  	r0, _, _ := Syscall(procGetCommandLineW.Addr(), 0, 0, 0, 0)
 679  	cmd = (*uint16)(unsafe.Pointer(r0))
 680  	return
 681  }
 682  
 683  func GetComputerName(buf *uint16, n *uint32) (err error) {
 684  	r1, _, e1 := Syscall(procGetComputerNameW.Addr(), 2, uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)), 0)
 685  	if r1 == 0 {
 686  		err = errnoErr(e1)
 687  	}
 688  	return
 689  }
 690  
 691  func GetConsoleMode(console Handle, mode *uint32) (err error) {
 692  	r1, _, e1 := Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0)
 693  	if r1 == 0 {
 694  		err = errnoErr(e1)
 695  	}
 696  	return
 697  }
 698  
 699  func GetCurrentDirectory(buflen uint32, buf *uint16) (n uint32, err error) {
 700  	r0, _, e1 := Syscall(procGetCurrentDirectoryW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
 701  	n = uint32(r0)
 702  	if n == 0 {
 703  		err = errnoErr(e1)
 704  	}
 705  	return
 706  }
 707  
 708  func GetCurrentProcess() (pseudoHandle Handle, err error) {
 709  	r0, _, e1 := Syscall(procGetCurrentProcess.Addr(), 0, 0, 0, 0)
 710  	pseudoHandle = Handle(r0)
 711  	if pseudoHandle == 0 {
 712  		err = errnoErr(e1)
 713  	}
 714  	return
 715  }
 716  
 717  func getCurrentProcessId() (pid uint32) {
 718  	r0, _, _ := Syscall(procGetCurrentProcessId.Addr(), 0, 0, 0, 0)
 719  	pid = uint32(r0)
 720  	return
 721  }
 722  
 723  func GetEnvironmentStrings() (envs *uint16, err error) {
 724  	r0, _, e1 := Syscall(procGetEnvironmentStringsW.Addr(), 0, 0, 0, 0)
 725  	envs = (*uint16)(unsafe.Pointer(r0))
 726  	if envs == nil {
 727  		err = errnoErr(e1)
 728  	}
 729  	return
 730  }
 731  
 732  func GetEnvironmentVariable(name *uint16, buffer *uint16, size uint32) (n uint32, err error) {
 733  	r0, _, e1 := Syscall(procGetEnvironmentVariableW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(size))
 734  	n = uint32(r0)
 735  	if n == 0 {
 736  		err = errnoErr(e1)
 737  	}
 738  	return
 739  }
 740  
 741  func GetExitCodeProcess(handle Handle, exitcode *uint32) (err error) {
 742  	r1, _, e1 := Syscall(procGetExitCodeProcess.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(exitcode)), 0)
 743  	if r1 == 0 {
 744  		err = errnoErr(e1)
 745  	}
 746  	return
 747  }
 748  
 749  func GetFileAttributesEx(name *uint16, level uint32, info *byte) (err error) {
 750  	r1, _, e1 := Syscall(procGetFileAttributesExW.Addr(), 3, uintptr(unsafe.Pointer(name)), uintptr(level), uintptr(unsafe.Pointer(info)))
 751  	if r1 == 0 {
 752  		err = errnoErr(e1)
 753  	}
 754  	return
 755  }
 756  
 757  func GetFileAttributes(name *uint16) (attrs uint32, err error) {
 758  	r0, _, e1 := Syscall(procGetFileAttributesW.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
 759  	attrs = uint32(r0)
 760  	if attrs == INVALID_FILE_ATTRIBUTES {
 761  		err = errnoErr(e1)
 762  	}
 763  	return
 764  }
 765  
 766  func GetFileInformationByHandle(handle Handle, data *ByHandleFileInformation) (err error) {
 767  	r1, _, e1 := Syscall(procGetFileInformationByHandle.Addr(), 2, uintptr(handle), uintptr(unsafe.Pointer(data)), 0)
 768  	if r1 == 0 {
 769  		err = errnoErr(e1)
 770  	}
 771  	return
 772  }
 773  
 774  func GetFileType(filehandle Handle) (n uint32, err error) {
 775  	r0, _, e1 := Syscall(procGetFileType.Addr(), 1, uintptr(filehandle), 0, 0)
 776  	n = uint32(r0)
 777  	if n == 0 {
 778  		err = errnoErr(e1)
 779  	}
 780  	return
 781  }
 782  
 783  func getFinalPathNameByHandle(file Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
 784  	r0, _, e1 := Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0)
 785  	n = uint32(r0)
 786  	if n == 0 || n >= filePathSize {
 787  		err = errnoErr(e1)
 788  	}
 789  	return
 790  }
 791  
 792  func GetFullPathName(path *uint16, buflen uint32, buf *uint16, fname **uint16) (n uint32, err error) {
 793  	r0, _, e1 := Syscall6(procGetFullPathNameW.Addr(), 4, uintptr(unsafe.Pointer(path)), uintptr(buflen), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(fname)), 0, 0)
 794  	n = uint32(r0)
 795  	if n == 0 {
 796  		err = errnoErr(e1)
 797  	}
 798  	return
 799  }
 800  
 801  func GetLastError() (lasterr error) {
 802  	r0, _, _ := Syscall(procGetLastError.Addr(), 0, 0, 0, 0)
 803  	if r0 != 0 {
 804  		lasterr = Errno(r0)
 805  	}
 806  	return
 807  }
 808  
 809  func GetLongPathName(path *uint16, buf *uint16, buflen uint32) (n uint32, err error) {
 810  	r0, _, e1 := Syscall(procGetLongPathNameW.Addr(), 3, uintptr(unsafe.Pointer(path)), uintptr(unsafe.Pointer(buf)), uintptr(buflen))
 811  	n = uint32(r0)
 812  	if n == 0 {
 813  		err = errnoErr(e1)
 814  	}
 815  	return
 816  }
 817  
 818  func GetProcAddress(module Handle, procname string) (proc uintptr, err error) {
 819  	var _p0 *byte
 820  	_p0, err = BytePtrFromString(procname)
 821  	if err != nil {
 822  		return
 823  	}
 824  	return _GetProcAddress(module, _p0)
 825  }
 826  
 827  func _GetProcAddress(module Handle, procname *byte) (proc uintptr, err error) {
 828  	r0, _, e1 := Syscall(procGetProcAddress.Addr(), 2, uintptr(module), uintptr(unsafe.Pointer(procname)), 0)
 829  	proc = uintptr(r0)
 830  	if proc == 0 {
 831  		err = errnoErr(e1)
 832  	}
 833  	return
 834  }
 835  
 836  func GetProcessTimes(handle Handle, creationTime *Filetime, exitTime *Filetime, kernelTime *Filetime, userTime *Filetime) (err error) {
 837  	r1, _, e1 := Syscall6(procGetProcessTimes.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(creationTime)), uintptr(unsafe.Pointer(exitTime)), uintptr(unsafe.Pointer(kernelTime)), uintptr(unsafe.Pointer(userTime)), 0)
 838  	if r1 == 0 {
 839  		err = errnoErr(e1)
 840  	}
 841  	return
 842  }
 843  
 844  func getQueuedCompletionStatus(cphandle Handle, qty *uint32, key *uintptr, overlapped **Overlapped, timeout uint32) (err error) {
 845  	r1, _, e1 := Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(cphandle), uintptr(unsafe.Pointer(qty)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(overlapped)), uintptr(timeout), 0)
 846  	if r1 == 0 {
 847  		err = errnoErr(e1)
 848  	}
 849  	return
 850  }
 851  
 852  func GetShortPathName(longpath *uint16, shortpath *uint16, buflen uint32) (n uint32, err error) {
 853  	r0, _, e1 := Syscall(procGetShortPathNameW.Addr(), 3, uintptr(unsafe.Pointer(longpath)), uintptr(unsafe.Pointer(shortpath)), uintptr(buflen))
 854  	n = uint32(r0)
 855  	if n == 0 {
 856  		err = errnoErr(e1)
 857  	}
 858  	return
 859  }
 860  
 861  func getStartupInfo(startupInfo *StartupInfo) {
 862  	Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
 863  	return
 864  }
 865  
 866  func GetStdHandle(stdhandle int) (handle Handle, err error) {
 867  	r0, _, e1 := Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
 868  	handle = Handle(r0)
 869  	if handle == InvalidHandle {
 870  		err = errnoErr(e1)
 871  	}
 872  	return
 873  }
 874  
 875  func GetSystemTimeAsFileTime(time *Filetime) {
 876  	Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
 877  	return
 878  }
 879  
 880  func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
 881  	r0, _, e1 := Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
 882  	n = uint32(r0)
 883  	if n == 0 {
 884  		err = errnoErr(e1)
 885  	}
 886  	return
 887  }
 888  
 889  func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
 890  	r0, _, e1 := Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
 891  	rc = uint32(r0)
 892  	if rc == 0xffffffff {
 893  		err = errnoErr(e1)
 894  	}
 895  	return
 896  }
 897  
 898  func GetVersion() (ver uint32, err error) {
 899  	r0, _, e1 := Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
 900  	ver = uint32(r0)
 901  	if ver == 0 {
 902  		err = errnoErr(e1)
 903  	}
 904  	return
 905  }
 906  
 907  func initializeProcThreadAttributeList(attrlist *_PROC_THREAD_ATTRIBUTE_LIST, attrcount uint32, flags uint32, size *uintptr) (err error) {
 908  	r1, _, e1 := Syscall6(procInitializeProcThreadAttributeList.Addr(), 4, uintptr(unsafe.Pointer(attrlist)), uintptr(attrcount), uintptr(flags), uintptr(unsafe.Pointer(size)), 0, 0)
 909  	if r1 == 0 {
 910  		err = errnoErr(e1)
 911  	}
 912  	return
 913  }
 914  
 915  func LoadLibrary(libname string) (handle Handle, err error) {
 916  	var _p0 *uint16
 917  	_p0, err = UTF16PtrFromString(libname)
 918  	if err != nil {
 919  		return
 920  	}
 921  	return _LoadLibrary(_p0)
 922  }
 923  
 924  func _LoadLibrary(libname *uint16) (handle Handle, err error) {
 925  	r0, _, e1 := Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
 926  	handle = Handle(r0)
 927  	if handle == 0 {
 928  		err = errnoErr(e1)
 929  	}
 930  	return
 931  }
 932  
 933  func localAlloc(flags uint32, length uint32) (ptr uintptr, err error) {
 934  	r0, _, e1 := Syscall(procLocalAlloc.Addr(), 2, uintptr(flags), uintptr(length), 0)
 935  	ptr = uintptr(r0)
 936  	if ptr == 0 {
 937  		err = errnoErr(e1)
 938  	}
 939  	return
 940  }
 941  
 942  func LocalFree(hmem Handle) (handle Handle, err error) {
 943  	r0, _, e1 := Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
 944  	handle = Handle(r0)
 945  	if handle != 0 {
 946  		err = errnoErr(e1)
 947  	}
 948  	return
 949  }
 950  
 951  func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
 952  	r0, _, e1 := Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
 953  	addr = uintptr(r0)
 954  	if addr == 0 {
 955  		err = errnoErr(e1)
 956  	}
 957  	return
 958  }
 959  
 960  func MoveFile(from *uint16, to *uint16) (err error) {
 961  	r1, _, e1 := Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
 962  	if r1 == 0 {
 963  		err = errnoErr(e1)
 964  	}
 965  	return
 966  }
 967  
 968  func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error) {
 969  	var _p0 uint32
 970  	if inheritHandle {
 971  		_p0 = 1
 972  	}
 973  	r0, _, e1 := Syscall(procOpenProcess.Addr(), 3, uintptr(da), uintptr(_p0), uintptr(pid))
 974  	handle = Handle(r0)
 975  	if handle == 0 {
 976  		err = errnoErr(e1)
 977  	}
 978  	return
 979  }
 980  
 981  func postQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) {
 982  	r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
 983  	if r1 == 0 {
 984  		err = errnoErr(e1)
 985  	}
 986  	return
 987  }
 988  
 989  func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
 990  	r1, _, e1 := Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
 991  	if r1 == 0 {
 992  		err = errnoErr(e1)
 993  	}
 994  	return
 995  }
 996  
 997  func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
 998  	r1, _, e1 := Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
 999  	if r1 == 0 {
1000  		err = errnoErr(e1)
1001  	}
1002  	return
1003  }
1004  
1005  func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
1006  	r1, _, e1 := Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
1007  	if r1 == 0 {
1008  		err = errnoErr(e1)
1009  	}
1010  	return
1011  }
1012  
1013  func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
1014  	var _p0 uint32
1015  	if watchSubTree {
1016  		_p0 = 1
1017  	}
1018  	r1, _, e1 := Syscall9(procReadDirectoryChangesW.Addr(), 8, uintptr(handle), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(_p0), uintptr(mask), uintptr(unsafe.Pointer(retlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine), 0)
1019  	if r1 == 0 {
1020  		err = errnoErr(e1)
1021  	}
1022  	return
1023  }
1024  
1025  func readFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
1026  	var _p0 *byte
1027  	if len(buf) > 0 {
1028  		_p0 = &buf[0]
1029  	}
1030  	r1, _, e1 := Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
1031  	if r1 == 0 {
1032  		err = errnoErr(e1)
1033  	}
1034  	return
1035  }
1036  
1037  func RemoveDirectory(path *uint16) (err error) {
1038  	r1, _, e1 := Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
1039  	if r1 == 0 {
1040  		err = errnoErr(e1)
1041  	}
1042  	return
1043  }
1044  
1045  func SetCurrentDirectory(path *uint16) (err error) {
1046  	r1, _, e1 := Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
1047  	if r1 == 0 {
1048  		err = errnoErr(e1)
1049  	}
1050  	return
1051  }
1052  
1053  func SetEndOfFile(handle Handle) (err error) {
1054  	r1, _, e1 := Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
1055  	if r1 == 0 {
1056  		err = errnoErr(e1)
1057  	}
1058  	return
1059  }
1060  
1061  func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
1062  	r1, _, e1 := Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
1063  	if r1 == 0 {
1064  		err = errnoErr(e1)
1065  	}
1066  	return
1067  }
1068  
1069  func SetFileAttributes(name *uint16, attrs uint32) (err error) {
1070  	r1, _, e1 := Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
1071  	if r1 == 0 {
1072  		err = errnoErr(e1)
1073  	}
1074  	return
1075  }
1076  
1077  func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
1078  	r1, _, e1 := Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
1079  	if r1 == 0 {
1080  		err = errnoErr(e1)
1081  	}
1082  	return
1083  }
1084  
1085  func setFileInformationByHandle(handle Handle, fileInformationClass uint32, buf unsafe.Pointer, bufsize uint32) (err error) {
1086  	r1, _, e1 := Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(fileInformationClass), uintptr(buf), uintptr(bufsize), 0, 0)
1087  	if r1 == 0 {
1088  		err = errnoErr(e1)
1089  	}
1090  	return
1091  }
1092  
1093  func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
1094  	r0, _, e1 := Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
1095  	newlowoffset = uint32(r0)
1096  	if newlowoffset == 0xffffffff {
1097  		err = errnoErr(e1)
1098  	}
1099  	return
1100  }
1101  
1102  func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
1103  	r1, _, e1 := Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
1104  	if r1 == 0 {
1105  		err = errnoErr(e1)
1106  	}
1107  	return
1108  }
1109  
1110  func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
1111  	r1, _, e1 := Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
1112  	if r1 == 0 {
1113  		err = errnoErr(e1)
1114  	}
1115  	return
1116  }
1117  
1118  func TerminateProcess(handle Handle, exitcode uint32) (err error) {
1119  	r1, _, e1 := Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
1120  	if r1 == 0 {
1121  		err = errnoErr(e1)
1122  	}
1123  	return
1124  }
1125  
1126  func UnmapViewOfFile(addr uintptr) (err error) {
1127  	r1, _, e1 := Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
1128  	if r1 == 0 {
1129  		err = errnoErr(e1)
1130  	}
1131  	return
1132  }
1133  
1134  func updateProcThreadAttribute(attrlist *_PROC_THREAD_ATTRIBUTE_LIST, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) {
1135  	r1, _, e1 := Syscall9(procUpdateProcThreadAttribute.Addr(), 7, uintptr(unsafe.Pointer(attrlist)), uintptr(flags), uintptr(attr), uintptr(value), uintptr(size), uintptr(prevvalue), uintptr(unsafe.Pointer(returnedsize)), 0, 0)
1136  	if r1 == 0 {
1137  		err = errnoErr(e1)
1138  	}
1139  	return
1140  }
1141  
1142  func VirtualLock(addr uintptr, length uintptr) (err error) {
1143  	r1, _, e1 := Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
1144  	if r1 == 0 {
1145  		err = errnoErr(e1)
1146  	}
1147  	return
1148  }
1149  
1150  func VirtualUnlock(addr uintptr, length uintptr) (err error) {
1151  	r1, _, e1 := Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
1152  	if r1 == 0 {
1153  		err = errnoErr(e1)
1154  	}
1155  	return
1156  }
1157  
1158  func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
1159  	r0, _, e1 := Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
1160  	event = uint32(r0)
1161  	if event == 0xffffffff {
1162  		err = errnoErr(e1)
1163  	}
1164  	return
1165  }
1166  
1167  func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
1168  	r1, _, e1 := Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
1169  	if r1 == 0 {
1170  		err = errnoErr(e1)
1171  	}
1172  	return
1173  }
1174  
1175  func writeFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
1176  	var _p0 *byte
1177  	if len(buf) > 0 {
1178  		_p0 = &buf[0]
1179  	}
1180  	r1, _, e1 := Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
1181  	if r1 == 0 {
1182  		err = errnoErr(e1)
1183  	}
1184  	return
1185  }
1186  
1187  func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
1188  	r1, _, e1 := Syscall9(procAcceptEx.Addr(), 8, uintptr(ls), uintptr(as), uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(overlapped)), 0)
1189  	if r1 == 0 {
1190  		err = errnoErr(e1)
1191  	}
1192  	return
1193  }
1194  
1195  func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
1196  	Syscall9(procGetAcceptExSockaddrs.Addr(), 8, uintptr(unsafe.Pointer(buf)), uintptr(rxdatalen), uintptr(laddrlen), uintptr(raddrlen), uintptr(unsafe.Pointer(lrsa)), uintptr(unsafe.Pointer(lrsalen)), uintptr(unsafe.Pointer(rrsa)), uintptr(unsafe.Pointer(rrsalen)), 0)
1197  	return
1198  }
1199  
1200  func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
1201  	r1, _, e1 := Syscall9(procTransmitFile.Addr(), 7, uintptr(s), uintptr(handle), uintptr(bytesToWrite), uintptr(bytsPerSend), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(transmitFileBuf)), uintptr(flags), 0, 0)
1202  	if r1 == 0 {
1203  		err = errnoErr(e1)
1204  	}
1205  	return
1206  }
1207  
1208  func NetApiBufferFree(buf *byte) (neterr error) {
1209  	r0, _, _ := Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
1210  	if r0 != 0 {
1211  		neterr = Errno(r0)
1212  	}
1213  	return
1214  }
1215  
1216  func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
1217  	r0, _, _ := Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
1218  	if r0 != 0 {
1219  		neterr = Errno(r0)
1220  	}
1221  	return
1222  }
1223  
1224  func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
1225  	r0, _, _ := Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
1226  	if r0 != 0 {
1227  		neterr = Errno(r0)
1228  	}
1229  	return
1230  }
1231  
1232  func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
1233  	r1, _, e1 := Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
1234  	if r1&0xff == 0 {
1235  		err = errnoErr(e1)
1236  	}
1237  	return
1238  }
1239  
1240  func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
1241  	r1, _, e1 := Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
1242  	if r1&0xff == 0 {
1243  		err = errnoErr(e1)
1244  	}
1245  	return
1246  }
1247  
1248  func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
1249  	r0, _, e1 := Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
1250  	argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
1251  	if argv == nil {
1252  		err = errnoErr(e1)
1253  	}
1254  	return
1255  }
1256  
1257  func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
1258  	r1, _, e1 := Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
1259  	if r1 == 0 {
1260  		err = errnoErr(e1)
1261  	}
1262  	return
1263  }
1264  
1265  func FreeAddrInfoW(addrinfo *AddrinfoW) {
1266  	Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
1267  	return
1268  }
1269  
1270  func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
1271  	r0, _, _ := Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
1272  	if r0 != 0 {
1273  		sockerr = Errno(r0)
1274  	}
1275  	return
1276  }
1277  
1278  func WSACleanup() (err error) {
1279  	r1, _, e1 := Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
1280  	if r1 == socket_error {
1281  		err = errnoErr(e1)
1282  	}
1283  	return
1284  }
1285  
1286  func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
1287  	r0, _, e1 := Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
1288  	n = int32(r0)
1289  	if n == -1 {
1290  		err = errnoErr(e1)
1291  	}
1292  	return
1293  }
1294  
1295  func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
1296  	r1, _, e1 := Syscall9(procWSAIoctl.Addr(), 9, uintptr(s), uintptr(iocc), uintptr(unsafe.Pointer(inbuf)), uintptr(cbif), uintptr(unsafe.Pointer(outbuf)), uintptr(cbob), uintptr(unsafe.Pointer(cbbr)), uintptr(unsafe.Pointer(overlapped)), uintptr(completionRoutine))
1297  	if r1 == socket_error {
1298  		err = errnoErr(e1)
1299  	}
1300  	return
1301  }
1302  
1303  func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
1304  	r1, _, e1 := Syscall9(procWSARecv.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
1305  	if r1 == socket_error {
1306  		err = errnoErr(e1)
1307  	}
1308  	return
1309  }
1310  
1311  func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
1312  	r1, _, e1 := Syscall9(procWSARecvFrom.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(recvd)), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
1313  	if r1 == socket_error {
1314  		err = errnoErr(e1)
1315  	}
1316  	return
1317  }
1318  
1319  func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
1320  	r1, _, e1 := Syscall9(procWSASend.Addr(), 7, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)), 0, 0)
1321  	if r1 == socket_error {
1322  		err = errnoErr(e1)
1323  	}
1324  	return
1325  }
1326  
1327  func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
1328  	r1, _, e1 := Syscall9(procWSASendTo.Addr(), 9, uintptr(s), uintptr(unsafe.Pointer(bufs)), uintptr(bufcnt), uintptr(unsafe.Pointer(sent)), uintptr(flags), uintptr(unsafe.Pointer(to)), uintptr(tolen), uintptr(unsafe.Pointer(overlapped)), uintptr(unsafe.Pointer(croutine)))
1329  	if r1 == socket_error {
1330  		err = errnoErr(e1)
1331  	}
1332  	return
1333  }
1334  
1335  func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
1336  	r0, _, _ := Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
1337  	if r0 != 0 {
1338  		sockerr = Errno(r0)
1339  	}
1340  	return
1341  }
1342  
1343  func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
1344  	r1, _, e1 := Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
1345  	if r1 == socket_error {
1346  		err = errnoErr(e1)
1347  	}
1348  	return
1349  }
1350  
1351  func Closesocket(s Handle) (err error) {
1352  	r1, _, e1 := Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
1353  	if r1 == socket_error {
1354  		err = errnoErr(e1)
1355  	}
1356  	return
1357  }
1358  
1359  func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
1360  	r1, _, e1 := Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
1361  	if r1 == socket_error {
1362  		err = errnoErr(e1)
1363  	}
1364  	return
1365  }
1366  
1367  func GetHostByName(name string) (h *Hostent, err error) {
1368  	var _p0 *byte
1369  	_p0, err = BytePtrFromString(name)
1370  	if err != nil {
1371  		return
1372  	}
1373  	return _GetHostByName(_p0)
1374  }
1375  
1376  func _GetHostByName(name *byte) (h *Hostent, err error) {
1377  	r0, _, e1 := Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
1378  	h = (*Hostent)(unsafe.Pointer(r0))
1379  	if h == nil {
1380  		err = errnoErr(e1)
1381  	}
1382  	return
1383  }
1384  
1385  func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
1386  	r1, _, e1 := Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
1387  	if r1 == socket_error {
1388  		err = errnoErr(e1)
1389  	}
1390  	return
1391  }
1392  
1393  func GetProtoByName(name string) (p *Protoent, err error) {
1394  	var _p0 *byte
1395  	_p0, err = BytePtrFromString(name)
1396  	if err != nil {
1397  		return
1398  	}
1399  	return _GetProtoByName(_p0)
1400  }
1401  
1402  func _GetProtoByName(name *byte) (p *Protoent, err error) {
1403  	r0, _, e1 := Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
1404  	p = (*Protoent)(unsafe.Pointer(r0))
1405  	if p == nil {
1406  		err = errnoErr(e1)
1407  	}
1408  	return
1409  }
1410  
1411  func GetServByName(name string, proto string) (s *Servent, err error) {
1412  	var _p0 *byte
1413  	_p0, err = BytePtrFromString(name)
1414  	if err != nil {
1415  		return
1416  	}
1417  	var _p1 *byte
1418  	_p1, err = BytePtrFromString(proto)
1419  	if err != nil {
1420  		return
1421  	}
1422  	return _GetServByName(_p0, _p1)
1423  }
1424  
1425  func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
1426  	r0, _, e1 := Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
1427  	s = (*Servent)(unsafe.Pointer(r0))
1428  	if s == nil {
1429  		err = errnoErr(e1)
1430  	}
1431  	return
1432  }
1433  
1434  func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
1435  	r1, _, e1 := Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
1436  	if r1 == socket_error {
1437  		err = errnoErr(e1)
1438  	}
1439  	return
1440  }
1441  
1442  func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
1443  	r1, _, e1 := Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
1444  	if r1 == socket_error {
1445  		err = errnoErr(e1)
1446  	}
1447  	return
1448  }
1449  
1450  func listen(s Handle, backlog int32) (err error) {
1451  	r1, _, e1 := Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
1452  	if r1 == socket_error {
1453  		err = errnoErr(e1)
1454  	}
1455  	return
1456  }
1457  
1458  func Ntohs(netshort uint16) (u uint16) {
1459  	r0, _, _ := Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
1460  	u = uint16(r0)
1461  	return
1462  }
1463  
1464  func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
1465  	r1, _, e1 := Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
1466  	if r1 == socket_error {
1467  		err = errnoErr(e1)
1468  	}
1469  	return
1470  }
1471  
1472  func shutdown(s Handle, how int32) (err error) {
1473  	r1, _, e1 := Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
1474  	if r1 == socket_error {
1475  		err = errnoErr(e1)
1476  	}
1477  	return
1478  }
1479  
1480  func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
1481  	r0, _, e1 := Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
1482  	handle = Handle(r0)
1483  	if handle == InvalidHandle {
1484  		err = errnoErr(e1)
1485  	}
1486  	return
1487  }
1488