summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2022-05-10 14:51:41 +0200
committerDavid Lönnhager <david.l@mullvad.net>2022-05-18 16:13:28 +0200
commit73626ba077230f7a29da3a91fcf69edca94a60b7 (patch)
tree388d989e57beaa68b72e4842528a5e0b8b000085
parentddb40d6479ad88a58ea3856e24e6038286dc7382 (diff)
downloadmullvadvpn-73626ba077230f7a29da3a91fcf69edca94a60b7.tar.xz
mullvadvpn-73626ba077230f7a29da3a91fcf69edca94a60b7.zip
Remove temporary binaries used during setup
-rw-r--r--dist-assets/windows/installer.nsh41
-rw-r--r--windows/nsis-plugins/src/log/log.cpp9
2 files changed, 50 insertions, 0 deletions
diff --git a/dist-assets/windows/installer.nsh b/dist-assets/windows/installer.nsh
index b04fadfb2d..cb4ea8a417 100644
--- a/dist-assets/windows/installer.nsh
+++ b/dist-assets/windows/installer.nsh
@@ -54,6 +54,42 @@
!define PERSISTENT_BLOCK_OUTBOUND_IPV4_FILTER_GUID "{79860c64-9a5e-48a3-b5f3-d64b41659aa5}"
#
+# CleanupTempFiles
+#
+# Clean up files used temporarily by the installer.
+#
+!macro CleanupTempFiles
+
+ Push $0
+
+ log::SetLogTarget ${LOG_VOID}
+
+ # Horrendous hack for unpinning log.dll. Since we do not know the reference count
+ # it is safest to unload it from here.
+ CleanupTempFiles_free_logger:
+ System::Call "KERNEL32::GetModuleHandle(t $\"$PLUGINSDIR\log.dll$\")p.r0"
+ ${If} $0 P<> 0
+ System::Call "KERNEL32::FreeLibrary(pr0)"
+ Goto CleanupTempFiles_free_logger
+ ${EndIf}
+
+ # The working directory cannot be deleted, so make sure it's set to $TEMP.
+ SetOutPath "$TEMP"
+
+ RMDir /r "$TEMP\mullvad-split-tunnel"
+ Delete "$TEMP\wintun.dll"
+ Delete "$TEMP\mullvad-wireguard.dll"
+ Delete "$TEMP\driverlogic.exe"
+ Delete "$TEMP\mullvad-setup.exe"
+ Delete "$TEMP\winfw.dll"
+
+ Pop $0
+
+!macroend
+
+!define CleanupTempFiles '!insertmacro "CleanupTempFiles"'
+
+#
# ExtractWireGuard
#
# Extract Wintun and WireGuardNT installer into $TEMP
@@ -902,6 +938,8 @@
customInstall_skip_abort:
+ ${CleanupTempFiles}
+
Pop $R0
!macroend
@@ -1161,6 +1199,7 @@
${EndIf}
log::Log "Aborting uninstaller"
+
SetErrorLevel 1
Abort
@@ -1196,6 +1235,8 @@
Delete "$LOCALAPPDATA\Mullvad VPN\uninstall.log"
${EndIf}
+ ${CleanupTempFiles}
+
Pop $R0
Pop $1
Pop $0
diff --git a/windows/nsis-plugins/src/log/log.cpp b/windows/nsis-plugins/src/log/log.cpp
index a491dc9b2d..6940240137 100644
--- a/windows/nsis-plugins/src/log/log.cpp
+++ b/windows/nsis-plugins/src/log/log.cpp
@@ -19,6 +19,8 @@ Logger *g_logger = nullptr;
namespace
{
+bool g_pinned = false;
+
std::wstring PopString()
{
//
@@ -45,6 +47,11 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
void PinDll()
{
+ if (g_pinned)
+ {
+ return;
+ }
+
//
// Apparently NSIS loads and unloads the plugin module for EVERY call it makes to the plugin.
// This makes it kind of difficult to maintain state.
@@ -68,6 +75,8 @@ void PinDll()
{
LoadLibraryW(self);
}
+
+ g_pinned = true;
}
std::vector<std::wstring> BlockToRows(const std::wstring &textBlock)