zsyscall_windows.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. )
  9. var _ unsafe.Pointer
  10. // Do the interface allocations only once for common
  11. // Errno values.
  12. const (
  13. errnoERROR_IO_PENDING = 997
  14. )
  15. var (
  16. errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
  17. errERROR_EINVAL error = syscall.EINVAL
  18. )
  19. // errnoErr returns common boxed Errno values, to prevent
  20. // allocations at runtime.
  21. func errnoErr(e syscall.Errno) error {
  22. switch e {
  23. case 0:
  24. return errERROR_EINVAL
  25. case errnoERROR_IO_PENDING:
  26. return errERROR_IO_PENDING
  27. }
  28. // TODO: add more here, after collecting data on the common
  29. // error values see on Windows. (perhaps when running
  30. // all.bat?)
  31. return e
  32. }
  33. var (
  34. modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
  35. modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
  36. modrstrtmgr = windows.NewLazySystemDLL("rstrtmgr.dll")
  37. procQueryServiceConfig2W = modadvapi32.NewProc("QueryServiceConfig2W")
  38. procGetApplicationRestartSettings = modkernel32.NewProc("GetApplicationRestartSettings")
  39. procRegisterApplicationRestart = modkernel32.NewProc("RegisterApplicationRestart")
  40. procRmEndSession = modrstrtmgr.NewProc("RmEndSession")
  41. procRmGetList = modrstrtmgr.NewProc("RmGetList")
  42. procRmJoinSession = modrstrtmgr.NewProc("RmJoinSession")
  43. procRmRegisterResources = modrstrtmgr.NewProc("RmRegisterResources")
  44. procRmStartSession = modrstrtmgr.NewProc("RmStartSession")
  45. )
  46. func queryServiceConfig2(hService windows.Handle, infoLevel uint32, buf *byte, bufLen uint32, bytesNeeded *uint32) (err error) {
  47. r1, _, e1 := syscall.Syscall6(procQueryServiceConfig2W.Addr(), 5, uintptr(hService), uintptr(infoLevel), uintptr(unsafe.Pointer(buf)), uintptr(bufLen), uintptr(unsafe.Pointer(bytesNeeded)), 0)
  48. if r1 == 0 {
  49. err = errnoErr(e1)
  50. }
  51. return
  52. }
  53. func getApplicationRestartSettings(process windows.Handle, commandLine *uint16, commandLineLen *uint32, flags *uint32) (ret wingoes.HRESULT) {
  54. r0, _, _ := syscall.Syscall6(procGetApplicationRestartSettings.Addr(), 4, uintptr(process), uintptr(unsafe.Pointer(commandLine)), uintptr(unsafe.Pointer(commandLineLen)), uintptr(unsafe.Pointer(flags)), 0, 0)
  55. ret = wingoes.HRESULT(r0)
  56. return
  57. }
  58. func registerApplicationRestart(cmdLineExclExeName *uint16, flags uint32) (ret wingoes.HRESULT) {
  59. r0, _, _ := syscall.Syscall(procRegisterApplicationRestart.Addr(), 2, uintptr(unsafe.Pointer(cmdLineExclExeName)), uintptr(flags), 0)
  60. ret = wingoes.HRESULT(r0)
  61. return
  62. }
  63. func rmEndSession(session _RMHANDLE) (ret error) {
  64. r0, _, _ := syscall.Syscall(procRmEndSession.Addr(), 1, uintptr(session), 0, 0)
  65. if r0 != 0 {
  66. ret = syscall.Errno(r0)
  67. }
  68. return
  69. }
  70. func rmGetList(session _RMHANDLE, nProcInfoNeeded *uint32, nProcInfo *uint32, rgAffectedApps *_RM_PROCESS_INFO, pRebootReasons *uint32) (ret error) {
  71. 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)
  72. if r0 != 0 {
  73. ret = syscall.Errno(r0)
  74. }
  75. return
  76. }
  77. func rmJoinSession(pSession *_RMHANDLE, sessionKey *uint16) (ret error) {
  78. r0, _, _ := syscall.Syscall(procRmJoinSession.Addr(), 2, uintptr(unsafe.Pointer(pSession)), uintptr(unsafe.Pointer(sessionKey)), 0)
  79. if r0 != 0 {
  80. ret = syscall.Errno(r0)
  81. }
  82. return
  83. }
  84. func rmRegisterResources(session _RMHANDLE, nFiles uint32, rgsFileNames **uint16, nApplications uint32, rgApplications *_RM_UNIQUE_PROCESS, nServices uint32, rgsServiceNames **uint16) (ret error) {
  85. 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)
  86. if r0 != 0 {
  87. ret = syscall.Errno(r0)
  88. }
  89. return
  90. }
  91. func rmStartSession(pSession *_RMHANDLE, flags uint32, sessionKey *uint16) (ret error) {
  92. r0, _, _ := syscall.Syscall(procRmStartSession.Addr(), 3, uintptr(unsafe.Pointer(pSession)), uintptr(flags), uintptr(unsafe.Pointer(sessionKey)))
  93. if r0 != 0 {
  94. ret = syscall.Errno(r0)
  95. }
  96. return
  97. }