zsyscall_windows.go 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // MACHINE GENERATED BY 'go generate' COMMAND; DO NOT EDIT
  2. package sspi
  3. import (
  4. "syscall"
  5. "unsafe"
  6. )
  7. var _ unsafe.Pointer
  8. // Do the interface allocations only once for common
  9. // Errno values.
  10. const (
  11. errnoERROR_IO_PENDING = 997
  12. )
  13. var (
  14. errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
  15. )
  16. // errnoErr returns common boxed Errno values, to prevent
  17. // allocations at runtime.
  18. func errnoErr(e syscall.Errno) error {
  19. switch e {
  20. case 0:
  21. return nil
  22. case errnoERROR_IO_PENDING:
  23. return errERROR_IO_PENDING
  24. }
  25. // TODO: add more here, after collecting data on the common
  26. // error values see on Windows. (perhaps when running
  27. // all.bat?)
  28. return e
  29. }
  30. var (
  31. modsecur32 = syscall.NewLazyDLL("secur32.dll")
  32. procQuerySecurityPackageInfoW = modsecur32.NewProc("QuerySecurityPackageInfoW")
  33. procFreeContextBuffer = modsecur32.NewProc("FreeContextBuffer")
  34. procAcquireCredentialsHandleW = modsecur32.NewProc("AcquireCredentialsHandleW")
  35. procFreeCredentialsHandle = modsecur32.NewProc("FreeCredentialsHandle")
  36. procInitializeSecurityContextW = modsecur32.NewProc("InitializeSecurityContextW")
  37. procAcceptSecurityContext = modsecur32.NewProc("AcceptSecurityContext")
  38. procCompleteAuthToken = modsecur32.NewProc("CompleteAuthToken")
  39. procDeleteSecurityContext = modsecur32.NewProc("DeleteSecurityContext")
  40. procImpersonateSecurityContext = modsecur32.NewProc("ImpersonateSecurityContext")
  41. procRevertSecurityContext = modsecur32.NewProc("RevertSecurityContext")
  42. procQueryContextAttributesW = modsecur32.NewProc("QueryContextAttributesW")
  43. procEncryptMessage = modsecur32.NewProc("EncryptMessage")
  44. procDecryptMessage = modsecur32.NewProc("DecryptMessage")
  45. procApplyControlToken = modsecur32.NewProc("ApplyControlToken")
  46. procMakeSignature = modsecur32.NewProc("MakeSignature")
  47. procVerifySignature = modsecur32.NewProc("VerifySignature")
  48. )
  49. func QuerySecurityPackageInfo(pkgname *uint16, pkginfo **SecPkgInfo) (ret syscall.Errno) {
  50. r0, _, _ := syscall.Syscall(procQuerySecurityPackageInfoW.Addr(), 2, uintptr(unsafe.Pointer(pkgname)), uintptr(unsafe.Pointer(pkginfo)), 0)
  51. ret = syscall.Errno(r0)
  52. return
  53. }
  54. func FreeContextBuffer(buf *byte) (ret syscall.Errno) {
  55. r0, _, _ := syscall.Syscall(procFreeContextBuffer.Addr(), 1, uintptr(unsafe.Pointer(buf)), 0, 0)
  56. ret = syscall.Errno(r0)
  57. return
  58. }
  59. func AcquireCredentialsHandle(principal *uint16, pkgname *uint16, creduse uint32, logonid *LUID, authdata *byte, getkeyfn uintptr, getkeyarg uintptr, handle *CredHandle, expiry *syscall.Filetime) (ret syscall.Errno) {
  60. r0, _, _ := syscall.Syscall9(procAcquireCredentialsHandleW.Addr(), 9, uintptr(unsafe.Pointer(principal)), uintptr(unsafe.Pointer(pkgname)), uintptr(creduse), uintptr(unsafe.Pointer(logonid)), uintptr(unsafe.Pointer(authdata)), uintptr(getkeyfn), uintptr(getkeyarg), uintptr(unsafe.Pointer(handle)), uintptr(unsafe.Pointer(expiry)))
  61. ret = syscall.Errno(r0)
  62. return
  63. }
  64. func FreeCredentialsHandle(handle *CredHandle) (ret syscall.Errno) {
  65. r0, _, _ := syscall.Syscall(procFreeCredentialsHandle.Addr(), 1, uintptr(unsafe.Pointer(handle)), 0, 0)
  66. ret = syscall.Errno(r0)
  67. return
  68. }
  69. func InitializeSecurityContext(credential *CredHandle, context *CtxtHandle, targname *uint16, contextreq uint32, reserved1 uint32, targdatarep uint32, input *SecBufferDesc, reserved2 uint32, newcontext *CtxtHandle, output *SecBufferDesc, contextattr *uint32, expiry *syscall.Filetime) (ret syscall.Errno) {
  70. r0, _, _ := syscall.Syscall12(procInitializeSecurityContextW.Addr(), 12, uintptr(unsafe.Pointer(credential)), uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(targname)), uintptr(contextreq), uintptr(reserved1), uintptr(targdatarep), uintptr(unsafe.Pointer(input)), uintptr(reserved2), uintptr(unsafe.Pointer(newcontext)), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(contextattr)), uintptr(unsafe.Pointer(expiry)))
  71. ret = syscall.Errno(r0)
  72. return
  73. }
  74. func AcceptSecurityContext(credential *CredHandle, context *CtxtHandle, input *SecBufferDesc, contextreq uint32, targdatarep uint32, newcontext *CtxtHandle, output *SecBufferDesc, contextattr *uint32, expiry *syscall.Filetime) (ret syscall.Errno) {
  75. r0, _, _ := syscall.Syscall9(procAcceptSecurityContext.Addr(), 9, uintptr(unsafe.Pointer(credential)), uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(input)), uintptr(contextreq), uintptr(targdatarep), uintptr(unsafe.Pointer(newcontext)), uintptr(unsafe.Pointer(output)), uintptr(unsafe.Pointer(contextattr)), uintptr(unsafe.Pointer(expiry)))
  76. ret = syscall.Errno(r0)
  77. return
  78. }
  79. func CompleteAuthToken(context *CtxtHandle, token *SecBufferDesc) (ret syscall.Errno) {
  80. r0, _, _ := syscall.Syscall(procCompleteAuthToken.Addr(), 2, uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(token)), 0)
  81. ret = syscall.Errno(r0)
  82. return
  83. }
  84. func DeleteSecurityContext(context *CtxtHandle) (ret syscall.Errno) {
  85. r0, _, _ := syscall.Syscall(procDeleteSecurityContext.Addr(), 1, uintptr(unsafe.Pointer(context)), 0, 0)
  86. ret = syscall.Errno(r0)
  87. return
  88. }
  89. func ImpersonateSecurityContext(context *CtxtHandle) (ret syscall.Errno) {
  90. r0, _, _ := syscall.Syscall(procImpersonateSecurityContext.Addr(), 1, uintptr(unsafe.Pointer(context)), 0, 0)
  91. ret = syscall.Errno(r0)
  92. return
  93. }
  94. func RevertSecurityContext(context *CtxtHandle) (ret syscall.Errno) {
  95. r0, _, _ := syscall.Syscall(procRevertSecurityContext.Addr(), 1, uintptr(unsafe.Pointer(context)), 0, 0)
  96. ret = syscall.Errno(r0)
  97. return
  98. }
  99. func QueryContextAttributes(context *CtxtHandle, attribute uint32, buf *byte) (ret syscall.Errno) {
  100. r0, _, _ := syscall.Syscall(procQueryContextAttributesW.Addr(), 3, uintptr(unsafe.Pointer(context)), uintptr(attribute), uintptr(unsafe.Pointer(buf)))
  101. ret = syscall.Errno(r0)
  102. return
  103. }
  104. func EncryptMessage(context *CtxtHandle, qop uint32, message *SecBufferDesc, messageseqno uint32) (ret syscall.Errno) {
  105. r0, _, _ := syscall.Syscall6(procEncryptMessage.Addr(), 4, uintptr(unsafe.Pointer(context)), uintptr(qop), uintptr(unsafe.Pointer(message)), uintptr(messageseqno), 0, 0)
  106. ret = syscall.Errno(r0)
  107. return
  108. }
  109. func DecryptMessage(context *CtxtHandle, message *SecBufferDesc, messageseqno uint32, qop *uint32) (ret syscall.Errno) {
  110. r0, _, _ := syscall.Syscall6(procDecryptMessage.Addr(), 4, uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(message)), uintptr(messageseqno), uintptr(unsafe.Pointer(qop)), 0, 0)
  111. ret = syscall.Errno(r0)
  112. return
  113. }
  114. func ApplyControlToken(context *CtxtHandle, input *SecBufferDesc) (ret syscall.Errno) {
  115. r0, _, _ := syscall.Syscall(procApplyControlToken.Addr(), 2, uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(input)), 0)
  116. ret = syscall.Errno(r0)
  117. return
  118. }
  119. func MakeSignature(context *CtxtHandle, qop uint32, message *SecBufferDesc, messageseqno uint32) (ret syscall.Errno) {
  120. r0, _, _ := syscall.Syscall6(procMakeSignature.Addr(), 4, uintptr(unsafe.Pointer(context)), uintptr(qop), uintptr(unsafe.Pointer(message)), uintptr(messageseqno), 0, 0)
  121. ret = syscall.Errno(r0)
  122. return
  123. }
  124. func VerifySignature(context *CtxtHandle, message *SecBufferDesc, messageseqno uint32, qop *uint32) (ret syscall.Errno) {
  125. r0, _, _ := syscall.Syscall6(procVerifySignature.Addr(), 4, uintptr(unsafe.Pointer(context)), uintptr(unsafe.Pointer(message)), uintptr(messageseqno), uintptr(unsafe.Pointer(qop)), 0, 0)
  126. ret = syscall.Errno(r0)
  127. return
  128. }