Black Lives Matter. Support the Equal Justice Initiative.

Source file src/syscall/zsyscall_windows.go

Documentation: syscall

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

View as plain text