summaryrefslogtreecommitdiffhomepage
path: root/windows/nsis-plugins/src/driverlogic/context.cpp
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2020-01-21 13:26:05 +0100
committerDavid Lönnhager <david.l@mullvad.net>2020-01-31 16:24:48 +0100
commit459d73b0dec7067387e6fffc55a3c0242ec1a6b2 (patch)
tree326d256f5c95c5d34820348531ed67d133ec46d8 /windows/nsis-plugins/src/driverlogic/context.cpp
parentb029983278f35d342307693b77e0a7d66e3e5c06 (diff)
downloadmullvadvpn-459d73b0dec7067387e6fffc55a3c0242ec1a6b2.tar.xz
mullvadvpn-459d73b0dec7067387e6fffc55a3c0242ec1a6b2.zip
Delete old-ID Mullvad TAP on updates
Diffstat (limited to 'windows/nsis-plugins/src/driverlogic/context.cpp')
-rw-r--r--windows/nsis-plugins/src/driverlogic/context.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/windows/nsis-plugins/src/driverlogic/context.cpp b/windows/nsis-plugins/src/driverlogic/context.cpp
index 4df6a94b85..1718182768 100644
--- a/windows/nsis-plugins/src/driverlogic/context.cpp
+++ b/windows/nsis-plugins/src/driverlogic/context.cpp
@@ -28,6 +28,7 @@ namespace
{
const wchar_t TAP_HARDWARE_ID[] = L"tapmullvad0901";
+const wchar_t DEPRECATED_TAP_HARDWARE_ID[] = L"tap0901";
template<typename T>
void LogAdapters(const std::wstring &description, const T &adapters)
@@ -245,7 +246,7 @@ std::optional<std::wstring> GetDeviceRegistryStringProperty(
return { buffer.data() };
}
-std::set<Context::NetworkAdapter> GetTapAdapters()
+std::set<Context::NetworkAdapter> GetTapAdapters(const std::wstring &tapHardwareId)
{
std::set<Context::NetworkAdapter> adapters;
@@ -293,7 +294,7 @@ std::set<Context::NetworkAdapter> GetTapAdapters()
const auto hardwareId = GetDeviceRegistryStringProperty(devInfo, &devInfoData, SPDRP_HARDWAREID);
if (!hardwareId.has_value()
- || wcscmp(hardwareId.value().c_str(), TAP_HARDWARE_ID) != 0)
+ || wcscmp(hardwareId.value().c_str(), tapHardwareId.c_str()) != 0)
{
continue;
}
@@ -387,7 +388,7 @@ std::optional<Context::NetworkAdapter> Context::FindMullvadAdapter(const std::se
Context::BaselineStatus Context::establishBaseline()
{
- m_baseline = GetTapAdapters();
+ m_baseline = GetTapAdapters(TAP_HARDWARE_ID);
if (m_baseline.empty())
{
@@ -404,7 +405,7 @@ Context::BaselineStatus Context::establishBaseline()
void Context::recordCurrentState()
{
- m_currentState = GetTapAdapters();
+ m_currentState = GetTapAdapters(TAP_HARDWARE_ID);
}
void Context::rollbackTapAliases()
@@ -453,9 +454,9 @@ Context::NetworkAdapter Context::getNewAdapter()
}
//static
-Context::DeletionResult Context::DeleteMullvadAdapter()
+Context::DeletionResult Context::DeleteOldMullvadAdapter()
{
- auto tapAdapters = GetTapAdapters();
+ auto tapAdapters = GetTapAdapters(DEPRECATED_TAP_HARDWARE_ID);
std::optional<NetworkAdapter> mullvadAdapter = FindMullvadAdapter(tapAdapters);
if (!mullvadAdapter.has_value())
@@ -505,7 +506,7 @@ Context::DeletionResult Context::DeleteMullvadAdapter()
const auto hardwareId = GetDeviceRegistryStringProperty(devInfo, &devInfoData, SPDRP_HARDWAREID);
if (hardwareId.has_value()
- && wcscmp(TAP_HARDWARE_ID, hardwareId.value().data()) == 0)
+ && wcscmp(DEPRECATED_TAP_HARDWARE_ID, hardwareId.value().data()) == 0)
{
if (0 != GetNetCfgInstanceId(devInfo, devInfoData).compare(mullvadGuid))
{