zsyscall_windows.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. // MACHINE GENERATED BY 'go generate' COMMAND; 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. modwinmm = windows.NewLazySystemDLL("winmm.dll")
  34. modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
  35. procCancelIoEx = modkernel32.NewProc("CancelIoEx")
  36. procCreateIoCompletionPort = modkernel32.NewProc("CreateIoCompletionPort")
  37. procGetQueuedCompletionStatus = modkernel32.NewProc("GetQueuedCompletionStatus")
  38. procSetFileCompletionNotificationModes = modkernel32.NewProc("SetFileCompletionNotificationModes")
  39. proctimeBeginPeriod = modwinmm.NewProc("timeBeginPeriod")
  40. procConnectNamedPipe = modkernel32.NewProc("ConnectNamedPipe")
  41. procCreateNamedPipeW = modkernel32.NewProc("CreateNamedPipeW")
  42. procCreateFileW = modkernel32.NewProc("CreateFileW")
  43. procWaitNamedPipeW = modkernel32.NewProc("WaitNamedPipeW")
  44. procGetNamedPipeInfo = modkernel32.NewProc("GetNamedPipeInfo")
  45. procGetNamedPipeHandleStateW = modkernel32.NewProc("GetNamedPipeHandleStateW")
  46. procLocalAlloc = modkernel32.NewProc("LocalAlloc")
  47. procLookupAccountNameW = modadvapi32.NewProc("LookupAccountNameW")
  48. procConvertSidToStringSidW = modadvapi32.NewProc("ConvertSidToStringSidW")
  49. procConvertStringSecurityDescriptorToSecurityDescriptorW = modadvapi32.NewProc("ConvertStringSecurityDescriptorToSecurityDescriptorW")
  50. procConvertSecurityDescriptorToStringSecurityDescriptorW = modadvapi32.NewProc("ConvertSecurityDescriptorToStringSecurityDescriptorW")
  51. procLocalFree = modkernel32.NewProc("LocalFree")
  52. procGetSecurityDescriptorLength = modadvapi32.NewProc("GetSecurityDescriptorLength")
  53. procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
  54. procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle")
  55. procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
  56. procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
  57. procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
  58. procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
  59. procGetCurrentThread = modkernel32.NewProc("GetCurrentThread")
  60. procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
  61. procLookupPrivilegeNameW = modadvapi32.NewProc("LookupPrivilegeNameW")
  62. procLookupPrivilegeDisplayNameW = modadvapi32.NewProc("LookupPrivilegeDisplayNameW")
  63. procBackupRead = modkernel32.NewProc("BackupRead")
  64. procBackupWrite = modkernel32.NewProc("BackupWrite")
  65. )
  66. func cancelIoEx(file syscall.Handle, o *syscall.Overlapped) (err error) {
  67. r1, _, e1 := syscall.Syscall(procCancelIoEx.Addr(), 2, uintptr(file), uintptr(unsafe.Pointer(o)), 0)
  68. if r1 == 0 {
  69. if e1 != 0 {
  70. err = errnoErr(e1)
  71. } else {
  72. err = syscall.EINVAL
  73. }
  74. }
  75. return
  76. }
  77. func createIoCompletionPort(file syscall.Handle, port syscall.Handle, key uintptr, threadCount uint32) (newport syscall.Handle, err error) {
  78. r0, _, e1 := syscall.Syscall6(procCreateIoCompletionPort.Addr(), 4, uintptr(file), uintptr(port), uintptr(key), uintptr(threadCount), 0, 0)
  79. newport = syscall.Handle(r0)
  80. if newport == 0 {
  81. if e1 != 0 {
  82. err = errnoErr(e1)
  83. } else {
  84. err = syscall.EINVAL
  85. }
  86. }
  87. return
  88. }
  89. func getQueuedCompletionStatus(port syscall.Handle, bytes *uint32, key *uintptr, o **ioOperation, timeout uint32) (err error) {
  90. r1, _, e1 := syscall.Syscall6(procGetQueuedCompletionStatus.Addr(), 5, uintptr(port), uintptr(unsafe.Pointer(bytes)), uintptr(unsafe.Pointer(key)), uintptr(unsafe.Pointer(o)), uintptr(timeout), 0)
  91. if r1 == 0 {
  92. if e1 != 0 {
  93. err = errnoErr(e1)
  94. } else {
  95. err = syscall.EINVAL
  96. }
  97. }
  98. return
  99. }
  100. func setFileCompletionNotificationModes(h syscall.Handle, flags uint8) (err error) {
  101. r1, _, e1 := syscall.Syscall(procSetFileCompletionNotificationModes.Addr(), 2, uintptr(h), uintptr(flags), 0)
  102. if r1 == 0 {
  103. if e1 != 0 {
  104. err = errnoErr(e1)
  105. } else {
  106. err = syscall.EINVAL
  107. }
  108. }
  109. return
  110. }
  111. func timeBeginPeriod(period uint32) (n int32) {
  112. r0, _, _ := syscall.Syscall(proctimeBeginPeriod.Addr(), 1, uintptr(period), 0, 0)
  113. n = int32(r0)
  114. return
  115. }
  116. func connectNamedPipe(pipe syscall.Handle, o *syscall.Overlapped) (err error) {
  117. r1, _, e1 := syscall.Syscall(procConnectNamedPipe.Addr(), 2, uintptr(pipe), uintptr(unsafe.Pointer(o)), 0)
  118. if r1 == 0 {
  119. if e1 != 0 {
  120. err = errnoErr(e1)
  121. } else {
  122. err = syscall.EINVAL
  123. }
  124. }
  125. return
  126. }
  127. func createNamedPipe(name string, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
  128. var _p0 *uint16
  129. _p0, err = syscall.UTF16PtrFromString(name)
  130. if err != nil {
  131. return
  132. }
  133. return _createNamedPipe(_p0, flags, pipeMode, maxInstances, outSize, inSize, defaultTimeout, sa)
  134. }
  135. func _createNamedPipe(name *uint16, flags uint32, pipeMode uint32, maxInstances uint32, outSize uint32, inSize uint32, defaultTimeout uint32, sa *syscall.SecurityAttributes) (handle syscall.Handle, err error) {
  136. 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)
  137. handle = syscall.Handle(r0)
  138. if handle == syscall.InvalidHandle {
  139. if e1 != 0 {
  140. err = errnoErr(e1)
  141. } else {
  142. err = syscall.EINVAL
  143. }
  144. }
  145. return
  146. }
  147. func createFile(name string, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) {
  148. var _p0 *uint16
  149. _p0, err = syscall.UTF16PtrFromString(name)
  150. if err != nil {
  151. return
  152. }
  153. return _createFile(_p0, access, mode, sa, createmode, attrs, templatefile)
  154. }
  155. func _createFile(name *uint16, access uint32, mode uint32, sa *syscall.SecurityAttributes, createmode uint32, attrs uint32, templatefile syscall.Handle) (handle syscall.Handle, err error) {
  156. 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)
  157. handle = syscall.Handle(r0)
  158. if handle == syscall.InvalidHandle {
  159. if e1 != 0 {
  160. err = errnoErr(e1)
  161. } else {
  162. err = syscall.EINVAL
  163. }
  164. }
  165. return
  166. }
  167. func waitNamedPipe(name string, timeout uint32) (err error) {
  168. var _p0 *uint16
  169. _p0, err = syscall.UTF16PtrFromString(name)
  170. if err != nil {
  171. return
  172. }
  173. return _waitNamedPipe(_p0, timeout)
  174. }
  175. func _waitNamedPipe(name *uint16, timeout uint32) (err error) {
  176. r1, _, e1 := syscall.Syscall(procWaitNamedPipeW.Addr(), 2, uintptr(unsafe.Pointer(name)), uintptr(timeout), 0)
  177. if r1 == 0 {
  178. if e1 != 0 {
  179. err = errnoErr(e1)
  180. } else {
  181. err = syscall.EINVAL
  182. }
  183. }
  184. return
  185. }
  186. func getNamedPipeInfo(pipe syscall.Handle, flags *uint32, outSize *uint32, inSize *uint32, maxInstances *uint32) (err error) {
  187. 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)
  188. if r1 == 0 {
  189. if e1 != 0 {
  190. err = errnoErr(e1)
  191. } else {
  192. err = syscall.EINVAL
  193. }
  194. }
  195. return
  196. }
  197. func getNamedPipeHandleState(pipe syscall.Handle, state *uint32, curInstances *uint32, maxCollectionCount *uint32, collectDataTimeout *uint32, userName *uint16, maxUserNameSize uint32) (err error) {
  198. 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)
  199. if r1 == 0 {
  200. if e1 != 0 {
  201. err = errnoErr(e1)
  202. } else {
  203. err = syscall.EINVAL
  204. }
  205. }
  206. return
  207. }
  208. func localAlloc(uFlags uint32, length uint32) (ptr uintptr) {
  209. r0, _, _ := syscall.Syscall(procLocalAlloc.Addr(), 2, uintptr(uFlags), uintptr(length), 0)
  210. ptr = uintptr(r0)
  211. return
  212. }
  213. func lookupAccountName(systemName *uint16, accountName string, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
  214. var _p0 *uint16
  215. _p0, err = syscall.UTF16PtrFromString(accountName)
  216. if err != nil {
  217. return
  218. }
  219. return _lookupAccountName(systemName, _p0, sid, sidSize, refDomain, refDomainSize, sidNameUse)
  220. }
  221. func _lookupAccountName(systemName *uint16, accountName *uint16, sid *byte, sidSize *uint32, refDomain *uint16, refDomainSize *uint32, sidNameUse *uint32) (err error) {
  222. 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)
  223. if r1 == 0 {
  224. if e1 != 0 {
  225. err = errnoErr(e1)
  226. } else {
  227. err = syscall.EINVAL
  228. }
  229. }
  230. return
  231. }
  232. func convertSidToStringSid(sid *byte, str **uint16) (err error) {
  233. r1, _, e1 := syscall.Syscall(procConvertSidToStringSidW.Addr(), 2, uintptr(unsafe.Pointer(sid)), uintptr(unsafe.Pointer(str)), 0)
  234. if r1 == 0 {
  235. if e1 != 0 {
  236. err = errnoErr(e1)
  237. } else {
  238. err = syscall.EINVAL
  239. }
  240. }
  241. return
  242. }
  243. func convertStringSecurityDescriptorToSecurityDescriptor(str string, revision uint32, sd *uintptr, size *uint32) (err error) {
  244. var _p0 *uint16
  245. _p0, err = syscall.UTF16PtrFromString(str)
  246. if err != nil {
  247. return
  248. }
  249. return _convertStringSecurityDescriptorToSecurityDescriptor(_p0, revision, sd, size)
  250. }
  251. func _convertStringSecurityDescriptorToSecurityDescriptor(str *uint16, revision uint32, sd *uintptr, size *uint32) (err error) {
  252. r1, _, e1 := syscall.Syscall6(procConvertStringSecurityDescriptorToSecurityDescriptorW.Addr(), 4, uintptr(unsafe.Pointer(str)), uintptr(revision), uintptr(unsafe.Pointer(sd)), uintptr(unsafe.Pointer(size)), 0, 0)
  253. if r1 == 0 {
  254. if e1 != 0 {
  255. err = errnoErr(e1)
  256. } else {
  257. err = syscall.EINVAL
  258. }
  259. }
  260. return
  261. }
  262. func convertSecurityDescriptorToStringSecurityDescriptor(sd *byte, revision uint32, secInfo uint32, sddl **uint16, sddlSize *uint32) (err error) {
  263. r1, _, e1 := syscall.Syscall6(procConvertSecurityDescriptorToStringSecurityDescriptorW.Addr(), 5, uintptr(unsafe.Pointer(sd)), uintptr(revision), uintptr(secInfo), uintptr(unsafe.Pointer(sddl)), uintptr(unsafe.Pointer(sddlSize)), 0)
  264. if r1 == 0 {
  265. if e1 != 0 {
  266. err = errnoErr(e1)
  267. } else {
  268. err = syscall.EINVAL
  269. }
  270. }
  271. return
  272. }
  273. func localFree(mem uintptr) {
  274. syscall.Syscall(procLocalFree.Addr(), 1, uintptr(mem), 0, 0)
  275. return
  276. }
  277. func getSecurityDescriptorLength(sd uintptr) (len uint32) {
  278. r0, _, _ := syscall.Syscall(procGetSecurityDescriptorLength.Addr(), 1, uintptr(sd), 0, 0)
  279. len = uint32(r0)
  280. return
  281. }
  282. func getFileInformationByHandleEx(h syscall.Handle, class uint32, buffer *byte, size uint32) (err error) {
  283. r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 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 setFileInformationByHandle(h syscall.Handle, class uint32, buffer *byte, size uint32) (err error) {
  294. r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(h), uintptr(class), uintptr(unsafe.Pointer(buffer)), uintptr(size), 0, 0)
  295. if r1 == 0 {
  296. if e1 != 0 {
  297. err = errnoErr(e1)
  298. } else {
  299. err = syscall.EINVAL
  300. }
  301. }
  302. return
  303. }
  304. func adjustTokenPrivileges(token windows.Token, releaseAll bool, input *byte, outputSize uint32, output *byte, requiredSize *uint32) (success bool, err error) {
  305. var _p0 uint32
  306. if releaseAll {
  307. _p0 = 1
  308. } else {
  309. _p0 = 0
  310. }
  311. 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)))
  312. success = r0 != 0
  313. if true {
  314. if e1 != 0 {
  315. err = errnoErr(e1)
  316. } else {
  317. err = syscall.EINVAL
  318. }
  319. }
  320. return
  321. }
  322. func impersonateSelf(level uint32) (err error) {
  323. r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(level), 0, 0)
  324. if r1 == 0 {
  325. if e1 != 0 {
  326. err = errnoErr(e1)
  327. } else {
  328. err = syscall.EINVAL
  329. }
  330. }
  331. return
  332. }
  333. func revertToSelf() (err error) {
  334. r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
  335. if r1 == 0 {
  336. if e1 != 0 {
  337. err = errnoErr(e1)
  338. } else {
  339. err = syscall.EINVAL
  340. }
  341. }
  342. return
  343. }
  344. func openThreadToken(thread syscall.Handle, accessMask uint32, openAsSelf bool, token *windows.Token) (err error) {
  345. var _p0 uint32
  346. if openAsSelf {
  347. _p0 = 1
  348. } else {
  349. _p0 = 0
  350. }
  351. r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(thread), uintptr(accessMask), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
  352. if r1 == 0 {
  353. if e1 != 0 {
  354. err = errnoErr(e1)
  355. } else {
  356. err = syscall.EINVAL
  357. }
  358. }
  359. return
  360. }
  361. func getCurrentThread() (h syscall.Handle) {
  362. r0, _, _ := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
  363. h = syscall.Handle(r0)
  364. return
  365. }
  366. func lookupPrivilegeValue(systemName string, name string, luid *uint64) (err error) {
  367. var _p0 *uint16
  368. _p0, err = syscall.UTF16PtrFromString(systemName)
  369. if err != nil {
  370. return
  371. }
  372. var _p1 *uint16
  373. _p1, err = syscall.UTF16PtrFromString(name)
  374. if err != nil {
  375. return
  376. }
  377. return _lookupPrivilegeValue(_p0, _p1, luid)
  378. }
  379. func _lookupPrivilegeValue(systemName *uint16, name *uint16, luid *uint64) (err error) {
  380. r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemName)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
  381. if r1 == 0 {
  382. if e1 != 0 {
  383. err = errnoErr(e1)
  384. } else {
  385. err = syscall.EINVAL
  386. }
  387. }
  388. return
  389. }
  390. func lookupPrivilegeName(systemName string, luid *uint64, buffer *uint16, size *uint32) (err error) {
  391. var _p0 *uint16
  392. _p0, err = syscall.UTF16PtrFromString(systemName)
  393. if err != nil {
  394. return
  395. }
  396. return _lookupPrivilegeName(_p0, luid, buffer, size)
  397. }
  398. func _lookupPrivilegeName(systemName *uint16, luid *uint64, buffer *uint16, size *uint32) (err error) {
  399. 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)
  400. if r1 == 0 {
  401. if e1 != 0 {
  402. err = errnoErr(e1)
  403. } else {
  404. err = syscall.EINVAL
  405. }
  406. }
  407. return
  408. }
  409. func lookupPrivilegeDisplayName(systemName string, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) {
  410. var _p0 *uint16
  411. _p0, err = syscall.UTF16PtrFromString(systemName)
  412. if err != nil {
  413. return
  414. }
  415. return _lookupPrivilegeDisplayName(_p0, name, buffer, size, languageId)
  416. }
  417. func _lookupPrivilegeDisplayName(systemName *uint16, name *uint16, buffer *uint16, size *uint32, languageId *uint32) (err error) {
  418. 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)
  419. if r1 == 0 {
  420. if e1 != 0 {
  421. err = errnoErr(e1)
  422. } else {
  423. err = syscall.EINVAL
  424. }
  425. }
  426. return
  427. }
  428. func backupRead(h syscall.Handle, b []byte, bytesRead *uint32, abort bool, processSecurity bool, context *uintptr) (err error) {
  429. var _p0 *byte
  430. if len(b) > 0 {
  431. _p0 = &b[0]
  432. }
  433. var _p1 uint32
  434. if abort {
  435. _p1 = 1
  436. } else {
  437. _p1 = 0
  438. }
  439. var _p2 uint32
  440. if processSecurity {
  441. _p2 = 1
  442. } else {
  443. _p2 = 0
  444. }
  445. 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)
  446. if r1 == 0 {
  447. if e1 != 0 {
  448. err = errnoErr(e1)
  449. } else {
  450. err = syscall.EINVAL
  451. }
  452. }
  453. return
  454. }
  455. func backupWrite(h syscall.Handle, b []byte, bytesWritten *uint32, abort bool, processSecurity bool, context *uintptr) (err error) {
  456. var _p0 *byte
  457. if len(b) > 0 {
  458. _p0 = &b[0]
  459. }
  460. var _p1 uint32
  461. if abort {
  462. _p1 = 1
  463. } else {
  464. _p1 = 0
  465. }
  466. var _p2 uint32
  467. if processSecurity {
  468. _p2 = 1
  469. } else {
  470. _p2 = 0
  471. }
  472. 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)
  473. if r1 == 0 {
  474. if e1 != 0 {
  475. err = errnoErr(e1)
  476. } else {
  477. err = syscall.EINVAL
  478. }
  479. }
  480. return
  481. }