github.com/kooksee/kchain@v0.0.0-20180613035215-4aef51c04906/src/golang.org/x/sys/windows/zsyscall_windows.go (about)

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