zsyscall_windows.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Code generated by 'go generate'; DO NOT EDIT.
  2. package security
  3. import (
  4. "syscall"
  5. "unsafe"
  6. "golang.org/x/sys/windows"
  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 = windows.NewLazySystemDLL("advapi32.dll")
  34. procGetSecurityInfo = modadvapi32.NewProc("GetSecurityInfo")
  35. procSetEntriesInAclW = modadvapi32.NewProc("SetEntriesInAclW")
  36. procSetSecurityInfo = modadvapi32.NewProc("SetSecurityInfo")
  37. )
  38. func getSecurityInfo(handle syscall.Handle, objectType uint32, si uint32, ppsidOwner **uintptr, ppsidGroup **uintptr, ppDacl *uintptr, ppSacl *uintptr, ppSecurityDescriptor *uintptr) (win32err error) {
  39. r0, _, _ := syscall.Syscall9(procGetSecurityInfo.Addr(), 8, uintptr(handle), uintptr(objectType), uintptr(si), uintptr(unsafe.Pointer(ppsidOwner)), uintptr(unsafe.Pointer(ppsidGroup)), uintptr(unsafe.Pointer(ppDacl)), uintptr(unsafe.Pointer(ppSacl)), uintptr(unsafe.Pointer(ppSecurityDescriptor)), 0)
  40. if r0 != 0 {
  41. win32err = syscall.Errno(r0)
  42. }
  43. return
  44. }
  45. func setEntriesInAcl(count uintptr, pListOfEEs uintptr, oldAcl uintptr, newAcl *uintptr) (win32err error) {
  46. r0, _, _ := syscall.Syscall6(procSetEntriesInAclW.Addr(), 4, uintptr(count), uintptr(pListOfEEs), uintptr(oldAcl), uintptr(unsafe.Pointer(newAcl)), 0, 0)
  47. if r0 != 0 {
  48. win32err = syscall.Errno(r0)
  49. }
  50. return
  51. }
  52. func setSecurityInfo(handle syscall.Handle, objectType uint32, si uint32, psidOwner uintptr, psidGroup uintptr, pDacl uintptr, pSacl uintptr) (win32err error) {
  53. r0, _, _ := syscall.Syscall9(procSetSecurityInfo.Addr(), 7, uintptr(handle), uintptr(objectType), uintptr(si), uintptr(psidOwner), uintptr(psidGroup), uintptr(pDacl), uintptr(pSacl), 0, 0)
  54. if r0 != 0 {
  55. win32err = syscall.Errno(r0)
  56. }
  57. return
  58. }