summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author Patrick Mackinlay <pmackinlay@hotmail.com>2023-04-25 14:45:43 +0700
committer Patrick Mackinlay <pmackinlay@hotmail.com>2023-04-25 14:46:24 +0700
commit5b567d4a37084065174316671fc33241b67f40bc (patch)
tree1046a80238165216076572df8c4599ff2785d0ca /src/osd
parent4bc6a8d0e65bc7004e113d6938b8012cc73a9600 (diff)
taptun: fix adapter detection on windows for newer versions of taptun driver
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/modules/netdev/taptun.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/osd/modules/netdev/taptun.cpp b/src/osd/modules/netdev/taptun.cpp
index a1b8d4d84ce..5196b6e7d2f 100644
--- a/src/osd/modules/netdev/taptun.cpp
+++ b/src/osd/modules/netdev/taptun.cpp
@@ -293,16 +293,21 @@ static std::vector<std::wstring> get_tap_adapters()
// check if the ComponentId value indicates a TAP-Windows adapter
if (RegQueryValueExW(unit_key, L"ComponentId", NULL, &data_type, LPBYTE(component_id), &component_id_len) == ERROR_SUCCESS
- && data_type == REG_SZ
- && safe_string(component_id, component_id_len) == L"" PRODUCT_TAP_WIN_COMPONENT_ID)
+ && data_type == REG_SZ)
{
- WCHAR net_cfg_instance_id[MAX_PATH];
- DWORD net_cfg_instance_id_len = sizeof(net_cfg_instance_id);
-
- // add the adapter to the result
- if (RegQueryValueExW(unit_key, L"NetCfgInstanceId", NULL, &data_type, LPBYTE(net_cfg_instance_id), &net_cfg_instance_id_len) == ERROR_SUCCESS
- && data_type == REG_SZ)
- result.push_back(safe_string(net_cfg_instance_id, net_cfg_instance_id_len));
+ std::wstring const value(safe_string(component_id, component_id_len));
+
+ // some older versions may not set the "root\" prefix
+ if (value == L"root\\" PRODUCT_TAP_WIN_COMPONENT_ID || value == L"" PRODUCT_TAP_WIN_COMPONENT_ID)
+ {
+ WCHAR net_cfg_instance_id[MAX_PATH];
+ DWORD net_cfg_instance_id_len = sizeof(net_cfg_instance_id);
+
+ // add the adapter to the result
+ if (RegQueryValueExW(unit_key, L"NetCfgInstanceId", NULL, &data_type, LPBYTE(net_cfg_instance_id), &net_cfg_instance_id_len) == ERROR_SUCCESS
+ && data_type == REG_SZ)
+ result.push_back(safe_string(net_cfg_instance_id, net_cfg_instance_id_len));
+ }
}
RegCloseKey(unit_key);