diff options
author | Simon Rozman <simon@rozman.si> | 2019-01-31 15:20:11 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-02-05 12:59:42 +0100 |
commit | 31949136df477c5699d7476e909d9bf30a0904cc (patch) | |
tree | a50cabca0c42cc1b07ee5ae9bf5f5ba0d4341702 /setupapi/zsetupapi_windows.go | |
parent | 6f76edd045e20435689d9e1a3dd221b40b49adc6 (diff) |
Introduce SetupAPI - Windows device and driver management API
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'setupapi/zsetupapi_windows.go')
-rw-r--r-- | setupapi/zsetupapi_windows.go | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/setupapi/zsetupapi_windows.go b/setupapi/zsetupapi_windows.go new file mode 100644 index 0000000..84ead2d --- /dev/null +++ b/setupapi/zsetupapi_windows.go @@ -0,0 +1,65 @@ +// 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) +) + +// errnoErr returns common boxed Errno values, to prevent +// allocations at runtime. +func errnoErr(e syscall.Errno) error { + switch e { + case 0: + return nil + 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") + + procSetupDiGetClassDevsExW = modsetupapi.NewProc("SetupDiGetClassDevsExW") +) + +func setupDiGetClassDevsEx(ClassGuid *windows.GUID, Enumerator *string, hwndParent uintptr, Flags uint32, DeviceInfoSet uintptr, MachineName string, reserved uint32) (handle windows.Handle, err error) { + var _p0 *uint16 + _p0, err = syscall.UTF16PtrFromString(MachineName) + if err != nil { + return + } + return _setupDiGetClassDevsEx(ClassGuid, Enumerator, hwndParent, Flags, DeviceInfoSet, _p0, reserved) +} + +func _setupDiGetClassDevsEx(ClassGuid *windows.GUID, Enumerator *string, hwndParent uintptr, Flags uint32, DeviceInfoSet uintptr, MachineName *uint16, reserved uint32) (handle windows.Handle, err error) { + r0, _, e1 := syscall.Syscall9(procSetupDiGetClassDevsExW.Addr(), 7, uintptr(unsafe.Pointer(ClassGuid)), uintptr(unsafe.Pointer(Enumerator)), uintptr(hwndParent), uintptr(Flags), uintptr(DeviceInfoSet), uintptr(unsafe.Pointer(MachineName)), uintptr(reserved), 0, 0) + handle = windows.Handle(r0) + if handle == 0 { + if e1 != 0 { + err = errnoErr(e1) + } else { + err = syscall.EINVAL + } + } + return +} |