github.com/go-asm/go@v1.21.1-0.20240213172139-40c5ead50c48/syscall/windows/registry/zsyscall_windows.go (about) 1 // Code generated by 'go generate'; DO NOT EDIT. 2 3 package registry 4 5 import ( 6 "syscall" 7 "unsafe" 8 9 "github.com/go-asm/go/syscall/windows/sysdll" 10 ) 11 12 var _ unsafe.Pointer 13 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) 22 errERROR_EINVAL error = syscall.EINVAL 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: 30 return errERROR_EINVAL 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 40 var ( 41 modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll")) 42 modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll")) 43 44 procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW") 45 procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW") 46 procRegDeleteValueW = modadvapi32.NewProc("RegDeleteValueW") 47 procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW") 48 procRegLoadMUIStringW = modadvapi32.NewProc("RegLoadMUIStringW") 49 procRegSetValueExW = modadvapi32.NewProc("RegSetValueExW") 50 procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW") 51 ) 52 53 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) { 54 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))) 55 if r0 != 0 { 56 regerrno = syscall.Errno(r0) 57 } 58 return 59 } 60 61 func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) { 62 r0, _, _ := syscall.Syscall(procRegDeleteKeyW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(subkey)), 0) 63 if r0 != 0 { 64 regerrno = syscall.Errno(r0) 65 } 66 return 67 } 68 69 func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) { 70 r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0) 71 if r0 != 0 { 72 regerrno = syscall.Errno(r0) 73 } 74 return 75 } 76 77 func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { 78 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) 79 if r0 != 0 { 80 regerrno = syscall.Errno(r0) 81 } 82 return 83 } 84 85 func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) { 86 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) 87 if r0 != 0 { 88 regerrno = syscall.Errno(r0) 89 } 90 return 91 } 92 93 func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) { 94 r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize)) 95 if r0 != 0 { 96 regerrno = syscall.Errno(r0) 97 } 98 return 99 } 100 101 func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) { 102 r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size)) 103 n = uint32(r0) 104 if n == 0 { 105 err = errnoErr(e1) 106 } 107 return 108 }