You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

zsyscall_windows.go 20KB

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