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