zsyscall_windows.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. // Code generated by 'go generate'; DO NOT EDIT.
  2. package winutil
  3. import (
  4. "syscall"
  5. "unsafe"
  6. "github.com/dblohm7/wingoes"
  7. "golang.org/x/sys/windows"
  8. "golang.org/x/sys/windows/registry"
  9. )
  10. var _ unsafe.Pointer
  11. // Do the interface allocations only once for common
  12. // Errno values.
  13. const (
  14. errnoERROR_IO_PENDING = 997
  15. )
  16. var (
  17. errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
  18. errERROR_EINVAL error = syscall.EINVAL
  19. )
  20. // errnoErr returns common boxed Errno values, to prevent
  21. // allocations at runtime.
  22. func errnoErr(e syscall.Errno) error {
  23. switch e {
  24. case 0:
  25. return errERROR_EINVAL
  26. case errnoERROR_IO_PENDING:
  27. return errERROR_IO_PENDING
  28. }
  29. // TODO: add more here, after collecting data on the common
  30. // error values see on Windows. (perhaps when running
  31. // all.bat?)
  32. return e
  33. }
  34. var (
  35. modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
  36. modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
  37. modnetapi32 = windows.NewLazySystemDLL("netapi32.dll")
  38. modrstrtmgr = windows.NewLazySystemDLL("rstrtmgr.dll")
  39. moduserenv = windows.NewLazySystemDLL("userenv.dll")
  40. procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
  41. procGetApplicationRestartSettings = modkernel32.NewProc("GetApplicationRestartSettings")
  42. procRegisterApplicationRestart = modkernel32.NewProc("RegisterApplicationRestart")
  43. procDsGetDcNameW = modnetapi32.NewProc("DsGetDcNameW")
  44. procNetValidateName = modnetapi32.NewProc("NetValidateName")
  45. procRmEndSession = modrstrtmgr.NewProc("RmEndSession")
  46. procRmGetList = modrstrtmgr.NewProc("RmGetList")
  47. procRmJoinSession = modrstrtmgr.NewProc("RmJoinSession")
  48. procRmRegisterResources = modrstrtmgr.NewProc("RmRegisterResources")
  49. procRmStartSession = modrstrtmgr.NewProc("RmStartSession")
  50. procExpandEnvironmentStringsForUserW = moduserenv.NewProc("ExpandEnvironmentStringsForUserW")
  51. procLoadUserProfileW = moduserenv.NewProc("LoadUserProfileW")
  52. procUnloadUserProfile = moduserenv.NewProc("UnloadUserProfile")
  53. )
  54. func queryServiceConfig2(hService windows.Handle, infoLevel uint32, buf *byte, bufLen uint32, bytesNeeded *uint32) (err error) {
  55. r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(hService), uintptr(infoLevel), uintptr(unsafe.Pointer(buf)), uintptr(bufLen), uintptr(unsafe.Pointer(bytesNeeded)), 0)
  56. if r1 == 0 {
  57. err = errnoErr(e1)
  58. }
  59. return
  60. }
  61. func getApplicationRestartSettings(process windows.Handle, commandLine *uint16, commandLineLen *uint32, flags *uint32) (ret wingoes.HRESULT) {
  62. r0, _, _ := syscall.Syscall6(procGetApplicationRestartSettings.Addr(), 4, uintptr(process), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(commandLineLen)), uintptr(unsafe.Pointer(flags)), 0, 0)
  63. ret = wingoes.HRESULT(r0)
  64. return
  65. }
  66. func registerApplicationRestart(cmdLineExclExeName *uint16, flags uint32) (ret wingoes.HRESULT) {
  67. r0, _, _ := syscall.Syscall(procRegisterApplicationRestart.Addr(), 2, uintptr(unsafe.Pointer(cmdLineExclExeName)), uintptr(flags), 0)
  68. ret = wingoes.HRESULT(r0)
  69. return
  70. }
  71. func dsGetDcName(computerName *uint16, domainName *uint16, domainGuid *windows.GUID, siteName *uint16, flags dsGetDcNameFlag, dcInfo **_DOMAIN_CONTROLLER_INFO) (ret error) {
  72. r0, _, _ := syscall.Syscall6(procDsGetDcNameW.Addr(), 6, uintptr(unsafe.Pointer(computerName)), uintptr(unsafe.Pointer(domainName)), uintptr(unsafe.Pointer(domainGuid)), uintptr(unsafe.Pointer(siteName)), uintptr(flags), uintptr(unsafe.Pointer(dcInfo)))
  73. if r0 != 0 {
  74. ret = syscall.Errno(r0)
  75. }
  76. return
  77. }
  78. func netValidateName(server *uint16, name *uint16, account *uint16, password *uint16, nameType _NETSETUP_NAME_TYPE) (ret error) {
  79. r0, _, _ := syscall.Syscall6(procNetValidateName.Addr(), 5, uintptr(unsafe.Pointer(server)), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(account)), uintptr(unsafe.Pointer(password)), uintptr(nameType), 0)
  80. if r0 != 0 {
  81. ret = syscall.Errno(r0)
  82. }
  83. return
  84. }
  85. func rmEndSession(session _RMHANDLE) (ret error) {
  86. r0, _, _ := syscall.Syscall(procRmEndSession.Addr(), 1, uintptr(session), 0, 0)
  87. if r0 != 0 {
  88. ret = syscall.Errno(r0)
  89. }
  90. return
  91. }
  92. func rmGetList(session _RMHANDLE, nProcInfoNeeded *uint32, nProcInfo *uint32, rgAffectedApps *_RM_PROCESS_INFO, pRebootReasons *uint32) (ret error) {
  93. r0, _, _ := syscall.Syscall6(procRmGetList.Addr(), 5, uintptr(session), uintptr(unsafe.Pointer(nProcInfoNeeded)), uintptr(unsafe.Pointer(nProcInfo)), uintptr(unsafe.Pointer(rgAffectedApps)), uintptr(unsafe.Pointer(pRebootReasons)), 0)
  94. if r0 != 0 {
  95. ret = syscall.Errno(r0)
  96. }
  97. return
  98. }
  99. func rmJoinSession(pSession *_RMHANDLE, sessionKey *uint16) (ret error) {
  100. r0, _, _ := syscall.Syscall(procRmJoinSession.Addr(), 2, uintptr(unsafe.Pointer(pSession)), uintptr(unsafe.Pointer(sessionKey)), 0)
  101. if r0 != 0 {
  102. ret = syscall.Errno(r0)
  103. }
  104. return
  105. }
  106. func rmRegisterResources(session _RMHANDLE, nFiles uint32, rgsFileNames **uint16, nApplications uint32, rgApplications *_RM_UNIQUE_PROCESS, nServices uint32, rgsServiceNames **uint16) (ret error) {
  107. r0, _, _ := syscall.Syscall9(procRmRegisterResources.Addr(), 7, uintptr(session), uintptr(nFiles), uintptr(unsafe.Pointer(rgsFileNames)), uintptr(nApplications), uintptr(unsafe.Pointer(rgApplications)), uintptr(nServices), uintptr(unsafe.Pointer(rgsServiceNames)), 0, 0)
  108. if r0 != 0 {
  109. ret = syscall.Errno(r0)
  110. }
  111. return
  112. }
  113. func rmStartSession(pSession *_RMHANDLE, flags uint32, sessionKey *uint16) (ret error) {
  114. r0, _, _ := syscall.Syscall(procRmStartSession.Addr(), 3, uintptr(unsafe.Pointer(pSession)), uintptr(flags), uintptr(unsafe.Pointer(sessionKey)))
  115. if r0 != 0 {
  116. ret = syscall.Errno(r0)
  117. }
  118. return
  119. }
  120. func expandEnvironmentStringsForUser(token windows.Token, src *uint16, dst *uint16, dstLen uint32) (err error) {
  121. r1, _, e1 := syscall.Syscall6(procExpandEnvironmentStringsForUserW.Addr(), 4, uintptr(token), uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(dstLen), 0, 0)
  122. if int32(r1) == 0 {
  123. err = errnoErr(e1)
  124. }
  125. return
  126. }
  127. func loadUserProfile(token windows.Token, profileInfo *_PROFILEINFO) (err error) {
  128. r1, _, e1 := syscall.Syscall(procLoadUserProfileW.Addr(), 2, uintptr(token), uintptr(unsafe.Pointer(profileInfo)), 0)
  129. if int32(r1) == 0 {
  130. err = errnoErr(e1)
  131. }
  132. return
  133. }
  134. func unloadUserProfile(token windows.Token, profile registry.Key) (err error) {
  135. r1, _, e1 := syscall.Syscall(procUnloadUserProfile.Addr(), 2, uintptr(token), uintptr(profile), 0)
  136. if int32(r1) == 0 {
  137. err = errnoErr(e1)
  138. }
  139. return
  140. }