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