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