You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

121 lines
4.4 KiB

  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. )
  17. // errnoErr returns common boxed Errno values, to prevent
  18. // allocations at runtime.
  19. func errnoErr(e syscall.Errno) error {
  20. switch e {
  21. case 0:
  22. return nil
  23. case errnoERROR_IO_PENDING:
  24. return errERROR_IO_PENDING
  25. }
  26. // TODO: add more here, after collecting data on the common
  27. // error values see on Windows. (perhaps when running
  28. // all.bat?)
  29. return e
  30. }
  31. var (
  32. modadvapi32 = windows.NewLazySystemDLL("advapi32.dll")
  33. modkernel32 = windows.NewLazySystemDLL("kernel32.dll")
  34. procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW")
  35. procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW")
  36. procRegSetValueExW = modadvapi32.NewProc("RegSetValueExW")
  37. procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW")
  38. procRegDeleteValueW = modadvapi32.NewProc("RegDeleteValueW")
  39. procRegLoadMUIStringW = modadvapi32.NewProc("RegLoadMUIStringW")
  40. procRegConnectRegistryW = modadvapi32.NewProc("RegConnectRegistryW")
  41. procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW")
  42. )
  43. 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) {
  44. 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)))
  45. if r0 != 0 {
  46. regerrno = syscall.Errno(r0)
  47. }
  48. return
  49. }
  50. func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) {
  51. r0, _, _ := syscall.Syscall(procRegDeleteKeyW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(subkey)), 0)
  52. if r0 != 0 {
  53. regerrno = syscall.Errno(r0)
  54. }
  55. return
  56. }
  57. func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) {
  58. r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize))
  59. if r0 != 0 {
  60. regerrno = syscall.Errno(r0)
  61. }
  62. return
  63. }
  64. func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) {
  65. 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)
  66. if r0 != 0 {
  67. regerrno = syscall.Errno(r0)
  68. }
  69. return
  70. }
  71. func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) {
  72. r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0)
  73. if r0 != 0 {
  74. regerrno = syscall.Errno(r0)
  75. }
  76. return
  77. }
  78. func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) {
  79. 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)
  80. if r0 != 0 {
  81. regerrno = syscall.Errno(r0)
  82. }
  83. return
  84. }
  85. func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) {
  86. r0, _, _ := syscall.Syscall(procRegConnectRegistryW.Addr(), 3, uintptr(unsafe.Pointer(machinename)), uintptr(key), uintptr(unsafe.Pointer(result)))
  87. if r0 != 0 {
  88. regerrno = syscall.Errno(r0)
  89. }
  90. return
  91. }
  92. func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) {
  93. r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size))
  94. n = uint32(r0)
  95. if n == 0 {
  96. if e1 != 0 {
  97. err = errnoErr(e1)
  98. } else {
  99. err = syscall.EINVAL
  100. }
  101. }
  102. return
  103. }