zsyscall_windows.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Code generated by 'go generate'; DO NOT EDIT.
  2. package registry
  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. modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
  35. procRegConnectRegistryW = modadvapi32.NewProc("RegConnectRegistryW")
  36. procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW")
  37. procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW")
  38. procRegDeleteValueW = modadvapi32.NewProc("RegDeleteValueW")
  39. procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW")
  40. procRegLoadMUIStringW = modadvapi32.NewProc("RegLoadMUIStringW")
  41. procRegSetValueExW = modadvapi32.NewProc("RegSetValueExW")
  42. procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW")
  43. )
  44. func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) {
  45. r0, _, _ := syscall.Syscall(procRegConnectRegistryW.Addr(), 3, uintptr(unsafe.Pointer(machinename)), uintptr(key), uintptr(unsafe.Pointer(result)))
  46. if r0 != 0 {
  47. regerrno = syscall.Errno(r0)
  48. }
  49. return
  50. }
  51. func regCreateKeyEx(key syscall.Handle, subkey *uint16, reserved uint32, class *uint16, options uint32, desired uint32, sa *syscall.SecurityAttributes, result *syscall.Handle, disposition *uint32) (regerrno error) {
  52. r0, _, _ := syscall.Syscall9(procRegCreateKeyExW.Addr(), 9, uintptr(key), uintptr(unsafe.Pointer(subkey)), uintptr(reserved), uintptr(unsafe.Pointer(class)), uintptr(options), uintptr(desired), uintptr(unsafe.Pointer(sa)), uintptr(unsafe.Pointer(result)), uintptr(unsafe.Pointer(disposition)))
  53. if r0 != 0 {
  54. regerrno = syscall.Errno(r0)
  55. }
  56. return
  57. }
  58. func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) {
  59. r0, _, _ := syscall.Syscall(procRegDeleteKeyW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(subkey)), 0)
  60. if r0 != 0 {
  61. regerrno = syscall.Errno(r0)
  62. }
  63. return
  64. }
  65. func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) {
  66. r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0)
  67. if r0 != 0 {
  68. regerrno = syscall.Errno(r0)
  69. }
  70. return
  71. }
  72. func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
  73. r0, _, _ := syscall.Syscall9(procRegEnumValueW.Addr(), 8, uintptr(key), uintptr(index), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(nameLen)), uintptr(unsafe.Pointer(reserved)), uintptr(unsafe.Pointer(valtype)), uintptr(unsafe.Pointer(buf)), uintptr(unsafe.Pointer(buflen)), 0)
  74. if r0 != 0 {
  75. regerrno = syscall.Errno(r0)
  76. }
  77. return
  78. }
  79. func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) {
  80. r0, _, _ := syscall.Syscall9(procRegLoadMUIStringW.Addr(), 7, uintptr(key), uintptr(unsafe.Pointer(name)), uintptr(unsafe.Pointer(buf)), uintptr(buflen), uintptr(unsafe.Pointer(buflenCopied)), uintptr(flags), uintptr(unsafe.Pointer(dir)), 0, 0)
  81. if r0 != 0 {
  82. regerrno = syscall.Errno(r0)
  83. }
  84. return
  85. }
  86. func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) {
  87. r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize))
  88. if r0 != 0 {
  89. regerrno = syscall.Errno(r0)
  90. }
  91. return
  92. }
  93. func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) {
  94. r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size))
  95. n = uint32(r0)
  96. if n == 0 {
  97. err = errnoErr(e1)
  98. }
  99. return
  100. }