github.com/reiver/go@v0.0.0-20150109200633-1d0c7792f172/src/syscall/zsyscall_windows.go (about)

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