Tobias Klauser | 8014b7b | 2018-06-14 09:37:16 +0200 | [diff] [blame] | 1 | // Code generated by 'go generate'; DO NOT EDIT. |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 2 | |
| 3 | package registry |
| 4 | |
Brad Fitzpatrick | 3dff6e1 | 2016-04-01 04:10:49 +0000 | [diff] [blame] | 5 | import ( |
Brad Fitzpatrick | 3dff6e1 | 2016-04-01 04:10:49 +0000 | [diff] [blame] | 6 | "syscall" |
| 7 | "unsafe" |
Alex Brainman | ca83bd2 | 2016-12-02 16:54:46 +1100 | [diff] [blame] | 8 | |
| 9 | "golang.org/x/sys/windows" |
Brad Fitzpatrick | 3dff6e1 | 2016-04-01 04:10:49 +0000 | [diff] [blame] | 10 | ) |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 11 | |
| 12 | var _ unsafe.Pointer |
| 13 | |
Alex Brainman | ca83bd2 | 2016-12-02 16:54:46 +1100 | [diff] [blame] | 14 | // Do the interface allocations only once for common |
| 15 | // Errno values. |
| 16 | const ( |
| 17 | errnoERROR_IO_PENDING = 997 |
| 18 | ) |
| 19 | |
| 20 | var ( |
| 21 | errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) |
Alex Brainman | 9f70ab9 | 2020-10-24 17:55:14 +1100 | [diff] [blame] | 22 | errERROR_EINVAL error = syscall.EINVAL |
Alex Brainman | ca83bd2 | 2016-12-02 16:54:46 +1100 | [diff] [blame] | 23 | ) |
| 24 | |
| 25 | // errnoErr returns common boxed Errno values, to prevent |
| 26 | // allocations at runtime. |
| 27 | func errnoErr(e syscall.Errno) error { |
| 28 | switch e { |
| 29 | case 0: |
Alex Brainman | 9f70ab9 | 2020-10-24 17:55:14 +1100 | [diff] [blame] | 30 | return errERROR_EINVAL |
Alex Brainman | ca83bd2 | 2016-12-02 16:54:46 +1100 | [diff] [blame] | 31 | case errnoERROR_IO_PENDING: |
| 32 | return errERROR_IO_PENDING |
| 33 | } |
| 34 | // TODO: add more here, after collecting data on the common |
| 35 | // error values see on Windows. (perhaps when running |
| 36 | // all.bat?) |
| 37 | return e |
| 38 | } |
| 39 | |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 40 | var ( |
Alex Brainman | 042a8f5 | 2016-04-06 15:52:57 +1000 | [diff] [blame] | 41 | modadvapi32 = windows.NewLazySystemDLL("advapi32.dll") |
| 42 | modkernel32 = windows.NewLazySystemDLL("kernel32.dll") |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 43 | |
Alex Brainman | 0aaa271 | 2020-10-11 09:49:28 +1100 | [diff] [blame] | 44 | procRegConnectRegistryW = modadvapi32.NewProc("RegConnectRegistryW") |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 45 | procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW") |
| 46 | procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW") |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 47 | procRegDeleteValueW = modadvapi32.NewProc("RegDeleteValueW") |
Alex Brainman | 0aaa271 | 2020-10-11 09:49:28 +1100 | [diff] [blame] | 48 | procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW") |
Daniel Johansson | 98fc114 | 2015-08-29 18:46:39 +0200 | [diff] [blame] | 49 | procRegLoadMUIStringW = modadvapi32.NewProc("RegLoadMUIStringW") |
Alex Brainman | 0aaa271 | 2020-10-11 09:49:28 +1100 | [diff] [blame] | 50 | procRegSetValueExW = modadvapi32.NewProc("RegSetValueExW") |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 51 | procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW") |
| 52 | ) |
| 53 | |
Alex Brainman | 0aaa271 | 2020-10-11 09:49:28 +1100 | [diff] [blame] | 54 | func regConnectRegistry(machinename *uint16, key syscall.Handle, result *syscall.Handle) (regerrno error) { |
| 55 | r0, _, _ := syscall.Syscall(procRegConnectRegistryW.Addr(), 3, uintptr(unsafe.Pointer(machinename)), uintptr(key), uintptr(unsafe.Pointer(result))) |
| 56 | if r0 != 0 { |
| 57 | regerrno = syscall.Errno(r0) |
| 58 | } |
| 59 | return |
| 60 | } |
| 61 | |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 62 | 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) { |
| 63 | 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))) |
| 64 | if r0 != 0 { |
| 65 | regerrno = syscall.Errno(r0) |
| 66 | } |
| 67 | return |
| 68 | } |
| 69 | |
| 70 | func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) { |
| 71 | r0, _, _ := syscall.Syscall(procRegDeleteKeyW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(subkey)), 0) |
| 72 | if r0 != 0 { |
| 73 | regerrno = syscall.Errno(r0) |
| 74 | } |
| 75 | return |
| 76 | } |
| 77 | |
Alex Brainman | 0aaa271 | 2020-10-11 09:49:28 +1100 | [diff] [blame] | 78 | func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) { |
| 79 | r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0) |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 80 | if r0 != 0 { |
| 81 | regerrno = syscall.Errno(r0) |
| 82 | } |
| 83 | return |
| 84 | } |
| 85 | |
| 86 | func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { |
| 87 | 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) |
| 88 | if r0 != 0 { |
| 89 | regerrno = syscall.Errno(r0) |
| 90 | } |
| 91 | return |
| 92 | } |
| 93 | |
Daniel Johansson | 98fc114 | 2015-08-29 18:46:39 +0200 | [diff] [blame] | 94 | func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) { |
| 95 | 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) |
| 96 | if r0 != 0 { |
| 97 | regerrno = syscall.Errno(r0) |
| 98 | } |
| 99 | return |
| 100 | } |
| 101 | |
Alex Brainman | 0aaa271 | 2020-10-11 09:49:28 +1100 | [diff] [blame] | 102 | func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) { |
| 103 | r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize)) |
Alex Brainman | f5a6bd4 | 2016-12-02 19:20:04 +1100 | [diff] [blame] | 104 | if r0 != 0 { |
| 105 | regerrno = syscall.Errno(r0) |
| 106 | } |
| 107 | return |
| 108 | } |
| 109 | |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 110 | func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) { |
| 111 | r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size)) |
| 112 | n = uint32(r0) |
| 113 | if n == 0 { |
Alex Brainman | 0aaa271 | 2020-10-11 09:49:28 +1100 | [diff] [blame] | 114 | err = errnoErr(e1) |
Alex Brainman | e961698 | 2015-04-13 20:37:56 +1000 | [diff] [blame] | 115 | } |
| 116 | return |
| 117 | } |