diff options
author | Simon Rozman <simon@rozman.si> | 2019-03-08 09:42:34 +0100 |
---|---|---|
committer | Simon Rozman <simon@rozman.si> | 2019-03-08 10:03:57 +0100 |
commit | 30ab07e35486909fdae95e7ed01c7bf7635d4a8f (patch) | |
tree | a8b9bdb976a854049aed1a8de8d0ed26e6b047f9 /tun | |
parent | a6d5ef82f4d90f3e997aa2ed4bf61414d6c39ee6 (diff) |
wintun: Introduce SetupAPI enumerator and machineName consts
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'tun')
-rw-r--r-- | tun/wintun/wintun_windows.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go index 1c5c6c9..eb72447 100644 --- a/tun/wintun/wintun_windows.go +++ b/tun/wintun/wintun_windows.go @@ -27,6 +27,8 @@ type Wintun windows.GUID var deviceClassNetGUID = windows.GUID{Data1: 0x4d36e972, Data2: 0xe325, Data3: 0x11ce, Data4: [8]byte{0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18}} const hardwareID = "Wintun" +const enumerator = "" +const machineName = "" // // GetInterface finds interface ID by name. @@ -43,7 +45,7 @@ const hardwareID = "Wintun" // func GetInterface(ifname string, hwndParent uintptr) (*Wintun, error) { // Create a list of network devices. - devInfoList, err := setupapi.SetupDiGetClassDevsEx(&deviceClassNetGUID, "", hwndParent, setupapi.DIGCF_PRESENT, setupapi.DevInfo(0), "") + devInfoList, err := setupapi.SetupDiGetClassDevsEx(&deviceClassNetGUID, enumerator, hwndParent, setupapi.DIGCF_PRESENT, setupapi.DevInfo(0), machineName) if err != nil { return nil, err } @@ -136,13 +138,13 @@ func GetInterface(ifname string, hwndParent uintptr) (*Wintun, error) { // func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, error) { // Create an empty device info set for network adapter device class. - devInfoList, err := setupapi.SetupDiCreateDeviceInfoListEx(&deviceClassNetGUID, hwndParent, "") + devInfoList, err := setupapi.SetupDiCreateDeviceInfoListEx(&deviceClassNetGUID, hwndParent, machineName) if err != nil { return nil, false, err } // Get the device class name from GUID. - className, err := setupapi.SetupDiClassNameFromGuidEx(&deviceClassNetGUID, "") + className, err := setupapi.SetupDiClassNameFromGuidEx(&deviceClassNetGUID, machineName) if err != nil { return nil, false, err } @@ -349,8 +351,9 @@ func CreateInterface(description string, hwndParent uintptr) (*Wintun, bool, err // func (wintun *Wintun) DeleteInterface(hwndParent uintptr) (bool, bool, error) { ifid := (*windows.GUID)(wintun) + // Create a list of network devices. - devInfoList, err := setupapi.SetupDiGetClassDevsEx(&deviceClassNetGUID, "", hwndParent, setupapi.DIGCF_PRESENT, setupapi.DevInfo(0), "") + devInfoList, err := setupapi.SetupDiGetClassDevsEx(&deviceClassNetGUID, enumerator, hwndParent, setupapi.DIGCF_PRESENT, setupapi.DevInfo(0), machineName) if err != nil { return false, false, err } |