Source file
src/syscall/zsyscall_windows.go
Documentation: syscall
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 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) {
862 Syscall(procGetStartupInfoW.Addr(), 1, uintptr(unsafe.Pointer(startupInfo)), 0, 0)
863 return
864 }
865
866 func GetStdHandle(stdhandle int) (handle Handle, err error) {
867 r0, _, e1 := Syscall(procGetStdHandle.Addr(), 1, uintptr(stdhandle), 0, 0)
868 handle = Handle(r0)
869 if handle == InvalidHandle {
870 err = errnoErr(e1)
871 }
872 return
873 }
874
875 func GetSystemTimeAsFileTime(time *Filetime) {
876 Syscall(procGetSystemTimeAsFileTime.Addr(), 1, uintptr(unsafe.Pointer(time)), 0, 0)
877 return
878 }
879
880 func GetTempPath(buflen uint32, buf *uint16) (n uint32, err error) {
881 r0, _, e1 := Syscall(procGetTempPathW.Addr(), 2, uintptr(buflen), uintptr(unsafe.Pointer(buf)), 0)
882 n = uint32(r0)
883 if n == 0 {
884 err = errnoErr(e1)
885 }
886 return
887 }
888
889 func GetTimeZoneInformation(tzi *Timezoneinformation) (rc uint32, err error) {
890 r0, _, e1 := Syscall(procGetTimeZoneInformation.Addr(), 1, uintptr(unsafe.Pointer(tzi)), 0, 0)
891 rc = uint32(r0)
892 if rc == 0xffffffff {
893 err = errnoErr(e1)
894 }
895 return
896 }
897
898 func GetVersion() (ver uint32, err error) {
899 r0, _, e1 := Syscall(procGetVersion.Addr(), 0, 0, 0, 0)
900 ver = uint32(r0)
901 if ver == 0 {
902 err = errnoErr(e1)
903 }
904 return
905 }
906
907 func initializeProcThreadAttributeList(attrlist *_PROC_THREAD_ATTRIBUTE_LIST, attrcount uint32, flags uint32, size *uintptr) (err error) {
908 r1, _, e1 := Syscall6(procInitializeProcThreadAttributeList.Addr(), 4, uintptr(unsafe.Pointer(attrlist)), uintptr(attrcount), uintptr(flags), uintptr(unsafe.Pointer(size)), 0, 0)
909 if r1 == 0 {
910 err = errnoErr(e1)
911 }
912 return
913 }
914
915 func LoadLibrary(libname string) (handle Handle, err error) {
916 var _p0 *uint16
917 _p0, err = UTF16PtrFromString(libname)
918 if err != nil {
919 return
920 }
921 return _LoadLibrary(_p0)
922 }
923
924 func _LoadLibrary(libname *uint16) (handle Handle, err error) {
925 r0, _, e1 := Syscall(procLoadLibraryW.Addr(), 1, uintptr(unsafe.Pointer(libname)), 0, 0)
926 handle = Handle(r0)
927 if handle == 0 {
928 err = errnoErr(e1)
929 }
930 return
931 }
932
933 func LocalFree(hmem Handle) (handle Handle, err error) {
934 r0, _, e1 := Syscall(procLocalFree.Addr(), 1, uintptr(hmem), 0, 0)
935 handle = Handle(r0)
936 if handle != 0 {
937 err = errnoErr(e1)
938 }
939 return
940 }
941
942 func MapViewOfFile(handle Handle, access uint32, offsetHigh uint32, offsetLow uint32, length uintptr) (addr uintptr, err error) {
943 r0, _, e1 := Syscall6(procMapViewOfFile.Addr(), 5, uintptr(handle), uintptr(access), uintptr(offsetHigh), uintptr(offsetLow), uintptr(length), 0)
944 addr = uintptr(r0)
945 if addr == 0 {
946 err = errnoErr(e1)
947 }
948 return
949 }
950
951 func MoveFile(from *uint16, to *uint16) (err error) {
952 r1, _, e1 := Syscall(procMoveFileW.Addr(), 2, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), 0)
953 if r1 == 0 {
954 err = errnoErr(e1)
955 }
956 return
957 }
958
959 func OpenProcess(da uint32, inheritHandle bool, pid uint32) (handle Handle, err error) {
960 var _p0 uint32
961 if inheritHandle {
962 _p0 = 1
963 }
964 r0, _, e1 := Syscall(procOpenProcess.Addr(), 3, uintptr(da), uintptr(_p0), uintptr(pid))
965 handle = Handle(r0)
966 if handle == 0 {
967 err = errnoErr(e1)
968 }
969 return
970 }
971
972 func postQueuedCompletionStatus(cphandle Handle, qty uint32, key uintptr, overlapped *Overlapped) (err error) {
973 r1, _, e1 := Syscall6(procPostQueuedCompletionStatus.Addr(), 4, uintptr(cphandle), uintptr(qty), uintptr(key), uintptr(unsafe.Pointer(overlapped)), 0, 0)
974 if r1 == 0 {
975 err = errnoErr(e1)
976 }
977 return
978 }
979
980 func Process32First(snapshot Handle, procEntry *ProcessEntry32) (err error) {
981 r1, _, e1 := Syscall(procProcess32FirstW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
982 if r1 == 0 {
983 err = errnoErr(e1)
984 }
985 return
986 }
987
988 func Process32Next(snapshot Handle, procEntry *ProcessEntry32) (err error) {
989 r1, _, e1 := Syscall(procProcess32NextW.Addr(), 2, uintptr(snapshot), uintptr(unsafe.Pointer(procEntry)), 0)
990 if r1 == 0 {
991 err = errnoErr(e1)
992 }
993 return
994 }
995
996 func ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) {
997 r1, _, e1 := Syscall6(procReadConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(toread), uintptr(unsafe.Pointer(read)), uintptr(unsafe.Pointer(inputControl)), 0)
998 if r1 == 0 {
999 err = errnoErr(e1)
1000 }
1001 return
1002 }
1003
1004 func ReadDirectoryChanges(handle Handle, buf *byte, buflen uint32, watchSubTree bool, mask uint32, retlen *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
1005 var _p0 uint32
1006 if watchSubTree {
1007 _p0 = 1
1008 }
1009 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)
1010 if r1 == 0 {
1011 err = errnoErr(e1)
1012 }
1013 return
1014 }
1015
1016 func readFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
1017 var _p0 *byte
1018 if len(buf) > 0 {
1019 _p0 = &buf[0]
1020 }
1021 r1, _, e1 := Syscall6(procReadFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
1022 if r1 == 0 {
1023 err = errnoErr(e1)
1024 }
1025 return
1026 }
1027
1028 func RemoveDirectory(path *uint16) (err error) {
1029 r1, _, e1 := Syscall(procRemoveDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
1030 if r1 == 0 {
1031 err = errnoErr(e1)
1032 }
1033 return
1034 }
1035
1036 func SetCurrentDirectory(path *uint16) (err error) {
1037 r1, _, e1 := Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0)
1038 if r1 == 0 {
1039 err = errnoErr(e1)
1040 }
1041 return
1042 }
1043
1044 func SetEndOfFile(handle Handle) (err error) {
1045 r1, _, e1 := Syscall(procSetEndOfFile.Addr(), 1, uintptr(handle), 0, 0)
1046 if r1 == 0 {
1047 err = errnoErr(e1)
1048 }
1049 return
1050 }
1051
1052 func SetEnvironmentVariable(name *uint16, value *uint16) (err error) {
1053 r1, _, e1 := Syscall(procSetEnvironmentVariableW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(value)), 0)
1054 if r1 == 0 {
1055 err = errnoErr(e1)
1056 }
1057 return
1058 }
1059
1060 func SetFileAttributes(name *uint16, attrs uint32) (err error) {
1061 r1, _, e1 := Syscall(procSetFileAttributesW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(attrs), 0)
1062 if r1 == 0 {
1063 err = errnoErr(e1)
1064 }
1065 return
1066 }
1067
1068 func SetFileCompletionNotificationModes(handle Handle, flags uint8) (err error) {
1069 r1, _, e1 := Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(handle), uintptr(flags), 0)
1070 if r1 == 0 {
1071 err = errnoErr(e1)
1072 }
1073 return
1074 }
1075
1076 func SetFilePointer(handle Handle, lowoffset int32, highoffsetptr *int32, whence uint32) (newlowoffset uint32, err error) {
1077 r0, _, e1 := Syscall6(procSetFilePointer.Addr(), 4, uintptr(handle), uintptr(lowoffset), uintptr(unsafe.Pointer(highoffsetptr)), uintptr(whence), 0, 0)
1078 newlowoffset = uint32(r0)
1079 if newlowoffset == 0xffffffff {
1080 err = errnoErr(e1)
1081 }
1082 return
1083 }
1084
1085 func SetFileTime(handle Handle, ctime *Filetime, atime *Filetime, wtime *Filetime) (err error) {
1086 r1, _, e1 := Syscall6(procSetFileTime.Addr(), 4, uintptr(handle), uintptr(unsafe.Pointer(ctime)), uintptr(unsafe.Pointer(atime)), uintptr(unsafe.Pointer(wtime)), 0, 0)
1087 if r1 == 0 {
1088 err = errnoErr(e1)
1089 }
1090 return
1091 }
1092
1093 func SetHandleInformation(handle Handle, mask uint32, flags uint32) (err error) {
1094 r1, _, e1 := Syscall(procSetHandleInformation.Addr(), 3, uintptr(handle), uintptr(mask), uintptr(flags))
1095 if r1 == 0 {
1096 err = errnoErr(e1)
1097 }
1098 return
1099 }
1100
1101 func TerminateProcess(handle Handle, exitcode uint32) (err error) {
1102 r1, _, e1 := Syscall(procTerminateProcess.Addr(), 2, uintptr(handle), uintptr(exitcode), 0)
1103 if r1 == 0 {
1104 err = errnoErr(e1)
1105 }
1106 return
1107 }
1108
1109 func UnmapViewOfFile(addr uintptr) (err error) {
1110 r1, _, e1 := Syscall(procUnmapViewOfFile.Addr(), 1, uintptr(addr), 0, 0)
1111 if r1 == 0 {
1112 err = errnoErr(e1)
1113 }
1114 return
1115 }
1116
1117 func updateProcThreadAttribute(attrlist *_PROC_THREAD_ATTRIBUTE_LIST, flags uint32, attr uintptr, value unsafe.Pointer, size uintptr, prevvalue unsafe.Pointer, returnedsize *uintptr) (err error) {
1118 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)
1119 if r1 == 0 {
1120 err = errnoErr(e1)
1121 }
1122 return
1123 }
1124
1125 func VirtualLock(addr uintptr, length uintptr) (err error) {
1126 r1, _, e1 := Syscall(procVirtualLock.Addr(), 2, uintptr(addr), uintptr(length), 0)
1127 if r1 == 0 {
1128 err = errnoErr(e1)
1129 }
1130 return
1131 }
1132
1133 func VirtualUnlock(addr uintptr, length uintptr) (err error) {
1134 r1, _, e1 := Syscall(procVirtualUnlock.Addr(), 2, uintptr(addr), uintptr(length), 0)
1135 if r1 == 0 {
1136 err = errnoErr(e1)
1137 }
1138 return
1139 }
1140
1141 func WaitForSingleObject(handle Handle, waitMilliseconds uint32) (event uint32, err error) {
1142 r0, _, e1 := Syscall(procWaitForSingleObject.Addr(), 2, uintptr(handle), uintptr(waitMilliseconds), 0)
1143 event = uint32(r0)
1144 if event == 0xffffffff {
1145 err = errnoErr(e1)
1146 }
1147 return
1148 }
1149
1150 func WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) {
1151 r1, _, e1 := Syscall6(procWriteConsoleW.Addr(), 5, uintptr(console), uintptr(unsafe.Pointer(buf)), uintptr(towrite), uintptr(unsafe.Pointer(written)), uintptr(unsafe.Pointer(reserved)), 0)
1152 if r1 == 0 {
1153 err = errnoErr(e1)
1154 }
1155 return
1156 }
1157
1158 func writeFile(handle Handle, buf []byte, done *uint32, overlapped *Overlapped) (err error) {
1159 var _p0 *byte
1160 if len(buf) > 0 {
1161 _p0 = &buf[0]
1162 }
1163 r1, _, e1 := Syscall6(procWriteFile.Addr(), 5, uintptr(handle), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(done)), uintptr(unsafe.Pointer(overlapped)), 0)
1164 if r1 == 0 {
1165 err = errnoErr(e1)
1166 }
1167 return
1168 }
1169
1170 func AcceptEx(ls Handle, as Handle, buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, recvd *uint32, overlapped *Overlapped) (err error) {
1171 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)
1172 if r1 == 0 {
1173 err = errnoErr(e1)
1174 }
1175 return
1176 }
1177
1178 func GetAcceptExSockaddrs(buf *byte, rxdatalen uint32, laddrlen uint32, raddrlen uint32, lrsa **RawSockaddrAny, lrsalen *int32, rrsa **RawSockaddrAny, rrsalen *int32) {
1179 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)
1180 return
1181 }
1182
1183 func TransmitFile(s Handle, handle Handle, bytesToWrite uint32, bytsPerSend uint32, overlapped *Overlapped, transmitFileBuf *TransmitFileBuffers, flags uint32) (err error) {
1184 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)
1185 if r1 == 0 {
1186 err = errnoErr(e1)
1187 }
1188 return
1189 }
1190
1191 func NetApiBufferFree(buf *byte) (neterr error) {
1192 r0, _, _ := Syscall(procNetApiBufferFree.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
1193 if r0 != 0 {
1194 neterr = Errno(r0)
1195 }
1196 return
1197 }
1198
1199 func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) {
1200 r0, _, _ := Syscall(procNetGetJoinInformation.Addr(), 3, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(bufType)))
1201 if r0 != 0 {
1202 neterr = Errno(r0)
1203 }
1204 return
1205 }
1206
1207 func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) {
1208 r0, _, _ := Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0)
1209 if r0 != 0 {
1210 neterr = Errno(r0)
1211 }
1212 return
1213 }
1214
1215 func rtlGetNtVersionNumbers(majorVersion *uint32, minorVersion *uint32, buildNumber *uint32) {
1216 Syscall(procRtlGetNtVersionNumbers.Addr(), 3, uintptr(unsafe.Pointer(majorVersion)), uintptr(unsafe.Pointer(minorVersion)), uintptr(unsafe.Pointer(buildNumber)))
1217 return
1218 }
1219
1220 func GetUserNameEx(nameFormat uint32, nameBuffre *uint16, nSize *uint32) (err error) {
1221 r1, _, e1 := Syscall(procGetUserNameExW.Addr(), 3, uintptr(nameFormat), uintptr(unsafe.Pointer(nameBuffre)), uintptr(unsafe.Pointer(nSize)))
1222 if r1&0xff == 0 {
1223 err = errnoErr(e1)
1224 }
1225 return
1226 }
1227
1228 func TranslateName(accName *uint16, accNameFormat uint32, desiredNameFormat uint32, translatedName *uint16, nSize *uint32) (err error) {
1229 r1, _, e1 := Syscall6(procTranslateNameW.Addr(), 5, uintptr(unsafe.Pointer(accName)), uintptr(accNameFormat), uintptr(desiredNameFormat), uintptr(unsafe.Pointer(translatedName)), uintptr(unsafe.Pointer(nSize)), 0)
1230 if r1&0xff == 0 {
1231 err = errnoErr(e1)
1232 }
1233 return
1234 }
1235
1236 func CommandLineToArgv(cmd *uint16, argc *int32) (argv *[8192]*[8192]uint16, err error) {
1237 r0, _, e1 := Syscall(procCommandLineToArgvW.Addr(), 2, uintptr(unsafe.Pointer(cmd)), uintptr(unsafe.Pointer(argc)), 0)
1238 argv = (*[8192]*[8192]uint16)(unsafe.Pointer(r0))
1239 if argv == nil {
1240 err = errnoErr(e1)
1241 }
1242 return
1243 }
1244
1245 func GetUserProfileDirectory(t Token, dir *uint16, dirLen *uint32) (err error) {
1246 r1, _, e1 := Syscall(procGetUserProfileDirectoryW.Addr(), 3, uintptr(t), uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)))
1247 if r1 == 0 {
1248 err = errnoErr(e1)
1249 }
1250 return
1251 }
1252
1253 func FreeAddrInfoW(addrinfo *AddrinfoW) {
1254 Syscall(procFreeAddrInfoW.Addr(), 1, uintptr(unsafe.Pointer(addrinfo)), 0, 0)
1255 return
1256 }
1257
1258 func GetAddrInfoW(nodename *uint16, servicename *uint16, hints *AddrinfoW, result **AddrinfoW) (sockerr error) {
1259 r0, _, _ := Syscall6(procGetAddrInfoW.Addr(), 4, uintptr(unsafe.Pointer(nodename)), uintptr(unsafe.Pointer(servicename)), uintptr(unsafe.Pointer(hints)), uintptr(unsafe.Pointer(result)), 0, 0)
1260 if r0 != 0 {
1261 sockerr = Errno(r0)
1262 }
1263 return
1264 }
1265
1266 func WSACleanup() (err error) {
1267 r1, _, e1 := Syscall(procWSACleanup.Addr(), 0, 0, 0, 0)
1268 if r1 == socket_error {
1269 err = errnoErr(e1)
1270 }
1271 return
1272 }
1273
1274 func WSAEnumProtocols(protocols *int32, protocolBuffer *WSAProtocolInfo, bufferLength *uint32) (n int32, err error) {
1275 r0, _, e1 := Syscall(procWSAEnumProtocolsW.Addr(), 3, uintptr(unsafe.Pointer(protocols)), uintptr(unsafe.Pointer(protocolBuffer)), uintptr(unsafe.Pointer(bufferLength)))
1276 n = int32(r0)
1277 if n == -1 {
1278 err = errnoErr(e1)
1279 }
1280 return
1281 }
1282
1283 func WSAIoctl(s Handle, iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *Overlapped, completionRoutine uintptr) (err error) {
1284 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))
1285 if r1 == socket_error {
1286 err = errnoErr(e1)
1287 }
1288 return
1289 }
1290
1291 func WSARecv(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, overlapped *Overlapped, croutine *byte) (err error) {
1292 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)
1293 if r1 == socket_error {
1294 err = errnoErr(e1)
1295 }
1296 return
1297 }
1298
1299 func WSARecvFrom(s Handle, bufs *WSABuf, bufcnt uint32, recvd *uint32, flags *uint32, from *RawSockaddrAny, fromlen *int32, overlapped *Overlapped, croutine *byte) (err error) {
1300 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)))
1301 if r1 == socket_error {
1302 err = errnoErr(e1)
1303 }
1304 return
1305 }
1306
1307 func WSASend(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, overlapped *Overlapped, croutine *byte) (err error) {
1308 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)
1309 if r1 == socket_error {
1310 err = errnoErr(e1)
1311 }
1312 return
1313 }
1314
1315 func WSASendTo(s Handle, bufs *WSABuf, bufcnt uint32, sent *uint32, flags uint32, to *RawSockaddrAny, tolen int32, overlapped *Overlapped, croutine *byte) (err error) {
1316 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)))
1317 if r1 == socket_error {
1318 err = errnoErr(e1)
1319 }
1320 return
1321 }
1322
1323 func WSAStartup(verreq uint32, data *WSAData) (sockerr error) {
1324 r0, _, _ := Syscall(procWSAStartup.Addr(), 2, uintptr(verreq), uintptr(unsafe.Pointer(data)), 0)
1325 if r0 != 0 {
1326 sockerr = Errno(r0)
1327 }
1328 return
1329 }
1330
1331 func bind(s Handle, name unsafe.Pointer, namelen int32) (err error) {
1332 r1, _, e1 := Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
1333 if r1 == socket_error {
1334 err = errnoErr(e1)
1335 }
1336 return
1337 }
1338
1339 func Closesocket(s Handle) (err error) {
1340 r1, _, e1 := Syscall(procclosesocket.Addr(), 1, uintptr(s), 0, 0)
1341 if r1 == socket_error {
1342 err = errnoErr(e1)
1343 }
1344 return
1345 }
1346
1347 func connect(s Handle, name unsafe.Pointer, namelen int32) (err error) {
1348 r1, _, e1 := Syscall(procconnect.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
1349 if r1 == socket_error {
1350 err = errnoErr(e1)
1351 }
1352 return
1353 }
1354
1355 func GetHostByName(name string) (h *Hostent, err error) {
1356 var _p0 *byte
1357 _p0, err = BytePtrFromString(name)
1358 if err != nil {
1359 return
1360 }
1361 return _GetHostByName(_p0)
1362 }
1363
1364 func _GetHostByName(name *byte) (h *Hostent, err error) {
1365 r0, _, e1 := Syscall(procgethostbyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
1366 h = (*Hostent)(unsafe.Pointer(r0))
1367 if h == nil {
1368 err = errnoErr(e1)
1369 }
1370 return
1371 }
1372
1373 func getpeername(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
1374 r1, _, e1 := Syscall(procgetpeername.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
1375 if r1 == socket_error {
1376 err = errnoErr(e1)
1377 }
1378 return
1379 }
1380
1381 func GetProtoByName(name string) (p *Protoent, err error) {
1382 var _p0 *byte
1383 _p0, err = BytePtrFromString(name)
1384 if err != nil {
1385 return
1386 }
1387 return _GetProtoByName(_p0)
1388 }
1389
1390 func _GetProtoByName(name *byte) (p *Protoent, err error) {
1391 r0, _, e1 := Syscall(procgetprotobyname.Addr(), 1, uintptr(unsafe.Pointer(name)), 0, 0)
1392 p = (*Protoent)(unsafe.Pointer(r0))
1393 if p == nil {
1394 err = errnoErr(e1)
1395 }
1396 return
1397 }
1398
1399 func GetServByName(name string, proto string) (s *Servent, err error) {
1400 var _p0 *byte
1401 _p0, err = BytePtrFromString(name)
1402 if err != nil {
1403 return
1404 }
1405 var _p1 *byte
1406 _p1, err = BytePtrFromString(proto)
1407 if err != nil {
1408 return
1409 }
1410 return _GetServByName(_p0, _p1)
1411 }
1412
1413 func _GetServByName(name *byte, proto *byte) (s *Servent, err error) {
1414 r0, _, e1 := Syscall(procgetservbyname.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(proto)), 0)
1415 s = (*Servent)(unsafe.Pointer(r0))
1416 if s == nil {
1417 err = errnoErr(e1)
1418 }
1419 return
1420 }
1421
1422 func getsockname(s Handle, rsa *RawSockaddrAny, addrlen *int32) (err error) {
1423 r1, _, e1 := Syscall(procgetsockname.Addr(), 3, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
1424 if r1 == socket_error {
1425 err = errnoErr(e1)
1426 }
1427 return
1428 }
1429
1430 func Getsockopt(s Handle, level int32, optname int32, optval *byte, optlen *int32) (err error) {
1431 r1, _, e1 := Syscall6(procgetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(unsafe.Pointer(optlen)), 0)
1432 if r1 == socket_error {
1433 err = errnoErr(e1)
1434 }
1435 return
1436 }
1437
1438 func listen(s Handle, backlog int32) (err error) {
1439 r1, _, e1 := Syscall(proclisten.Addr(), 2, uintptr(s), uintptr(backlog), 0)
1440 if r1 == socket_error {
1441 err = errnoErr(e1)
1442 }
1443 return
1444 }
1445
1446 func Ntohs(netshort uint16) (u uint16) {
1447 r0, _, _ := Syscall(procntohs.Addr(), 1, uintptr(netshort), 0, 0)
1448 u = uint16(r0)
1449 return
1450 }
1451
1452 func Setsockopt(s Handle, level int32, optname int32, optval *byte, optlen int32) (err error) {
1453 r1, _, e1 := Syscall6(procsetsockopt.Addr(), 5, uintptr(s), uintptr(level), uintptr(optname), uintptr(unsafe.Pointer(optval)), uintptr(optlen), 0)
1454 if r1 == socket_error {
1455 err = errnoErr(e1)
1456 }
1457 return
1458 }
1459
1460 func shutdown(s Handle, how int32) (err error) {
1461 r1, _, e1 := Syscall(procshutdown.Addr(), 2, uintptr(s), uintptr(how), 0)
1462 if r1 == socket_error {
1463 err = errnoErr(e1)
1464 }
1465 return
1466 }
1467
1468 func socket(af int32, typ int32, protocol int32) (handle Handle, err error) {
1469 r0, _, e1 := Syscall(procsocket.Addr(), 3, uintptr(af), uintptr(typ), uintptr(protocol))
1470 handle = Handle(r0)
1471 if handle == InvalidHandle {
1472 err = errnoErr(e1)
1473 }
1474 return
1475 }
1476
View as plain text