Source file src/syscall/zsyscall_windows.go

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

View as plain text