zsyscall.go 17 KB

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