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