summaryrefslogtreecommitdiffhomepage
path: root/setupapi/setupapi_windows.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-01-31 15:20:11 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-05 12:59:42 +0100
commit31949136df477c5699d7476e909d9bf30a0904cc (patch)
treea50cabca0c42cc1b07ee5ae9bf5f5ba0d4341702 /setupapi/setupapi_windows.go
parent6f76edd045e20435689d9e1a3dd221b40b49adc6 (diff)
Introduce SetupAPI - Windows device and driver management API
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'setupapi/setupapi_windows.go')
-rw-r--r--setupapi/setupapi_windows.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/setupapi/setupapi_windows.go b/setupapi/setupapi_windows.go
new file mode 100644
index 0000000..22cacee
--- /dev/null
+++ b/setupapi/setupapi_windows.go
@@ -0,0 +1,41 @@
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2019 WireGuard LLC. All Rights Reserved.
+ */
+
+package setupapi
+
+import (
+ "golang.org/x/sys/windows"
+)
+
+const (
+ SP_MAX_MACHINENAME_LENGTH = windows.MAX_PATH + 3
+)
+
+type DIGCF uint32
+
+const (
+ Default DIGCF = 0x00000001
+ Present DIGCF = 0x00000002
+ AllClasses DIGCF = 0x00000004
+ Profile DIGCF = 0x00000008
+ DeviceInterface DIGCF = 0x00000010
+ InterfaceDevice DIGCF = 0x00000010
+)
+
+type DevInfo windows.Handle
+
+//sys setupDiGetClassDevsEx(ClassGuid *windows.GUID, Enumerator *string, hwndParent uintptr, Flags uint32, DeviceInfoSet uintptr, MachineName string, reserved uint32) (handle windows.Handle, err error) = setupapi.SetupDiGetClassDevsExW
+
+// The SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements for a local or a remote computer.
+func SetupDiGetClassDevsEx(ClassGuid *windows.GUID, Enumerator string, hwndParent uintptr, Flags DIGCF, DeviceInfoSet DevInfo, MachineName string) (DevInfo, error) {
+ enumerator := &Enumerator
+
+ if Enumerator == "" {
+ enumerator = nil
+ }
+
+ h, err := setupDiGetClassDevsEx(ClassGuid, enumerator, hwndParent, uint32(Flags), uintptr(DeviceInfoSet), MachineName, 0)
+ return DevInfo(h), err
+}