github.com/zhongdalu/gf@v1.0.0/third/golang.org/x/sys/windows/zsyscall_windows.go (about)

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