PageRenderTime 183ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/libgo/go/internal/syscall/windows/zsyscall_windows.go

https://gitlab.com/adotout/gcc
Go | 327 lines | 282 code | 37 blank | 8 comment | 58 complexity | fd2a36db6ad279979992f53547273c80 MD5 | raw file
  1. // Code generated by 'go generate'; DO NOT EDIT.
  2. package windows
  3. import (
  4. "internal/syscall/windows/sysdll"
  5. "syscall"
  6. "unsafe"
  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. errERROR_EINVAL error = syscall.EINVAL
  17. )
  18. // errnoErr returns common boxed Errno values, to prevent
  19. // allocations at runtime.
  20. func errnoErr(e syscall.Errno) error {
  21. switch e {
  22. case 0:
  23. return errERROR_EINVAL
  24. case errnoERROR_IO_PENDING:
  25. return errERROR_IO_PENDING
  26. }
  27. // TODO: add more here, after collecting data on the common
  28. // error values see on Windows. (perhaps when running
  29. // all.bat?)
  30. return e
  31. }
  32. var (
  33. modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll"))
  34. modiphlpapi = syscall.NewLazyDLL(sysdll.Add("iphlpapi.dll"))
  35. modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll"))
  36. modnetapi32 = syscall.NewLazyDLL(sysdll.Add("netapi32.dll"))
  37. modpsapi = syscall.NewLazyDLL(sysdll.Add("psapi.dll"))
  38. moduserenv = syscall.NewLazyDLL(sysdll.Add("userenv.dll"))
  39. modws2_32 = syscall.NewLazyDLL(sysdll.Add("ws2_32.dll"))
  40. procAdjustTokenPrivileges = modadvapi32.NewProc("AdjustTokenPrivileges")
  41. procDuplicateTokenEx = modadvapi32.NewProc("DuplicateTokenEx")
  42. procImpersonateSelf = modadvapi32.NewProc("ImpersonateSelf")
  43. procLookupPrivilegeValueW = modadvapi32.NewProc("LookupPrivilegeValueW")
  44. procOpenThreadToken = modadvapi32.NewProc("OpenThreadToken")
  45. procRevertToSelf = modadvapi32.NewProc("RevertToSelf")
  46. procSetTokenInformation = modadvapi32.NewProc("SetTokenInformation")
  47. procSystemFunction036 = modadvapi32.NewProc("SystemFunction036")
  48. procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
  49. procGetACP = modkernel32.NewProc("GetACP")
  50. procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW")
  51. procGetConsoleCP = modkernel32.NewProc("GetConsoleCP")
  52. procGetCurrentThread = modkernel32.NewProc("GetCurrentThread")
  53. procGetFileInformationByHandleEx = modkernel32.NewProc("GetFileInformationByHandleEx")
  54. procGetFinalPathNameByHandleW = modkernel32.NewProc("GetFinalPathNameByHandleW")
  55. procGetModuleFileNameW = modkernel32.NewProc("GetModuleFileNameW")
  56. procLockFileEx = modkernel32.NewProc("LockFileEx")
  57. procMoveFileExW = modkernel32.NewProc("MoveFileExW")
  58. procMultiByteToWideChar = modkernel32.NewProc("MultiByteToWideChar")
  59. procSetFileInformationByHandle = modkernel32.NewProc("SetFileInformationByHandle")
  60. procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
  61. procNetShareAdd = modnetapi32.NewProc("NetShareAdd")
  62. procNetShareDel = modnetapi32.NewProc("NetShareDel")
  63. procNetUserGetLocalGroups = modnetapi32.NewProc("NetUserGetLocalGroups")
  64. procGetProcessMemoryInfo = modpsapi.NewProc("GetProcessMemoryInfo")
  65. procCreateEnvironmentBlock = moduserenv.NewProc("CreateEnvironmentBlock")
  66. procDestroyEnvironmentBlock = moduserenv.NewProc("DestroyEnvironmentBlock")
  67. procGetProfilesDirectoryW = moduserenv.NewProc("GetProfilesDirectoryW")
  68. procWSASocketW = modws2_32.NewProc("WSASocketW")
  69. )
  70. func adjustTokenPrivileges(token syscall.Token, disableAllPrivileges bool, newstate *TOKEN_PRIVILEGES, buflen uint32, prevstate *TOKEN_PRIVILEGES, returnlen *uint32) (ret uint32, err error) {
  71. var _p0 uint32
  72. if disableAllPrivileges {
  73. _p0 = 1
  74. }
  75. r0, _, e1 := syscall.Syscall6(procAdjustTokenPrivileges.Addr(), 6, uintptr(token), uintptr(_p0), uintptr(unsafe.Pointer(newstate)), uintptr(buflen), uintptr(unsafe.Pointer(prevstate)), uintptr(unsafe.Pointer(returnlen)))
  76. ret = uint32(r0)
  77. if true {
  78. err = errnoErr(e1)
  79. }
  80. return
  81. }
  82. func DuplicateTokenEx(hExistingToken syscall.Token, dwDesiredAccess uint32, lpTokenAttributes *syscall.SecurityAttributes, impersonationLevel uint32, tokenType TokenType, phNewToken *syscall.Token) (err error) {
  83. r1, _, e1 := syscall.Syscall6(procDuplicateTokenEx.Addr(), 6, uintptr(hExistingToken), uintptr(dwDesiredAccess), uintptr(unsafe.Pointer(lpTokenAttributes)), uintptr(impersonationLevel), uintptr(tokenType), uintptr(unsafe.Pointer(phNewToken)))
  84. if r1 == 0 {
  85. err = errnoErr(e1)
  86. }
  87. return
  88. }
  89. func ImpersonateSelf(impersonationlevel uint32) (err error) {
  90. r1, _, e1 := syscall.Syscall(procImpersonateSelf.Addr(), 1, uintptr(impersonationlevel), 0, 0)
  91. if r1 == 0 {
  92. err = errnoErr(e1)
  93. }
  94. return
  95. }
  96. func LookupPrivilegeValue(systemname *uint16, name *uint16, luid *LUID) (err error) {
  97. r1, _, e1 := syscall.Syscall(procLookupPrivilegeValueW.Addr(), 3, uintptr(unsafe.Pointer(systemname)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(luid)))
  98. if r1 == 0 {
  99. err = errnoErr(e1)
  100. }
  101. return
  102. }
  103. func OpenThreadToken(h syscall.Handle, access uint32, openasself bool, token *syscall.Token) (err error) {
  104. var _p0 uint32
  105. if openasself {
  106. _p0 = 1
  107. }
  108. r1, _, e1 := syscall.Syscall6(procOpenThreadToken.Addr(), 4, uintptr(h), uintptr(access), uintptr(_p0), uintptr(unsafe.Pointer(token)), 0, 0)
  109. if r1 == 0 {
  110. err = errnoErr(e1)
  111. }
  112. return
  113. }
  114. func RevertToSelf() (err error) {
  115. r1, _, e1 := syscall.Syscall(procRevertToSelf.Addr(), 0, 0, 0, 0)
  116. if r1 == 0 {
  117. err = errnoErr(e1)
  118. }
  119. return
  120. }
  121. func SetTokenInformation(tokenHandle syscall.Token, tokenInformationClass uint32, tokenInformation uintptr, tokenInformationLength uint32) (err error) {
  122. r1, _, e1 := syscall.Syscall6(procSetTokenInformation.Addr(), 4, uintptr(tokenHandle), uintptr(tokenInformationClass), uintptr(tokenInformation), uintptr(tokenInformationLength), 0, 0)
  123. if r1 == 0 {
  124. err = errnoErr(e1)
  125. }
  126. return
  127. }
  128. func RtlGenRandom(buf []byte) (err error) {
  129. var _p0 *byte
  130. if len(buf) > 0 {
  131. _p0 = &buf[0]
  132. }
  133. r1, _, e1 := syscall.Syscall(procSystemFunction036.Addr(), 2, uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), 0)
  134. if r1 == 0 {
  135. err = errnoErr(e1)
  136. }
  137. return
  138. }
  139. func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
  140. r0, _, _ := syscall.Syscall6(procGetAdaptersAddresses.Addr(), 5, uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)), 0)
  141. if r0 != 0 {
  142. errcode = syscall.Errno(r0)
  143. }
  144. return
  145. }
  146. func GetACP() (acp uint32) {
  147. r0, _, _ := syscall.Syscall(procGetACP.Addr(), 0, 0, 0, 0)
  148. acp = uint32(r0)
  149. return
  150. }
  151. func GetComputerNameEx(nameformat uint32, buf *uint16, n *uint32) (err error) {
  152. r1, _, e1 := syscall.Syscall(procGetComputerNameExW.Addr(), 3, uintptr(nameformat), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(n)))
  153. if r1 == 0 {
  154. err = errnoErr(e1)
  155. }
  156. return
  157. }
  158. func GetConsoleCP() (ccp uint32) {
  159. r0, _, _ := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0)
  160. ccp = uint32(r0)
  161. return
  162. }
  163. func GetCurrentThread() (pseudoHandle syscall.Handle, err error) {
  164. r0, _, e1 := syscall.Syscall(procGetCurrentThread.Addr(), 0, 0, 0, 0)
  165. pseudoHandle = syscall.Handle(r0)
  166. if pseudoHandle == 0 {
  167. err = errnoErr(e1)
  168. }
  169. return
  170. }
  171. func GetFileInformationByHandleEx(handle syscall.Handle, class uint32, info *byte, bufsize uint32) (err error) {
  172. r1, _, e1 := syscall.Syscall6(procGetFileInformationByHandleEx.Addr(), 4, uintptr(handle), uintptr(class), uintptr(unsafe.Pointer(info)), uintptr(bufsize), 0, 0)
  173. if r1 == 0 {
  174. err = errnoErr(e1)
  175. }
  176. return
  177. }
  178. func GetFinalPathNameByHandle(file syscall.Handle, filePath *uint16, filePathSize uint32, flags uint32) (n uint32, err error) {
  179. r0, _, e1 := syscall.Syscall6(procGetFinalPathNameByHandleW.Addr(), 4, uintptr(file), uintptr(unsafe.Pointer(filePath)), uintptr(filePathSize), uintptr(flags), 0, 0)
  180. n = uint32(r0)
  181. if n == 0 {
  182. err = errnoErr(e1)
  183. }
  184. return
  185. }
  186. func GetModuleFileName(module syscall.Handle, fn *uint16, len uint32) (n uint32, err error) {
  187. r0, _, e1 := syscall.Syscall(procGetModuleFileNameW.Addr(), 3, uintptr(module), uintptr(unsafe.Pointer(fn)), uintptr(len))
  188. n = uint32(r0)
  189. if n == 0 {
  190. err = errnoErr(e1)
  191. }
  192. return
  193. }
  194. func LockFileEx(file syscall.Handle, flags uint32, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
  195. r1, _, e1 := syscall.Syscall6(procLockFileEx.Addr(), 6, uintptr(file), uintptr(flags), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)))
  196. if r1 == 0 {
  197. err = errnoErr(e1)
  198. }
  199. return
  200. }
  201. func MoveFileEx(from *uint16, to *uint16, flags uint32) (err error) {
  202. r1, _, e1 := syscall.Syscall(procMoveFileExW.Addr(), 3, uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(to)), uintptr(flags))
  203. if r1 == 0 {
  204. err = errnoErr(e1)
  205. }
  206. return
  207. }
  208. func MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) {
  209. r0, _, e1 := syscall.Syscall6(procMultiByteToWideChar.Addr(), 6, uintptr(codePage), uintptr(dwFlags), uintptr(unsafe.Pointer(str)), uintptr(nstr), uintptr(unsafe.Pointer(wchar)), uintptr(nwchar))
  210. nwrite = int32(r0)
  211. if nwrite == 0 {
  212. err = errnoErr(e1)
  213. }
  214. return
  215. }
  216. func SetFileInformationByHandle(handle syscall.Handle, fileInformationClass uint32, buf uintptr, bufsize uint32) (err error) {
  217. r1, _, e1 := syscall.Syscall6(procSetFileInformationByHandle.Addr(), 4, uintptr(handle), uintptr(fileInformationClass), uintptr(buf), uintptr(bufsize), 0, 0)
  218. if r1 == 0 {
  219. err = errnoErr(e1)
  220. }
  221. return
  222. }
  223. func UnlockFileEx(file syscall.Handle, reserved uint32, bytesLow uint32, bytesHigh uint32, overlapped *syscall.Overlapped) (err error) {
  224. r1, _, e1 := syscall.Syscall6(procUnlockFileEx.Addr(), 5, uintptr(file), uintptr(reserved), uintptr(bytesLow), uintptr(bytesHigh), uintptr(unsafe.Pointer(overlapped)), 0)
  225. if r1 == 0 {
  226. err = errnoErr(e1)
  227. }
  228. return
  229. }
  230. func NetShareAdd(serverName *uint16, level uint32, buf *byte, parmErr *uint16) (neterr error) {
  231. r0, _, _ := syscall.Syscall6(procNetShareAdd.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(parmErr)), 0, 0)
  232. if r0 != 0 {
  233. neterr = syscall.Errno(r0)
  234. }
  235. return
  236. }
  237. func NetShareDel(serverName *uint16, netName *uint16, reserved uint32) (neterr error) {
  238. r0, _, _ := syscall.Syscall(procNetShareDel.Addr(), 3, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(netName)), uintptr(reserved))
  239. if r0 != 0 {
  240. neterr = syscall.Errno(r0)
  241. }
  242. return
  243. }
  244. func NetUserGetLocalGroups(serverName *uint16, userName *uint16, level uint32, flags uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32) (neterr error) {
  245. r0, _, _ := syscall.Syscall9(procNetUserGetLocalGroups.Addr(), 8, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(flags), uintptr(unsafe.Pointer(buf)), uintptr(prefMaxLen), uintptr(unsafe.Pointer(entriesRead)), uintptr(unsafe.Pointer(totalEntries)), 0)
  246. if r0 != 0 {
  247. neterr = syscall.Errno(r0)
  248. }
  249. return
  250. }
  251. func GetProcessMemoryInfo(handle syscall.Handle, memCounters *PROCESS_MEMORY_COUNTERS, cb uint32) (err error) {
  252. r1, _, e1 := syscall.Syscall(procGetProcessMemoryInfo.Addr(), 3, uintptr(handle), uintptr(unsafe.Pointer(memCounters)), uintptr(cb))
  253. if r1 == 0 {
  254. err = errnoErr(e1)
  255. }
  256. return
  257. }
  258. func CreateEnvironmentBlock(block **uint16, token syscall.Token, inheritExisting bool) (err error) {
  259. var _p0 uint32
  260. if inheritExisting {
  261. _p0 = 1
  262. }
  263. r1, _, e1 := syscall.Syscall(procCreateEnvironmentBlock.Addr(), 3, uintptr(unsafe.Pointer(block)), uintptr(token), uintptr(_p0))
  264. if r1 == 0 {
  265. err = errnoErr(e1)
  266. }
  267. return
  268. }
  269. func DestroyEnvironmentBlock(block *uint16) (err error) {
  270. r1, _, e1 := syscall.Syscall(procDestroyEnvironmentBlock.Addr(), 1, uintptr(unsafe.Pointer(block)), 0, 0)
  271. if r1 == 0 {
  272. err = errnoErr(e1)
  273. }
  274. return
  275. }
  276. func GetProfilesDirectory(dir *uint16, dirLen *uint32) (err error) {
  277. r1, _, e1 := syscall.Syscall(procGetProfilesDirectoryW.Addr(), 2, uintptr(unsafe.Pointer(dir)), uintptr(unsafe.Pointer(dirLen)), 0)
  278. if r1 == 0 {
  279. err = errnoErr(e1)
  280. }
  281. return
  282. }
  283. func WSASocket(af int32, typ int32, protocol int32, protinfo *syscall.WSAProtocolInfo, group uint32, flags uint32) (handle syscall.Handle, err error) {
  284. r0, _, e1 := syscall.Syscall6(procWSASocketW.Addr(), 6, uintptr(af), uintptr(typ), uintptr(protocol), uintptr(unsafe.Pointer(protinfo)), uintptr(group), uintptr(flags))
  285. handle = syscall.Handle(r0)
  286. if handle == syscall.InvalidHandle {
  287. err = errnoErr(e1)
  288. }
  289. return
  290. }