summaryrefslogtreecommitdiffhomepage
path: root/windows/nsis-plugins/src/driverlogic/driverlogic.cpp
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2019-11-28 09:49:49 +0100
committerDavid Lönnhager <david.l@mullvad.net>2019-12-03 09:17:30 +0100
commit472c70f2e737c1cc22b538af17b36315a48cdd62 (patch)
treec2ae516a51ee6ffd9fffab9539139b2c470ff674 /windows/nsis-plugins/src/driverlogic/driverlogic.cpp
parent8f9f08a676d196172c76de1a568416beeb4da3d0 (diff)
downloadmullvadvpn-472c70f2e737c1cc22b538af17b36315a48cdd62.tar.xz
mullvadvpn-472c70f2e737c1cc22b538af17b36315a48cdd62.zip
Roll back TAP aliases after TAP driver updates (Windows)
Diffstat (limited to 'windows/nsis-plugins/src/driverlogic/driverlogic.cpp')
-rw-r--r--windows/nsis-plugins/src/driverlogic/driverlogic.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/windows/nsis-plugins/src/driverlogic/driverlogic.cpp b/windows/nsis-plugins/src/driverlogic/driverlogic.cpp
index 82259c015d..c46649846d 100644
--- a/windows/nsis-plugins/src/driverlogic/driverlogic.cpp
+++ b/windows/nsis-plugins/src/driverlogic/driverlogic.cpp
@@ -272,6 +272,56 @@ void __declspec(dllexport) NSISCALL IdentifyNewAdapter
}
//
+// RollbackTapAliases
+//
+// Updating the TAP driver may replace GUIDs and aliases.
+// Use this to restore the aliases to their baseline state.
+//
+enum class RollbackTapAliasesStatus
+{
+ GENERAL_ERROR = 0,
+ SUCCESS
+};
+
+void __declspec(dllexport) NSISCALL RollbackTapAliases
+(
+ HWND hwndParent,
+ int string_size,
+ LPTSTR variables,
+ stack_t** stacktop,
+ extra_parameters* extra,
+ ...
+)
+{
+ EXDLL_INIT();
+
+ if (nullptr == g_context)
+ {
+ pushstring(L"Initialize() function was not called or was not successful");
+ pushint(EstablishBaselineStatus::GENERAL_ERROR);
+ }
+
+ try
+ {
+ g_context->recordCurrentState();
+ g_context->rollbackTapAliases();
+
+ pushstring(L"");
+ pushint(RollbackTapAliasesStatus::SUCCESS);
+ }
+ catch (std::exception & err)
+ {
+ pushstring(common::string::ToWide(err.what()).c_str());
+ pushint(RollbackTapAliasesStatus::GENERAL_ERROR);
+ }
+ catch (...)
+ {
+ pushstring(L"Unspecified error");
+ pushint(RollbackTapAliasesStatus::GENERAL_ERROR);
+ }
+}
+
+//
// Deinitialize
//
// Call this function once during shutdown.