summaryrefslogtreecommitdiffhomepage
path: root/windows/nsis-plugins/src/driverlogic/driverlogic.cpp
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2019-12-03 09:17:53 +0100
committerDavid Lönnhager <david.l@mullvad.net>2019-12-03 09:17:53 +0100
commitb0628860be5c03af241bbfc308887686ea561bed (patch)
tree13fec05db5a764709650c3ce4b2d92549692bd7d /windows/nsis-plugins/src/driverlogic/driverlogic.cpp
parentc030edc99b8fa03b1090d9a8060873d6fc7ed16c (diff)
parent6d9192f46d7c1c8d447ad39b7d10e768c79650c2 (diff)
downloadmullvadvpn-b0628860be5c03af241bbfc308887686ea561bed.tar.xz
mullvadvpn-b0628860be5c03af241bbfc308887686ea561bed.zip
Merge branch 'tap-update-fix'
Diffstat (limited to 'windows/nsis-plugins/src/driverlogic/driverlogic.cpp')
-rw-r--r--windows/nsis-plugins/src/driverlogic/driverlogic.cpp55
1 files changed, 54 insertions, 1 deletions
diff --git a/windows/nsis-plugins/src/driverlogic/driverlogic.cpp b/windows/nsis-plugins/src/driverlogic/driverlogic.cpp
index 82259c015d..1e1ecc0fc7 100644
--- a/windows/nsis-plugins/src/driverlogic/driverlogic.cpp
+++ b/windows/nsis-plugins/src/driverlogic/driverlogic.cpp
@@ -126,6 +126,7 @@ void __declspec(dllexport) NSISCALL EstablishBaseline
{
pushstring(L"Initialize() function was not called or was not successful");
pushint(EstablishBaselineStatus::GENERAL_ERROR);
+ return;
}
try
@@ -247,7 +248,8 @@ void __declspec(dllexport) NSISCALL IdentifyNewAdapter
if (nullptr == g_context)
{
pushstring(L"Initialize() function was not called or was not successful");
- pushint(EstablishBaselineStatus::GENERAL_ERROR);
+ pushint(IdentifyNewAdapterStatus::GENERAL_ERROR);
+ return;
}
try
@@ -272,6 +274,57 @@ 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(RollbackTapAliasesStatus::GENERAL_ERROR);
+ return;
+ }
+
+ 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.