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