From da28a3e9f3abc3e117a777452ba887090fd0ad98 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Wed, 28 Aug 2019 08:39:26 -0600 Subject: [PATCH] wintun: give better errors when ndis interface listing fails --- tun/wintun/wintun_windows.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tun/wintun/wintun_windows.go b/tun/wintun/wintun_windows.go index bae1089..b558fd6 100644 --- a/tun/wintun/wintun_windows.go +++ b/tun/wintun/wintun_windows.go @@ -687,11 +687,11 @@ func (wintun *Wintun) deviceData() (setupapi.DevInfo, *setupapi.DevInfoData, err func (wintun *Wintun) AdapterHandle() (windows.Handle, error) { interfaces, err := setupapi.CM_Get_Device_Interface_List(wintun.devInstanceID, &deviceInterfaceNetGUID, setupapi.CM_GET_DEVICE_INTERFACE_LIST_PRESENT) if err != nil { - return windows.InvalidHandle, err + return windows.InvalidHandle, fmt.Errorf("Error listing NDIS interfaces: %v", err) } handle, err := windows.CreateFile(windows.StringToUTF16Ptr(interfaces[0]), windows.GENERIC_READ|windows.GENERIC_WRITE, windows.FILE_SHARE_READ|windows.FILE_SHARE_WRITE|windows.FILE_SHARE_DELETE, nil, windows.OPEN_EXISTING, 0, 0) if err != nil { - return windows.InvalidHandle, fmt.Errorf("Open NDIS device failed: %v", err) + return windows.InvalidHandle, fmt.Errorf("Error opening NDIS device: %v", err) } return handle, nil }