github.com/FISCO-BCOS/crypto@v0.0.0-20200202032121-bd8ab0b5d4f1/internal/syscall/windows/registry/zsyscall_windows.go (about) 1 // Code generated by 'go generate'; DO NOT EDIT. 2 3 package registry 4 5 import ( 6 "internal/syscall/windows/sysdll" 7 "syscall" 8 "unsafe" 9 ) 10 11 var _ unsafe.Pointer 12 13 // Do the interface allocations only once for common 14 // Errno values. 15 const ( 16 errnoERROR_IO_PENDING = 997 17 ) 18 19 var ( 20 errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING) 21 ) 22 23 // errnoErr returns common boxed Errno values, to prevent 24 // allocations at runtime. 25 func errnoErr(e syscall.Errno) error { 26 switch e { 27 case 0: 28 return nil 29 case errnoERROR_IO_PENDING: 30 return errERROR_IO_PENDING 31 } 32 // TODO: add more here, after collecting data on the common 33 // error values see on Windows. (perhaps when running 34 // all.bat?) 35 return e 36 } 37 38 var ( 39 modadvapi32 = syscall.NewLazyDLL(sysdll.Add("advapi32.dll")) 40 modkernel32 = syscall.NewLazyDLL(sysdll.Add("kernel32.dll")) 41 42 procRegCreateKeyExW = modadvapi32.NewProc("RegCreateKeyExW") 43 procRegDeleteKeyW = modadvapi32.NewProc("RegDeleteKeyW") 44 procRegSetValueExW = modadvapi32.NewProc("RegSetValueExW") 45 procRegEnumValueW = modadvapi32.NewProc("RegEnumValueW") 46 procRegDeleteValueW = modadvapi32.NewProc("RegDeleteValueW") 47 procRegLoadMUIStringW = modadvapi32.NewProc("RegLoadMUIStringW") 48 procExpandEnvironmentStringsW = modkernel32.NewProc("ExpandEnvironmentStringsW") 49 ) 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 59 func regDeleteKey(key syscall.Handle, subkey *uint16) (regerrno error) { 60 r0, _, _ := syscall.Syscall(procRegDeleteKeyW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(subkey)), 0) 61 if r0 != 0 { 62 regerrno = syscall.Errno(r0) 63 } 64 return 65 } 66 67 func regSetValueEx(key syscall.Handle, valueName *uint16, reserved uint32, vtype uint32, buf *byte, bufsize uint32) (regerrno error) { 68 r0, _, _ := syscall.Syscall6(procRegSetValueExW.Addr(), 6, uintptr(key), uintptr(unsafe.Pointer(valueName)), uintptr(reserved), uintptr(vtype), uintptr(unsafe.Pointer(buf)), uintptr(bufsize)) 69 if r0 != 0 { 70 regerrno = syscall.Errno(r0) 71 } 72 return 73 } 74 75 func regEnumValue(key syscall.Handle, index uint32, name *uint16, nameLen *uint32, reserved *uint32, valtype *uint32, buf *byte, buflen *uint32) (regerrno error) { 76 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) 77 if r0 != 0 { 78 regerrno = syscall.Errno(r0) 79 } 80 return 81 } 82 83 func regDeleteValue(key syscall.Handle, name *uint16) (regerrno error) { 84 r0, _, _ := syscall.Syscall(procRegDeleteValueW.Addr(), 2, uintptr(key), uintptr(unsafe.Pointer(name)), 0) 85 if r0 != 0 { 86 regerrno = syscall.Errno(r0) 87 } 88 return 89 } 90 91 func regLoadMUIString(key syscall.Handle, name *uint16, buf *uint16, buflen uint32, buflenCopied *uint32, flags uint32, dir *uint16) (regerrno error) { 92 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) 93 if r0 != 0 { 94 regerrno = syscall.Errno(r0) 95 } 96 return 97 } 98 99 func expandEnvironmentStrings(src *uint16, dst *uint16, size uint32) (n uint32, err error) { 100 r0, _, e1 := syscall.Syscall(procExpandEnvironmentStringsW.Addr(), 3, uintptr(unsafe.Pointer(src)), uintptr(unsafe.Pointer(dst)), uintptr(size)) 101 n = uint32(r0) 102 if n == 0 { 103 if e1 != 0 { 104 err = errnoErr(e1) 105 } else { 106 err = syscall.EINVAL 107 } 108 } 109 return 110 }