main
Raw Download raw file
  1//go:build windows
  2
  3// Code generated by 'go generate' using "github.com/Microsoft/go-winio/tools/mkwinsyscall"; DO NOT EDIT.
  4
  5package winio
  6
  7import (
  8	"syscall"
  9	"unsafe"
 10
 11	"golang.org/x/sys/windows"
 12)
 13
 14var _ unsafe.Pointer
 15
 16// Do the interface allocations only once for common
 17// Errno values.
 18const (
 19	errnoERROR_IO_PENDING = 997
 20)
 21
 22var (
 23	errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
 24	errERROR_EINVAL     error = syscall.EINVAL
 25)
 26
 27// errnoErr returns common boxed Errno values, to prevent
 28// allocations at runtime.
 29func errnoErr(e syscall.Errno) error {
 30	switch e {
 31	case 0:
 32		return errERROR_EINVAL
 33	case errnoERROR_IO_PENDING:
 34		return errERROR_IO_PENDING
 35	}
 36	return e
 37}
 38
 39var (
 40	modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
 41	modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
 42	modntdll    = windows.NewLazySystemDLL("ntdll.dll")
 43	modws2_32   = windows.NewLazySystemDLL("ws2_32.dll")
 44
 45	procAdjustTokenPrivileges              = modadvapi32.NewProc("AdjustTokenPrivileges")
 46	procConvertSidToStringSidW             = modadvapi32.NewProc("ConvertSidToStringSidW")
 47	procConvertStringSidToSidW             = modadvapi32.NewProc("ConvertStringSidToSidW")
 48	procImpersonateSelf                    = modadvapi32.NewProc("ImpersonateSelf")
 49	procLookupAccountNameW                 = modadvapi32.NewProc("LookupAccountNameW")
 50	procLookupAccountSidW                  = modadvapi32.NewProc("LookupAccountSidW")
 51	procLookupPrivilegeDisplayNameW        = modadvapi32.NewProc("LookupPrivilegeDisplayNameW")
 52	procLookupPrivilegeNameW               = modadvapi32.NewProc("LookupPrivilegeNameW")
 53	procLookupPrivilegeValueW              = modadvapi32.NewProc("LookupPrivilegeValueW")
 54	procOpenThreadToken                    = modadvapi32.NewProc("OpenThreadToken")
 55	procRevertToSelf                       = modadvapi32.NewProc("RevertToSelf")
 56	procBackupRead                         = modkernel32.NewProc("BackupRead")
 57	procBackupWrite                        = modkernel32.NewProc("BackupWrite")
 58	procCancelIoEx                         = modkernel32.NewProc("CancelIoEx")
 59	procConnectNamedPipe                   = modkernel32.NewProc("ConnectNamedPipe")
 60	procCreateIoCompletionPort             = modkernel32.NewProc("CreateIoCompletionPort")
 61	procCreateNamedPipeW                   = modkernel32.NewProc("CreateNamedPipeW")
 62	procDisconnectNamedPipe                = modkernel32.NewProc("DisconnectNamedPipe")
 63	procGetCurrentThread                   = modkernel32.NewProc("GetCurrentThread")
 64	procGetNamedPipeHandleStateW           = modkernel32.NewProc("GetNamedPipeHandleStateW")
 65	procGetNamedPipeInfo                   = modkernel32.NewProc("GetNamedPipeInfo")
 66	procGetQueuedCompletionStatus          = modkernel32.NewProc("GetQueuedCompletionStatus")
 67	procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
 68	procNtCreateNamedPipeFile              = modntdll.NewProc("NtCreateNamedPipeFile")
 69	procRtlDefaultNpAcl                    = modntdll.NewProc("RtlDefaultNpAcl")
 70	procRtlDosPathNameToNtPathName_U       = modntdll.NewProc("RtlDosPathNameToNtPathName_U")
 71	procRtlNtStatusToDosErrorNoTeb         = modntdll.NewProc("RtlNtStatusToDosErrorNoTeb")
 72	procWSAGetOverlappedResult             = modws2_32.NewProc("WSAGetOverlappedResult")
 73)
 74
 75func adjustTokenPrivileges(token windows.Token, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) {
 76	var _p0 uint32
 77	if releaseAll {
 78		_p0 = 1
 79	}
 80	r0, _, e1 := syscall.SyscallN(procAdjustTokenPrivileges.Addr(), uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(input)), uintptr(outputSize), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(requiredSize)))
 81	success = r0 != 0
 82	if true {
 83		err = errnoErr(e1)
 84	}
 85	return
 86}
 87
 88func convertSidToStringSid(sid *byte, str **uint16) (err error) {
 89	r1, _, e1 := syscall.SyscallN(procConvertSidToStringSidW.Addr(), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(str)))
 90	if r1 == 0 {
 91		err = errnoErr(e1)
 92	}
 93	return
 94}
 95
 96func convertStringSidToSid(str *uint16, sid **byte) (err error) {
 97	r1, _, e1 := syscall.SyscallN(procConvertStringSidToSidW.Addr(), uintptr(unsafe.Pointer(str)), uintptr(unsafe.Pointer(sid)))
 98	if r1 == 0 {
 99		err = errnoErr(e1)
100	}
101	return
102}
103
104func impersonateSelf(level uint32) (err error) {
105	r1, _, e1 := syscall.SyscallN(procImpersonateSelf.Addr(), uintptr(level))
106	if r1 == 0 {
107		err = errnoErr(e1)
108	}
109	return
110}
111
112func lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
113	var _p0 *uint16
114	_p0, err = syscall.UTF16PtrFromString(accountName)
115	if err != nil {
116		return
117	}
118	return _lookupAccountName(systemName, _p0, sid, sidSize, refDomain, refDomainSize, sidNameUse)
119}
120
121func _lookupAccountName(systemName *uint16, accountName *uint16, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
122	r1, _, e1 := syscall.SyscallN(procLookupAccountNameW.Addr(), 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)))
123	if r1 == 0 {
124		err = errnoErr(e1)
125	}
126	return
127}
128
129func lookupAccountSid(systemName *uint16, sid *byte, name *uint16, nameSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
130	r1, _, e1 := syscall.SyscallN(procLookupAccountSidW.Addr(), uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameSize)), uintptr(unsafe.Pointer(refDomain)), uintptr(unsafe.Pointer(refDomainSize)), uintptr(unsafe.Pointer(sidNameUse)))
131	if r1 == 0 {
132		err = errnoErr(e1)
133	}
134	return
135}
136
137func lookupPrivilegeDisplayName(systemName string, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) {
138	var _p0 *uint16
139	_p0, err = syscall.UTF16PtrFromString(systemName)
140	if err != nil {
141		return
142	}
143	return _lookupPrivilegeDisplayName(_p0, name, buffer, size, languageId)
144}
145
146func _lookupPrivilegeDisplayName(systemName *uint16, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) {
147	r1, _, e1 := syscall.SyscallN(procLookupPrivilegeDisplayNameW.Addr(), uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)), uintptr(unsafe.Pointer(languageId)))
148	if r1 == 0 {
149		err = errnoErr(e1)
150	}
151	return
152}
153
154func lookupPrivilegeName(systemName string, luid *uint64, buffer *uint16, size *uint32) (err error) {
155	var _p0 *uint16
156	_p0, err = syscall.UTF16PtrFromString(systemName)
157	if err != nil {
158		return
159	}
160	return _lookupPrivilegeName(_p0, luid, buffer, size)
161}
162
163func _lookupPrivilegeName(systemName *uint16, luid *uint64, buffer *uint16, size *uint32) (err error) {
164	r1, _, e1 := syscall.SyscallN(procLookupPrivilegeNameW.Addr(), uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(luid)), uintptr(unsafe.Pointer(buffer)), uintptr(unsafe.Pointer(size)))
165	if r1 == 0 {
166		err = errnoErr(e1)
167	}
168	return
169}
170
171func lookupPrivilegeValue(systemName string, name string, luid *uint64) (err error) {
172	var _p0 *uint16
173	_p0, err = syscall.UTF16PtrFromString(systemName)
174	if err != nil {
175		return
176	}
177	var _p1 *uint16
178	_p1, err = syscall.UTF16PtrFromString(name)
179	if err != nil {
180		return
181	}
182	return _lookupPrivilegeValue(_p0, _p1, luid)
183}
184
185func _lookupPrivilegeValue(systemName *uint16, name *uint16, luid *uint64) (err error) {
186	r1, _, e1 := syscall.SyscallN(procLookupPrivilegeValueW.Addr(), uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
187	if r1 == 0 {
188		err = errnoErr(e1)
189	}
190	return
191}
192
193func openThreadToken(thread windows.Handle, accessMask uint32, openAsSelf bool, token *windows.Token) (err error) {
194	var _p0 uint32
195	if openAsSelf {
196		_p0 = 1
197	}
198	r1, _, e1 := syscall.SyscallN(procOpenThreadToken.Addr(), uintptr(thread), uintptr(accessMask), uintptr(_p0), uintptr(unsafe.Pointer(token)))
199	if r1 == 0 {
200		err = errnoErr(e1)
201	}
202	return
203}
204
205func revertToSelf() (err error) {
206	r1, _, e1 := syscall.SyscallN(procRevertToSelf.Addr())
207	if r1 == 0 {
208		err = errnoErr(e1)
209	}
210	return
211}
212
213func backupRead(h windows.Handle, b []byte, bytesRead *uint32, abort bool, processSecurity bool, context *uintptr) (err error) {
214	var _p0 *byte
215	if len(b) > 0 {
216		_p0 = &b[0]
217	}
218	var _p1 uint32
219	if abort {
220		_p1 = 1
221	}
222	var _p2 uint32
223	if processSecurity {
224		_p2 = 1
225	}
226	r1, _, e1 := syscall.SyscallN(procBackupRead.Addr(), uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesRead)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)))
227	if r1 == 0 {
228		err = errnoErr(e1)
229	}
230	return
231}
232
233func backupWrite(h windows.Handle, b []byte, bytesWritten *uint32, abort bool, processSecurity bool, context *uintptr) (err error) {
234	var _p0 *byte
235	if len(b) > 0 {
236		_p0 = &b[0]
237	}
238	var _p1 uint32
239	if abort {
240		_p1 = 1
241	}
242	var _p2 uint32
243	if processSecurity {
244		_p2 = 1
245	}
246	r1, _, e1 := syscall.SyscallN(procBackupWrite.Addr(), uintptr(h), uintptr(unsafe.Pointer(_p0)), uintptr(len(b)), uintptr(unsafe.Pointer(bytesWritten)), uintptr(_p1), uintptr(_p2), uintptr(unsafe.Pointer(context)))
247	if r1 == 0 {
248		err = errnoErr(e1)
249	}
250	return
251}
252
253func cancelIoEx(file windows.Handle, o *windows.Overlapped) (err error) {
254	r1, _, e1 := syscall.SyscallN(procCancelIoEx.Addr(), uintptr(file), uintptr(unsafe.Pointer(o)))
255	if r1 == 0 {
256		err = errnoErr(e1)
257	}
258	return
259}
260
261func connectNamedPipe(pipe windows.Handle, o *windows.Overlapped) (err error) {
262	r1, _, e1 := syscall.SyscallN(procConnectNamedPipe.Addr(), uintptr(pipe), uintptr(unsafe.Pointer(o)))
263	if r1 == 0 {
264		err = errnoErr(e1)
265	}
266	return
267}
268
269func createIoCompletionPort(file windows.Handle, port windows.Handle, key uintptr, threadCount uint32) (newport windows.Handle, err error) {
270	r0, _, e1 := syscall.SyscallN(procCreateIoCompletionPort.Addr(), uintptr(file), uintptr(port), uintptr(key), uintptr(threadCount))
271	newport = windows.Handle(r0)
272	if newport == 0 {
273		err = errnoErr(e1)
274	}
275	return
276}
277
278func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *windows.SecurityAttributes) (handle windows.Handle, err error) {
279	var _p0 *uint16
280	_p0, err = syscall.UTF16PtrFromString(name)
281	if err != nil {
282		return
283	}
284	return _createNamedPipe(_p0, flags, pipeMode, maxInstances, outSize, inSize, defaultTimeout, sa)
285}
286
287func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *windows.SecurityAttributes) (handle windows.Handle, err error) {
288	r0, _, e1 := syscall.SyscallN(procCreateNamedPipeW.Addr(), uintptr(unsafe.Pointer(name)), uintptr(flags), uintptr(pipeMode), uintptr(maxInstances), uintptr(outSize), uintptr(inSize), uintptr(defaultTimeout), uintptr(unsafe.Pointer(sa)))
289	handle = windows.Handle(r0)
290	if handle == windows.InvalidHandle {
291		err = errnoErr(e1)
292	}
293	return
294}
295
296func disconnectNamedPipe(pipe windows.Handle) (err error) {
297	r1, _, e1 := syscall.SyscallN(procDisconnectNamedPipe.Addr(), uintptr(pipe))
298	if r1 == 0 {
299		err = errnoErr(e1)
300	}
301	return
302}
303
304func getCurrentThread() (h windows.Handle) {
305	r0, _, _ := syscall.SyscallN(procGetCurrentThread.Addr())
306	h = windows.Handle(r0)
307	return
308}
309
310func getNamedPipeHandleState(pipe windows.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
311	r1, _, e1 := syscall.SyscallN(procGetNamedPipeHandleStateW.Addr(), uintptr(pipe), uintptr(unsafe.Pointer(state)), uintptr(unsafe.Pointer(curInstances)), uintptr(unsafe.Pointer(maxCollectionCount)), uintptr(unsafe.Pointer(collectDataTimeout)), uintptr(unsafe.Pointer(userName)), uintptr(maxUserNameSize))
312	if r1 == 0 {
313		err = errnoErr(e1)
314	}
315	return
316}
317
318func getNamedPipeInfo(pipe windows.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) {
319	r1, _, e1 := syscall.SyscallN(procGetNamedPipeInfo.Addr(), uintptr(pipe), uintptr(unsafe.Pointer(flags)), uintptr(unsafe.Pointer(outSize)), uintptr(unsafe.Pointer(inSize)), uintptr(unsafe.Pointer(maxInstances)))
320	if r1 == 0 {
321		err = errnoErr(e1)
322	}
323	return
324}
325
326func getQueuedCompletionStatus(port windows.Handle, bytes *uint32, key *uintptr, o **ioOperation, timeout uint32) (err error) {
327	r1, _, e1 := syscall.SyscallN(procGetQueuedCompletionStatus.Addr(), uintptr(port), uintptr(unsafe.Pointer(bytes)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(o)), uintptr(timeout))
328	if r1 == 0 {
329		err = errnoErr(e1)
330	}
331	return
332}
333
334func setFileCompletionNotificationModes(h windows.Handle, flags uint8) (err error) {
335	r1, _, e1 := syscall.SyscallN(procSetFileCompletionNotificationModes.Addr(), uintptr(h), uintptr(flags))
336	if r1 == 0 {
337		err = errnoErr(e1)
338	}
339	return
340}
341
342func ntCreateNamedPipeFile(pipe *windows.Handle, access ntAccessMask, oa *objectAttributes, iosb *ioStatusBlock, share ntFileShareMode, disposition ntFileCreationDisposition, options ntFileOptions, typ uint32, readMode uint32, completionMode uint32, maxInstances uint32, inboundQuota uint32, outputQuota uint32, timeout *int64) (status ntStatus) {
343	r0, _, _ := syscall.SyscallN(procNtCreateNamedPipeFile.Addr(), 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)))
344	status = ntStatus(r0)
345	return
346}
347
348func rtlDefaultNpAcl(dacl *uintptr) (status ntStatus) {
349	r0, _, _ := syscall.SyscallN(procRtlDefaultNpAcl.Addr(), uintptr(unsafe.Pointer(dacl)))
350	status = ntStatus(r0)
351	return
352}
353
354func rtlDosPathNameToNtPathName(name *uint16, ntName *unicodeString, filePart uintptr, reserved uintptr) (status ntStatus) {
355	r0, _, _ := syscall.SyscallN(procRtlDosPathNameToNtPathName_U.Addr(), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(ntName)), uintptr(filePart), uintptr(reserved))
356	status = ntStatus(r0)
357	return
358}
359
360func rtlNtStatusToDosError(status ntStatus) (winerr error) {
361	r0, _, _ := syscall.SyscallN(procRtlNtStatusToDosErrorNoTeb.Addr(), uintptr(status))
362	if r0 != 0 {
363		winerr = syscall.Errno(r0)
364	}
365	return
366}
367
368func wsaGetOverlappedResult(h windows.Handle, o *windows.Overlapped, bytes *uint32, wait bool, flags *uint32) (err error) {
369	var _p0 uint32
370	if wait {
371		_p0 = 1
372	}
373	r1, _, e1 := syscall.SyscallN(procWSAGetOverlappedResult.Addr(), uintptr(h), uintptr(unsafe.Pointer(o)), uintptr(unsafe.Pointer(bytes)), uintptr(_p0), uintptr(unsafe.Pointer(flags)))
374	if r1 == 0 {
375		err = errnoErr(e1)
376	}
377	return
378}