diff options
| author | David Lönnhager <david.l@mullvad.net> | 2019-10-11 12:44:33 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2019-10-18 13:38:58 +0200 |
| commit | fd13e2805f7d493d8600fa4f4a9ac87f58e06d3a (patch) | |
| tree | 5629a11f547e902735e0a13a82ae602d3a51059f /windows/nsis-plugins/src/driverlogic/driverlogic.cpp | |
| parent | 6d063dd619b6b9c609f0d1bc6343df43ba7b4e88 (diff) | |
| download | mullvadvpn-fd13e2805f7d493d8600fa4f4a9ac87f58e06d3a.tar.xz mullvadvpn-fd13e2805f7d493d8600fa4f4a9ac87f58e06d3a.zip | |
Remove only the TAP driver if it's not being used by other adapters on
Windows
Diffstat (limited to 'windows/nsis-plugins/src/driverlogic/driverlogic.cpp')
| -rw-r--r-- | windows/nsis-plugins/src/driverlogic/driverlogic.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/windows/nsis-plugins/src/driverlogic/driverlogic.cpp b/windows/nsis-plugins/src/driverlogic/driverlogic.cpp index 3bbe98bf8b..82259c015d 100644 --- a/windows/nsis-plugins/src/driverlogic/driverlogic.cpp +++ b/windows/nsis-plugins/src/driverlogic/driverlogic.cpp @@ -157,6 +157,68 @@ void __declspec(dllexport) NSISCALL EstablishBaseline } // +// RemoveMullvadTap +// +// Deletes the Mullvad TAP adapter. +// +// +enum class RemoveMullvadTapStatus +{ + GENERAL_ERROR = 0, + SUCCESS_NO_REMAINING_TAP_ADAPTERS, + SUCCESS_SOME_REMAINING_TAP_ADAPTERS +}; + +void __declspec(dllexport) NSISCALL RemoveMullvadTap +( + HWND hwndParent, + int string_size, + LPTSTR variables, + stack_t **stacktop, + extra_parameters *extra, + ... +) +{ + EXDLL_INIT(); + + try + { + pushstring(L""); + + switch (Context::DeleteMullvadAdapter()) + { + case Context::DeletionResult::NO_REMAINING_TAP_ADAPTERS: + { + pushint(RemoveMullvadTapStatus::SUCCESS_NO_REMAINING_TAP_ADAPTERS); + break; + } + + case Context::DeletionResult::SOME_REMAINING_TAP_ADAPTERS: + { + pushint(RemoveMullvadTapStatus::SUCCESS_SOME_REMAINING_TAP_ADAPTERS); + break; + } + + default: + { + throw std::runtime_error("Unexpected case"); + } + } + } + catch (std::exception &err) + { + pushstring(common::string::ToWide(err.what()).c_str()); + pushint(RemoveMullvadTapStatus::GENERAL_ERROR); + } + catch (...) + { + pushstring(L"Unspecified error"); + pushint(RemoveMullvadTapStatus::GENERAL_ERROR); + } +} + + +// // IdentifyNewAdapter // // Call this function after installing a TAP adapter. |
