zsyscall_windows.go 15 KB

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