github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/src/pkg/syscall/zsyscall_windows_386.go (about)

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