1// Code generated by 'go generate'; DO NOT EDIT.
2
3package winio
4
5import (
6	"syscall"
7	"unsafe"
8
9	"golang.org/x/sys/windows"
10)
11
12var _ unsafe.Pointer
13
14// Do the interface allocations only once for common
15// Errno values.
16const (
17	errnoERROR_IO_PENDING = 997
18)
19
20var (
21	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
22)
23
24// errnoErr returns common boxed Errno values, to prevent
25// allocations at runtime.
26func errnoErr(e syscall.Errno) error {
27	switch e {
28	case 0:
29		return nil
30	case errnoERROR_IO_PENDING:
31		return errERROR_IO_PENDING
32	}
33	// TODO: add more here, after collecting data on the common
34	// error values see on Windows. (perhaps when running
35	// all.bat?)
36	return e
37}
38
39var (
40	modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
41	modws2_32   = windows.NewLazySystemDLL("ws2_32.dll")
42	modntdll    = windows.NewLazySystemDLL("ntdll.dll")
43	modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
44
45	procCancelIoEx                                           = modkernel32.NewProc("CancelIoEx")
46	procCreateIoCompletionPort                               = modkernel32.NewProc("CreateIoCompletionPort")
47	procGetQueuedCompletionStatus                            = modkernel32.NewProc("GetQueuedCompletionStatus")
48	procSetFileCompletionNotificationModes                   = modkernel32.NewProc("SetFileCompletionNotificationModes")
49	procWSAGetOverlappedResult                               = modws2_32.NewProc("WSAGetOverlappedResult")
50	procConnectNamedPipe                                     = modkernel32.NewProc("ConnectNamedPipe")
51	procCreateNamedPipeW                                     = modkernel32.NewProc("CreateNamedPipeW")
52	procCreateFileW                                          = modkernel32.NewProc("CreateFileW")
53	procGetNamedPipeInfo                                     = modkernel32.NewProc("GetNamedPipeInfo")
54	procGetNamedPipeHandleStateW                             = modkernel32.NewProc("GetNamedPipeHandleStateW")
55	procLocalAlloc                                           = modkernel32.NewProc("LocalAlloc")
56	procNtCreateNamedPipeFile                                = modntdll.NewProc("NtCreateNamedPipeFile")
57	procRtlNtStatusToDosErrorNoTeb                           = modntdll.NewProc("RtlNtStatusToDosErrorNoTeb")
58	procRtlDosPathNameToNtPathName_U                         = modntdll.NewProc("RtlDosPathNameToNtPathName_U")
59	procRtlDefaultNpAcl                                      = modntdll.NewProc("RtlDefaultNpAcl")
60	procLookupAccountNameW                                   = modadvapi32.NewProc("LookupAccountNameW")
61	procConvertSidToStringSidW                               = modadvapi32.NewProc("ConvertSidToStringSidW")
62	procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
63	procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
64	procLocalFree                                            = modkernel32.NewProc("LocalFree")
65	procGetSecurityDescriptorLength                          = modadvapi32.NewProc("GetSecurityDescriptorLength")
66	procGetFileInformationByHandleEx                         = modkernel32.NewProc("GetFileInformationByHandleEx")
67	procSetFileInformationByHandle                           = modkernel32.NewProc("SetFileInformationByHandle")
68	procAdjustTokenPrivileges                                = modadvapi32.NewProc("AdjustTokenPrivileges")
69	procImpersonateSelf                                      = modadvapi32.NewProc("ImpersonateSelf")
70	procRevertToSelf                                         = modadvapi32.NewProc("RevertToSelf")
71	procOpenThreadToken                                      = modadvapi32.NewProc("OpenThreadToken")
72	procGetCurrentThread                                     = modkernel32.NewProc("GetCurrentThread")
73	procLookupPrivilegeValueW                                = modadvapi32.NewProc("LookupPrivilegeValueW")
74	procLookupPrivilegeNameW                                 = modadvapi32.NewProc("LookupPrivilegeNameW")
75	procLookupPrivilegeDisplayNameW                          = modadvapi32.NewProc("LookupPrivilegeDisplayNameW")
76	procBackupRead                                           = modkernel32.NewProc("BackupRead")
77	procBackupWrite                                          = modkernel32.NewProc("BackupWrite")
78	procbind                                                 = modws2_32.NewProc("bind")
79)
80
81func cancelIoEx(file syscall.Handle, o *syscall.Overlapped) (err error) {
82	r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(file), uintptr(unsafe.Pointer(o)), 0)
83	if r1 == 0 {
84		if e1 != 0 {
85			err = errnoErr(e1)
86		} else {
87			err = syscall.EINVAL
88		}
89	}
90	return
91}
92
93func createIoCompletionPort(file syscall.Handle, port syscall.Handle, key uintptr, threadCount uint32) (newport syscall.Handle, err error) {
94	r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(file), uintptr(port), uintptr(key), uintptr(threadCount), 0, 0)
95	newport = syscall.Handle(r0)
96	if newport == 0 {
97		if e1 != 0 {
98			err = errnoErr(e1)
99		} else {
100			err = syscall.EINVAL
101		}
102	}
103	return
104}
105
106func getQueuedCompletionStatus(port syscall.Handle, bytes *uint32, key *uintptr, o **ioOperation, timeout uint32) (err error) {
107	r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(port), uintptr(unsafe.Pointer(bytes)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(o)), uintptr(timeout), 0)
108	if r1 == 0 {
109		if e1 != 0 {
110			err = errnoErr(e1)
111		} else {
112			err = syscall.EINVAL
113		}
114	}
115	return
116}
117
118func setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) {
119	r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(h), uintptr(flags), 0)
120	if r1 == 0 {
121		if e1 != 0 {
122			err = errnoErr(e1)
123		} else {
124			err = syscall.EINVAL
125		}
126	}
127	return
128}
129
130func wsaGetOverlappedResult(h syscall.Handle, o *syscall.Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) {
131	var _p0 uint32
132	if wait {
133		_p0 = 1
134	} else {
135		_p0 = 0
136	}
137	r1, _, e1 := syscall.Syscall6(procWSAGetOverlappedResult.Addr(), 5, uintptr(h), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(bytes)), uintptr(_p0), uintptr(unsafe.Pointer(flags)), 0)
138	if r1 == 0 {
139		if e1 != 0 {
140			err = errnoErr(e1)
141		} else {
142			err = syscall.EINVAL
143		}
144	}
145	return
146}
147
148func connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) {
149	r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(o)), 0)
150	if r1 == 0 {
151		if e1 != 0 {
152			err = errnoErr(e1)
153		} else {
154			err = syscall.EINVAL
155		}
156	}
157	return
158}
159
160func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
161	var _p0 *uint16
162	_p0, err = syscall.UTF16PtrFromString(name)
163	if err != nil {
164		return
165	}
166	return _createNamedPipe(_p0, flags, pipeMode, maxInstances, outSize, inSize, defaultTimeout, sa)
167}
168
169func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
170	r0, _, e1 := syscall.Syscall9(procCreateNamedPipeW.Addr(), 8, uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)), 0)
171	handle = syscall.Handle(r0)
172	if handle == syscall.InvalidHandle {
173		if e1 != 0 {
174			err = errnoErr(e1)
175		} else {
176			err = syscall.EINVAL
177		}
178	}
179	return
180}
181
182func createFile(name string, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) {
183	var _p0 *uint16
184	_p0, err = syscall.UTF16PtrFromString(name)
185	if err != nil {
186		return
187	}
188	return _createFile(_p0, access, mode, sa, createmode, attrs, templatefile)
189}
190
191func _createFile(name *uint16, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) {
192	r0, _, e1 := syscall.Syscall9(procCreateFileW.Addr(), 7, uintptr(unsafe.Pointer(name)), uintptr(access), uintptr(mode), uintptr(unsafe.Pointer(sa)), uintptr(createmode), uintptr(attrs), uintptr(templatefile), 0, 0)
193	handle = syscall.Handle(r0)
194	if handle == syscall.InvalidHandle {
195		if e1 != 0 {
196			err = errnoErr(e1)
197		} else {
198			err = syscall.EINVAL
199		}
200	}
201	return
202}
203
204func getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) {
205	r1, _, e1 := syscall.Syscall6(procGetNamedPipeInfo.Addr(), 5, uintptr(pipe), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(outSize)), uintptr(unsafe.Pointer(inSize)), uintptr(unsafe.Pointer(maxInstances)), 0)
206	if r1 == 0 {
207		if e1 != 0 {
208			err = errnoErr(e1)
209		} else {
210			err = syscall.EINVAL
211		}
212	}
213	return
214}
215
216func getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
217	r1, _, e1 := syscall.Syscall9(procGetNamedPipeHandleStateW.Addr(), 7, uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize), 0, 0)
218	if r1 == 0 {
219		if e1 != 0 {
220			err = errnoErr(e1)
221		} else {
222			err = syscall.EINVAL
223		}
224	}
225	return
226}
227
228func localAlloc(uFlags uint32, length uint32) (ptr uintptr) {
229	r0, _, _ := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(uFlags), uintptr(length), 0)
230	ptr = uintptr(r0)
231	return
232}
233
234func ntCreateNamedPipeFile(pipe *syscall.Handle, access uint32, oa *objectAttributes, iosb *ioStatusBlock, share uint32, disposition uint32, options uint32, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (status ntstatus) {
235	r0, _, _ := syscall.Syscall15(procNtCreateNamedPipeFile.Addr(), 14, uintptr(unsafe.Pointer(pipe)), uintptr(access), uintptr(unsafe.Pointer(oa)), uintptr(unsafe.Pointer(iosb)), uintptr(share), uintptr(disposition), uintptr(options), uintptr(typ), uintptr(readMode), uintptr(completionMode), uintptr(maxInstances), uintptr(inboundQuota), uintptr(outputQuota), uintptr(unsafe.Pointer(timeout)), 0)
236	status = ntstatus(r0)
237	return
238}
239
240func rtlNtStatusToDosError(status ntstatus) (winerr error) {
241	r0, _, _ := syscall.Syscall(procRtlNtStatusToDosErrorNoTeb.Addr(), 1, uintptr(status), 0, 0)
242	if r0 != 0 {
243		winerr = syscall.Errno(r0)
244	}
245	return
246}
247
248func rtlDosPathNameToNtPathName(name *uint16, ntName *unicodeString, filePart uintptr, reserved uintptr) (status ntstatus) {
249	r0, _, _ := syscall.Syscall6(procRtlDosPathNameToNtPathName_U.Addr(), 4, uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(ntName)), uintptr(filePart), uintptr(reserved), 0, 0)
250	status = ntstatus(r0)
251	return
252}
253
254func rtlDefaultNpAcl(dacl *uintptr) (status ntstatus) {
255	r0, _, _ := syscall.Syscall(procRtlDefaultNpAcl.Addr(), 1, uintptr(unsafe.Pointer(dacl)), 0, 0)
256	status = ntstatus(r0)
257	return
258}
259
260func lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
261	var _p0 *uint16
262	_p0, err = syscall.UTF16PtrFromString(accountName)
263	if err != nil {
264		return
265	}
266	return _lookupAccountName(systemName, _p0, sid, sidSize, refDomain, refDomainSize, sidNameUse)
267}
268
269func _lookupAccountName(systemName *uint16, accountName *uint16, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
270	r1, _, e1 := syscall.Syscall9(procLookupAccountNameW.Addr(), 7, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(accountName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(sidSize)), uintptr(unsafe.Pointer(refDomain)), uintptr(unsafe.Pointer(refDomainSize)), uintptr(unsafe.Pointer(sidNameUse)), 0, 0)
271	if r1 == 0 {
272		if e1 != 0 {
273			err = errnoErr(e1)
274		} else {
275			err = syscall.EINVAL
276		}
277	}
278	return
279}
280
281func convertSidToStringSid(sid *byte, str **uint16) (err error) {
282	r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(str)), 0)
283	if r1 == 0 {
284		if e1 != 0 {
285			err = errnoErr(e1)
286		} else {
287			err = syscall.EINVAL
288		}
289	}
290	return
291}
292
293func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd *uintptr, size *uint32) (err error) {
294	var _p0 *uint16
295	_p0, err = syscall.UTF16PtrFromString(str)
296	if err != nil {
297		return
298	}
299	return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
300}
301
302func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd *uintptr, size *uint32) (err error) {
303	r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
304	if r1 == 0 {
305		if e1 != 0 {
306			err = errnoErr(e1)
307		} else {
308			err = syscall.EINVAL
309		}
310	}
311	return
312}
313
314func convertSecurityDescriptorToStringSecurityDescriptor(sd *byte, revision uint32, secInfo uint32, sddl **uint16, sddlSize *uint32) (err error) {
315	r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(secInfo), uintptr(unsafe.Pointer(sddl)), uintptr(unsafe.Pointer(sddlSize)), 0)
316	if r1 == 0 {
317		if e1 != 0 {
318			err = errnoErr(e1)
319		} else {
320			err = syscall.EINVAL
321		}
322	}
323	return
324}
325
326func localFree(mem uintptr) {
327	syscall.Syscall(procLocalFree.Addr(), 1, uintptr(mem), 0, 0)
328	return
329}
330
331func getSecurityDescriptorLength(sd uintptr) (len uint32) {
332	r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(sd), 0, 0)
333	len = uint32(r0)
334	return
335}
336
337func getFileInformationByHandleEx(h syscall.Handle, class uint32, buffer *byte, size uint32) (err error) {
338	r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0)
339	if r1 == 0 {
340		if e1 != 0 {
341			err = errnoErr(e1)
342		} else {
343			err = syscall.EINVAL
344		}
345	}
346	return
347}
348
349func setFileInformationByHandle(h syscall.Handle, class uint32, buffer *byte, size uint32) (err error) {
350	r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0)
351	if r1 == 0 {
352		if e1 != 0 {
353			err = errnoErr(e1)
354		} else {
355			err = syscall.EINVAL
356		}
357	}
358	return
359}
360
361func adjustTokenPrivileges(token windows.Token, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) {
362	var _p0 uint32
363	if releaseAll {
364		_p0 = 1
365	} else {
366		_p0 = 0
367	}
368	r0, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(input)), uintptr(outputSize), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(requiredSize)))
369	success = r0 != 0
370	if true {
371		if e1 != 0 {
372			err = errnoErr(e1)
373		} else {
374			err = syscall.EINVAL
375		}
376	}
377	return
378}
379
380func impersonateSelf(level uint32) (err error) {
381	r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(level), 0, 0)
382	if r1 == 0 {
383		if e1 != 0 {
384			err = errnoErr(e1)
385		} else {
386			err = syscall.EINVAL
387		}
388	}
389	return
390}
391
392func revertToSelf() (err error) {
393	r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
394	if r1 == 0 {
395		if e1 != 0 {
396			err = errnoErr(e1)
397		} else {
398			err = syscall.EINVAL
399		}
400	}
401	return
402}
403
404func openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool, token *windows.Token) (err error) {
405	var _p0 uint32
406	if openAsSelf {
407		_p0 = 1
408	} else {
409		_p0 = 0
410	}
411	r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(accessMask), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
412	if r1 == 0 {
413		if e1 != 0 {
414			err = errnoErr(e1)
415		} else {
416			err = syscall.EINVAL
417		}
418	}
419	return
420}
421
422func getCurrentThread() (h syscall.Handle) {
423	r0, _, _ := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
424	h = syscall.Handle(r0)
425	return
426}
427
428func lookupPrivilegeValue(systemName string, name string, luid *uint64) (err error) {
429	var _p0 *uint16
430	_p0, err = syscall.UTF16PtrFromString(systemName)
431	if err != nil {
432		return
433	}
434	var _p1 *uint16
435	_p1, err = syscall.UTF16PtrFromString(name)
436	if err != nil {
437		return
438	}
439	return _lookupPrivilegeValue(_p0, _p1, luid)
440}
441
442func _lookupPrivilegeValue(systemName *uint16, name *uint16, luid *uint64) (err error) {
443	r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
444	if r1 == 0 {
445		if e1 != 0 {
446			err = errnoErr(e1)
447		} else {
448			err = syscall.EINVAL
449		}
450	}
451	return
452}
453
454func lookupPrivilegeName(systemName string, luid *uint64, buffer *uint16, size *uint32) (err error) {
455	var _p0 *uint16
456	_p0, err = syscall.UTF16PtrFromString(systemName)
457	if err != nil {
458		return
459	}
460	return _lookupPrivilegeName(_p0, luid, buffer, size)
461}
462
463func _lookupPrivilegeName(systemName *uint16, luid *uint64, buffer *uint16, size *uint32) (err error) {
464	r1, _, e1 := syscall.Syscall6(procLookupPrivilegeNameW.Addr(), 4, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(luid)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), 0, 0)
465	if r1 == 0 {
466		if e1 != 0 {
467			err = errnoErr(e1)
468		} else {
469			err = syscall.EINVAL
470		}
471	}
472	return
473}
474
475func lookupPrivilegeDisplayName(systemName string, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) {
476	var _p0 *uint16
477	_p0, err = syscall.UTF16PtrFromString(systemName)
478	if err != nil {
479		return
480	}
481	return _lookupPrivilegeDisplayName(_p0, name, buffer, size, languageId)
482}
483
484func _lookupPrivilegeDisplayName(systemName *uint16, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) {
485	r1, _, e1 := syscall.Syscall6(procLookupPrivilegeDisplayNameW.Addr(), 5, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(languageId)), 0)
486	if r1 == 0 {
487		if e1 != 0 {
488			err = errnoErr(e1)
489		} else {
490			err = syscall.EINVAL
491		}
492	}
493	return
494}
495
496func backupRead(h syscall.Handle, b []byte, bytesRead *uint32, abort bool, processSecurity bool, context *uintptr) (err error) {
497	var _p0 *byte
498	if len(b) > 0 {
499		_p0 = &b[0]
500	}
501	var _p1 uint32
502	if abort {
503		_p1 = 1
504	} else {
505		_p1 = 0
506	}
507	var _p2 uint32
508	if processSecurity {
509		_p2 = 1
510	} else {
511		_p2 = 0
512	}
513	r1, _, e1 := syscall.Syscall9(procBackupRead.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesRead)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0)
514	if r1 == 0 {
515		if e1 != 0 {
516			err = errnoErr(e1)
517		} else {
518			err = syscall.EINVAL
519		}
520	}
521	return
522}
523
524func backupWrite(h syscall.Handle, b []byte, bytesWritten *uint32, abort bool, processSecurity bool, context *uintptr) (err error) {
525	var _p0 *byte
526	if len(b) > 0 {
527		_p0 = &b[0]
528	}
529	var _p1 uint32
530	if abort {
531		_p1 = 1
532	} else {
533		_p1 = 0
534	}
535	var _p2 uint32
536	if processSecurity {
537		_p2 = 1
538	} else {
539		_p2 = 0
540	}
541	r1, _, e1 := syscall.Syscall9(procBackupWrite.Addr(), 7, uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesWritten)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)), 0, 0)
542	if r1 == 0 {
543		if e1 != 0 {
544			err = errnoErr(e1)
545		} else {
546			err = syscall.EINVAL
547		}
548	}
549	return
550}
551
552func bind(s syscall.Handle, name unsafe.Pointer, namelen int32) (err error) {
553	r1, _, e1 := syscall.Syscall(procbind.Addr(), 3, uintptr(s), uintptr(name), uintptr(namelen))
554	if r1 == socketError {
555		if e1 != 0 {
556			err = errnoErr(e1)
557		} else {
558			err = syscall.EINVAL
559		}
560	}
561	return
562}
563