summaryrefslogtreecommitdiff
path: root/setupapi/setupapi_windows_test.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-02-01 13:00:44 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-02-05 12:59:42 +0100
commitdce5192d860888e6af3e7fa8a7e4b2c776274e69 (patch)
tree08c7889ba624b1738efc50de9a458dc21d6c0635 /setupapi/setupapi_windows_test.go
parent955d8dfe04fa87d265bb1ccb671db05a323eb86f (diff)
downloadwireguard-go-dce5192d860888e6af3e7fa8a7e4b2c776274e69.tar.gz
wireguard-go-dce5192d860888e6af3e7fa8a7e4b2c776274e69.zip
Add support for setupapi.SetupDiOpenDevRegKey()
Furthermore setupapi.DevInfoData has been obsoleted. SetupDiEnumDeviceInfo() fills existing SP_DEVINFO_DATA structure now. As other functions of SetupAPI use SP_DEVINFO_DATA, converting it to DevInfoData and back would hurt performance. Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'setupapi/setupapi_windows_test.go')
-rw-r--r--setupapi/setupapi_windows_test.go34
1 files changed, 30 insertions, 4 deletions
diff --git a/setupapi/setupapi_windows_test.go b/setupapi/setupapi_windows_test.go
index 8aa7221..25e712f 100644
--- a/setupapi/setupapi_windows_test.go
+++ b/setupapi/setupapi_windows_test.go
@@ -43,7 +43,7 @@ func TestSetupDiGetDeviceInfoListDetailLocal(t *testing.T) {
if err != nil {
t.Errorf("Error calling SetupDiGetClassDevsEx: %s", err.Error())
}
- defer SetupDiDestroyDeviceInfoList(devInfoList)
+ defer devInfoList.Close()
data, err := SetupDiGetDeviceInfoListDetail(devInfoList)
if err != nil {
@@ -68,7 +68,7 @@ func TestSetupDiGetDeviceInfoListDetailRemote(t *testing.T) {
if err != nil {
t.Errorf("Error calling SetupDiGetClassDevsEx: %s", err.Error())
}
- defer SetupDiDestroyDeviceInfoList(devInfoList)
+ defer devInfoList.Close()
data, err := SetupDiGetDeviceInfoListDetail(devInfoList)
if err != nil {
@@ -93,10 +93,11 @@ func TestSetupDiEnumDeviceInfo(t *testing.T) {
if err != nil {
t.Errorf("Error calling SetupDiGetClassDevsEx: %s", err.Error())
}
- defer SetupDiDestroyDeviceInfoList(devInfoList)
+ defer devInfoList.Close()
+ var data SP_DEVINFO_DATA
for i := 0; true; i++ {
- data, err := SetupDiEnumDeviceInfo(devInfoList, i)
+ err := SetupDiEnumDeviceInfo(devInfoList, i, &data)
if err != nil {
if errWin, ok := err.(syscall.Errno); ok && errWin == 259 /*ERROR_NO_MORE_ITEMS*/ {
break
@@ -109,3 +110,28 @@ func TestSetupDiEnumDeviceInfo(t *testing.T) {
}
}
}
+
+func TestSetupDiOpenDevRegKey(t *testing.T) {
+ devInfoList, err := SetupDiGetClassDevsEx(&deviceClassNetGUID, "", 0, DIGCF_PRESENT, DevInfo(0), "")
+ if err != nil {
+ t.Errorf("Error calling SetupDiGetClassDevsEx: %s", err.Error())
+ }
+ defer devInfoList.Close()
+
+ var data SP_DEVINFO_DATA
+ for i := 0; true; i++ {
+ err := SetupDiEnumDeviceInfo(devInfoList, i, &data)
+ if err != nil {
+ if errWin, ok := err.(syscall.Errno); ok && errWin == 259 /*ERROR_NO_MORE_ITEMS*/ {
+ break
+ }
+ continue
+ }
+
+ key, err := SetupDiOpenDevRegKey(devInfoList, &data, DICS_FLAG_GLOBAL, 0, DIREG_DRV, windows.KEY_READ)
+ if err != nil {
+ t.Errorf("Error calling SetupDiOpenDevRegKey: %s", err.Error())
+ }
+ defer key.Close()
+ }
+}