/
zsetupapi_windows_amd64.go
179 lines (157 loc) · 7.09 KB
/
zsetupapi_windows_amd64.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// Code generated by 'go generate'; DO NOT EDIT.
package setupapi
import (
"syscall"
"unsafe"
"golang.org/x/sys/windows"
)
var _ unsafe.Pointer
// Do the interface allocations only once for common
// Errno values.
const (
errnoERROR_IO_PENDING = 997
)
var (
errERROR_IO_PENDING error = syscall.Errno(errnoERROR_IO_PENDING)
errERROR_EINVAL error = syscall.EINVAL
)
// errnoErr returns common boxed Errno values, to prevent
// allocations at runtime.
func errnoErr(e syscall.Errno) error {
switch e {
case 0:
return errERROR_EINVAL
case errnoERROR_IO_PENDING:
return errERROR_IO_PENDING
}
// TODO: add more here, after collecting data on the common
// error values see on Windows. (perhaps when running
// all.bat?)
return e
}
var (
modsetupapi = windows.NewLazySystemDLL("setupapi.dll")
procSetupDiCallClassInstaller = modsetupapi.NewProc("SetupDiCallClassInstaller")
procSetupDiCreateDeviceInfoList = modsetupapi.NewProc("SetupDiCreateDeviceInfoList")
procSetupDiCreateDeviceInfoW = modsetupapi.NewProc("SetupDiCreateDeviceInfoW")
procSetupDiDestroyDeviceInfoList = modsetupapi.NewProc("SetupDiDestroyDeviceInfoList")
procSetupDiEnumDeviceInfo = modsetupapi.NewProc("SetupDiEnumDeviceInfo")
procSetupDiGetClassDevsW = modsetupapi.NewProc("SetupDiGetClassDevsW")
procSetupDiGetDeviceInstanceIdW = modsetupapi.NewProc("SetupDiGetDeviceInstanceIdW")
procSetupDiGetDevicePropertyW = modsetupapi.NewProc("SetupDiGetDevicePropertyW")
procSetupDiGetDeviceRegistryPropertyW = modsetupapi.NewProc("SetupDiGetDeviceRegistryPropertyW")
procSetupDiGetINFClassW = modsetupapi.NewProc("SetupDiGetINFClassW")
procSetupDiOpenDevRegKey = modsetupapi.NewProc("SetupDiOpenDevRegKey")
procSetupDiOpenDeviceInfoW = modsetupapi.NewProc("SetupDiOpenDeviceInfoW")
procSetupDiSetDeviceRegistryPropertyW = modsetupapi.NewProc("SetupDiSetDeviceRegistryPropertyW")
)
func SetupDiCallClassInstaller(installFn uintptr, devInfoSet syscall.Handle, data *SpDevinfoData) (err error) {
r1, _, e1 := syscall.Syscall(procSetupDiCallClassInstaller.Addr(), 3, uintptr(installFn), uintptr(devInfoSet), uintptr(unsafe.Pointer(data)))
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiCreateDeviceInfoList(g *Guid, hwnd uintptr) (devInfoSet syscall.Handle, err error) {
r0, _, e1 := syscall.Syscall(procSetupDiCreateDeviceInfoList.Addr(), 2, uintptr(unsafe.Pointer(g)), uintptr(hwnd), 0)
devInfoSet = syscall.Handle(r0)
if devInfoSet == syscall.InvalidHandle {
err = errnoErr(e1)
}
return
}
func SetupDiCreateDeviceInfo(devInfoSet syscall.Handle, devName *uint16, g *Guid, devDesc *uint16, hwnd uintptr, cflags uint32, dataOut *SpDevinfoData) (err error) {
r1, _, e1 := syscall.Syscall9(procSetupDiCreateDeviceInfoW.Addr(), 7, uintptr(devInfoSet), uintptr(unsafe.Pointer(devName)), uintptr(unsafe.Pointer(g)), uintptr(unsafe.Pointer(devDesc)), uintptr(hwnd), uintptr(cflags), uintptr(unsafe.Pointer(dataOut)), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiDestroyDeviceInfoList(devInfoSet syscall.Handle) (err error) {
r1, _, e1 := syscall.Syscall(procSetupDiDestroyDeviceInfoList.Addr(), 1, uintptr(devInfoSet), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiEnumDeviceInfo(devInfoSet syscall.Handle, index uint32, diData *SpDevinfoData) (err error) {
r1, _, e1 := syscall.Syscall(procSetupDiEnumDeviceInfo.Addr(), 3, uintptr(devInfoSet), uintptr(index), uintptr(unsafe.Pointer(diData)))
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiGetClassDevs(class *Guid, enum *uint16, parent syscall.Handle, flags uint32) (devInfoSet syscall.Handle, err error) {
r0, _, e1 := syscall.Syscall6(procSetupDiGetClassDevsW.Addr(), 4, uintptr(unsafe.Pointer(class)), uintptr(unsafe.Pointer(enum)), uintptr(parent), uintptr(flags), 0, 0)
devInfoSet = syscall.Handle(r0)
if devInfoSet == syscall.InvalidHandle {
err = errnoErr(e1)
}
return
}
func SetupDiGetDeviceInstanceId(devInfoSet syscall.Handle, diData *SpDevinfoData, id []uint16, reqSz *uint32) (err error) {
var _p0 *uint16
if len(id) > 0 {
_p0 = &id[0]
}
r1, _, e1 := syscall.Syscall6(procSetupDiGetDeviceInstanceIdW.Addr(), 5, uintptr(devInfoSet), uintptr(unsafe.Pointer(diData)), uintptr(unsafe.Pointer(_p0)), uintptr(len(id)), uintptr(unsafe.Pointer(reqSz)), 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiGetDeviceProperty(devInfoSet syscall.Handle, diData *SpDevinfoData, pKey *DevPropKey, pType *DevPropType, buf []byte, size *uint32, flags uint32) (err error) {
var _p0 *byte
if len(buf) > 0 {
_p0 = &buf[0]
}
r1, _, e1 := syscall.Syscall9(procSetupDiGetDevicePropertyW.Addr(), 8, uintptr(devInfoSet), uintptr(unsafe.Pointer(diData)), uintptr(unsafe.Pointer(pKey)), uintptr(unsafe.Pointer(pType)), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(size)), uintptr(flags), 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiGetDeviceRegistryProperty(devInfoSet syscall.Handle, diData *SpDevinfoData, prop uint32, regDataType *uint32, buf []byte, size *uint32) (err error) {
var _p0 *byte
if len(buf) > 0 {
_p0 = &buf[0]
}
r1, _, e1 := syscall.Syscall9(procSetupDiGetDeviceRegistryPropertyW.Addr(), 7, uintptr(devInfoSet), uintptr(unsafe.Pointer(diData)), uintptr(prop), uintptr(unsafe.Pointer(regDataType)), uintptr(unsafe.Pointer(_p0)), uintptr(len(buf)), uintptr(unsafe.Pointer(size)), 0, 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiGetINFClass(infPath *uint16, guid *Guid, className []uint16, reqSz *uint32) (err error) {
var _p0 *uint16
if len(className) > 0 {
_p0 = &className[0]
}
r1, _, e1 := syscall.Syscall6(procSetupDiGetINFClassW.Addr(), 5, uintptr(unsafe.Pointer(infPath)), uintptr(unsafe.Pointer(guid)), uintptr(unsafe.Pointer(_p0)), uintptr(len(className)), uintptr(unsafe.Pointer(reqSz)), 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiOpenDevRegKey(devInfoSet syscall.Handle, diData *SpDevinfoData, scope uint32, hwProfile uint32, keyType uint32, desiredAccess uint32) (h syscall.Handle, err error) {
r0, _, e1 := syscall.Syscall6(procSetupDiOpenDevRegKey.Addr(), 6, uintptr(devInfoSet), uintptr(unsafe.Pointer(diData)), uintptr(scope), uintptr(hwProfile), uintptr(keyType), uintptr(desiredAccess))
h = syscall.Handle(r0)
if h == syscall.InvalidHandle {
err = errnoErr(e1)
}
return
}
func SetupDiOpenDeviceInfo(devInfoSet syscall.Handle, deviceInstanceId *uint16, hwndParent syscall.Handle, openFlags uint32, diData *SpDevinfoData) (err error) {
r1, _, e1 := syscall.Syscall6(procSetupDiOpenDeviceInfoW.Addr(), 5, uintptr(devInfoSet), uintptr(unsafe.Pointer(deviceInstanceId)), uintptr(hwndParent), uintptr(openFlags), uintptr(unsafe.Pointer(diData)), 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}
func SetupDiSetDeviceRegistryProperty(devInfoSet syscall.Handle, data *SpDevinfoData, prop uint32, buf *byte, sz uint32) (err error) {
r1, _, e1 := syscall.Syscall6(procSetupDiSetDeviceRegistryPropertyW.Addr(), 5, uintptr(devInfoSet), uintptr(unsafe.Pointer(data)), uintptr(prop), uintptr(unsafe.Pointer(buf)), uintptr(sz), 0)
if r1 == 0 {
err = errnoErr(e1)
}
return
}