diff options
| author | Odd Stranne <odd@mullvad.net> | 2018-11-02 11:22:26 +0100 |
|---|---|---|
| committer | Odd Stranne <odd@mullvad.net> | 2018-11-02 11:22:26 +0100 |
| commit | 96fc79fea56372a42553b31b6d423083e3fc8d75 (patch) | |
| tree | a7282305a1d1f65b2bb46162c2a30bb9e9bf03e0 | |
| parent | 9955852694d3d2340f065c6ebe287468bc2a1a0b (diff) | |
| parent | 20050d41f4d8c3827e7c050b46ae52f38fcdf2d5 (diff) | |
| download | mullvadvpn-96fc79fea56372a42553b31b6d423083e3fc8d75.tar.xz mullvadvpn-96fc79fea56372a42553b31b6d423083e3fc8d75.zip | |
Merge branch 'update-app-id'
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | dist-assets/windows/installer.nsh | 31 | ||||
| -rwxr-xr-x | gui/packages/desktop/electron-builder.yml | 1 | ||||
| -rw-r--r-- | windows/nsis-plugins/nsis-plugins.sln | 9 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/dllmain.cpp | 11 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/registry.cpp | 88 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/registry.def | 5 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/registry.vcxproj | 122 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/registry.vcxproj.filters | 15 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/stdafx.cpp | 8 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/stdafx.h | 16 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/registry/targetver.h | 12 | ||||
| m--------- | windows/windows-libraries | 0 |
13 files changed, 321 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index fd14dedbb0..5217cb8bfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,9 @@ Line wrap the file at 100 chars. Th VPN tunnel is established instead of only on computer boot. - Set DNS search domain when using the systemd-resolved. Makes it work on Ubuntu 18.10. +#### Windows +- Use proper app id in the registry. This avoids false-positives with certain anti-virus software. + ### Security #### Linux - Block all traffic to DNS servers other than the correct one in the tunnel. Stops potential DNS diff --git a/dist-assets/windows/installer.nsh b/dist-assets/windows/installer.nsh index 64b38528e0..1de27c2b14 100644 --- a/dist-assets/windows/installer.nsh +++ b/dist-assets/windows/installer.nsh @@ -305,6 +305,37 @@ !define RemoveSettings '!insertmacro "RemoveSettings"' # +# customInit +# +# This macro is activated right when the installer first starts up. +# +# When the installer is starting, take the opportunity to update registry +# keys to use the new app identifier. +# +# This enables subsequent logic in the installer to correctly identify +# that there is a previous version of the app installed. +# +!macro customInit + + Push $0 + + registry::MoveKey "HKLM\SOFTWARE\8fa2c331-e09e-5709-bc74-c59df61f0c7e" "HKLM\SOFTWARE\Mullvad VPN" + + # Discard return value + Pop $0 + Pop $0 + + registry::MoveKey "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\8fa2c331-e09e-5709-bc74-c59df61f0c7e" "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Mullvad VPN" + + # Discard return value + Pop $0 + Pop $0 + + Pop $0 + +!macroend + +# # customInstall # # This macro is activated towards the end of the installation diff --git a/gui/packages/desktop/electron-builder.yml b/gui/packages/desktop/electron-builder.yml index 3aae55b9aa..570be2a18c 100755 --- a/gui/packages/desktop/electron-builder.yml +++ b/gui/packages/desktop/electron-builder.yml @@ -59,6 +59,7 @@ pkg: isRelocatable: false nsis: + guid: "Mullvad VPN" oneClick: false perMachine: true allowElevation: true diff --git a/windows/nsis-plugins/nsis-plugins.sln b/windows/nsis-plugins/nsis-plugins.sln index e1c6eefd47..aa59d45e59 100644 --- a/windows/nsis-plugins/nsis-plugins.sln +++ b/windows/nsis-plugins/nsis-plugins.sln @@ -20,6 +20,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "log", "src\log\log.vcxproj" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcommon", "..\windows-libraries\src\libcommon\libcommon.vcxproj", "{B52E2D10-A94A-4605-914A-2DCEF6A757EF}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "registry", "src\registry\registry.vcxproj", "{756DEBA7-E499-43DF-B5AB-C8F98145D603}" + ProjectSection(ProjectDependencies) = postProject + {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x86 = Debug|x86 @@ -42,6 +47,10 @@ Global {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.Build.0 = Debug|Win32 {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.ActiveCfg = Release|Win32 {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.Build.0 = Release|Win32 + {756DEBA7-E499-43DF-B5AB-C8F98145D603}.Debug|x86.ActiveCfg = Debug|Win32 + {756DEBA7-E499-43DF-B5AB-C8F98145D603}.Debug|x86.Build.0 = Debug|Win32 + {756DEBA7-E499-43DF-B5AB-C8F98145D603}.Release|x86.ActiveCfg = Release|Win32 + {756DEBA7-E499-43DF-B5AB-C8F98145D603}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/windows/nsis-plugins/src/registry/dllmain.cpp b/windows/nsis-plugins/src/registry/dllmain.cpp new file mode 100644 index 0000000000..a5a44613dd --- /dev/null +++ b/windows/nsis-plugins/src/registry/dllmain.cpp @@ -0,0 +1,11 @@ +#include "stdafx.h" +#include <windows.h> + +BOOL APIENTRY DllMain(HMODULE, DWORD reason, LPVOID) +{ + // + // Avoid doing work in DllMain since the loader lock is held + // + + return TRUE; +} diff --git a/windows/nsis-plugins/src/registry/registry.cpp b/windows/nsis-plugins/src/registry/registry.cpp new file mode 100644 index 0000000000..e94c0540ee --- /dev/null +++ b/windows/nsis-plugins/src/registry/registry.cpp @@ -0,0 +1,88 @@ +#include "stdafx.h" +#include <windows.h> +#include <libcommon/string.h> +#include <libcommon/registry/registry.h> +#include <libcommon/registry/registrypath.h> +#include <nsis/pluginapi.h> +#include <string> +#include <stdexcept> + +namespace +{ + +std::wstring PopString() +{ + // + // NSIS functions popstring() and popstringn() require that you definitely size the buffer + // before popping the string. Let's do it ourselves instead. + // + + if (!g_stacktop || !*g_stacktop) + { + throw std::runtime_error("NSIS variable stack is corrupted"); + } + + stack_t *th = *g_stacktop; + + std::wstring copy(th->text); + + *g_stacktop = th->next; + GlobalFree((HGLOBAL)th); + + return copy; +} + +} // anonymous namespace + +// +// MoveKey "source" "destination" +// +// Moves a registry key. +// +// Example usage: +// +// MoveKey "HKLM\Software\A" "HKLM\Software\B" +// +enum class MoveKeyStatus +{ + GENERAL_ERROR = 0, + SUCCESS +}; + +void __declspec(dllexport) NSISCALL MoveKey +( + HWND hwndParent, + int string_size, + LPTSTR variables, + stack_t **stacktop, + extra_parameters *extra, + ... +) +{ + EXDLL_INIT(); + + try + { + const auto source = PopString(); + const auto destination = PopString(); + + auto typedSource = common::registry::RegistryPath(source); + auto typedDestination = common::registry::RegistryPath(destination); + + common::registry::Registry::MoveKey(typedSource.key(), typedSource.subkey(), typedDestination.key(), + typedDestination.subkey(), common::registry::RegistryView::Force64); + + pushstring(L""); + pushint(MoveKeyStatus::SUCCESS); + } + catch (std::exception &err) + { + pushstring(common::string::ToWide(err.what()).c_str()); + pushint(MoveKeyStatus::GENERAL_ERROR); + } + catch (...) + { + pushstring(L"Unspecified error"); + pushint(MoveKeyStatus::GENERAL_ERROR); + } +} diff --git a/windows/nsis-plugins/src/registry/registry.def b/windows/nsis-plugins/src/registry/registry.def new file mode 100644 index 0000000000..8c1aac5492 --- /dev/null +++ b/windows/nsis-plugins/src/registry/registry.def @@ -0,0 +1,5 @@ +LIBRARY registry + +EXPORTS + +MoveKey=?MoveKey@@YAXPAUHWND__@@HPA_WPAPAU_stack_t@@PAUextra_parameters@@ZZ diff --git a/windows/nsis-plugins/src/registry/registry.vcxproj b/windows/nsis-plugins/src/registry/registry.vcxproj new file mode 100644 index 0000000000..900881f9d9 --- /dev/null +++ b/windows/nsis-plugins/src/registry/registry.vcxproj @@ -0,0 +1,122 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <VCProjectVersion>15.0</VCProjectVersion> + <ProjectGuid>{756DEBA7-E499-43DF-B5AB-C8F98145D603}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>registry</RootNamespace> + <WindowsTargetPlatformVersion>10.0.16299.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <PlatformToolset>v141</PlatformToolset> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="Shared"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + <OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir> + <IntDir>$(SolutionDir)bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <OutDir>$(SolutionDir)bin\$(Platform)-$(Configuration)\</OutDir> + <IntDir>$(SolutionDir)bin\temp\$(Platform)-$(Configuration)\$(ProjectName)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader>Use</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;_DEBUG;REGISTRY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <AdditionalIncludeDirectories>$(ProjectDir)../../../../dist-assets/binaries/windows/;$(ProjectDir)../../../windows-libraries/src/</AdditionalIncludeDirectories> + <LanguageStandard>stdcpplatest</LanguageStandard> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> + <AdditionalLibraryDirectories>$(ProjectDir)../../../../dist-assets/binaries/windows/nsis/;$(SolutionDir)bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> + <AdditionalDependencies>libcommon.lib;pluginapi-x86-unicode.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <IgnoreSpecificDefaultLibraries>libc.lib</IgnoreSpecificDefaultLibraries> + <ModuleDefinitionFile>registry.def</ModuleDefinitionFile> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <PrecompiledHeader>Use</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <SDLCheck>true</SDLCheck> + <PreprocessorDefinitions>WIN32;NDEBUG;REGISTRY_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <ConformanceMode>true</ConformanceMode> + <AdditionalIncludeDirectories>$(ProjectDir)../../../../dist-assets/binaries/windows/;$(ProjectDir)../../../windows-libraries/src/</AdditionalIncludeDirectories> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <LanguageStandard>stdcpplatest</LanguageStandard> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> + <AdditionalLibraryDirectories>$(ProjectDir)../../../../dist-assets/binaries/windows/nsis/;$(SolutionDir)bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> + <AdditionalDependencies>libcommon.lib;pluginapi-x86-unicode.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> + <IgnoreSpecificDefaultLibraries>libc.lib</IgnoreSpecificDefaultLibraries> + <ModuleDefinitionFile>registry.def</ModuleDefinitionFile> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClInclude Include="stdafx.h" /> + <ClInclude Include="targetver.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="dllmain.cpp" /> + <ClCompile Include="registry.cpp" /> + <ClCompile Include="stdafx.cpp"> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> + </ClCompile> + </ItemGroup> + <ItemGroup> + <None Include="registry.def" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/windows/nsis-plugins/src/registry/registry.vcxproj.filters b/windows/nsis-plugins/src/registry/registry.vcxproj.filters new file mode 100644 index 0000000000..f62d1c7691 --- /dev/null +++ b/windows/nsis-plugins/src/registry/registry.vcxproj.filters @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <ClInclude Include="stdafx.h" /> + <ClInclude Include="targetver.h" /> + </ItemGroup> + <ItemGroup> + <ClCompile Include="dllmain.cpp" /> + <ClCompile Include="stdafx.cpp" /> + <ClCompile Include="registry.cpp" /> + </ItemGroup> + <ItemGroup> + <None Include="registry.def" /> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/windows/nsis-plugins/src/registry/stdafx.cpp b/windows/nsis-plugins/src/registry/stdafx.cpp new file mode 100644 index 0000000000..3b6341d106 --- /dev/null +++ b/windows/nsis-plugins/src/registry/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// driverlogic.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/windows/nsis-plugins/src/registry/stdafx.h b/windows/nsis-plugins/src/registry/stdafx.h new file mode 100644 index 0000000000..f3a07375c7 --- /dev/null +++ b/windows/nsis-plugins/src/registry/stdafx.h @@ -0,0 +1,16 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#include "targetver.h" + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include <windows.h> + + + +// TODO: reference additional headers your program requires here diff --git a/windows/nsis-plugins/src/registry/targetver.h b/windows/nsis-plugins/src/registry/targetver.h new file mode 100644 index 0000000000..ae4a5c032c --- /dev/null +++ b/windows/nsis-plugins/src/registry/targetver.h @@ -0,0 +1,12 @@ +#pragma once + +// Including SDKDDKVer.h defines the highest available Windows platform. + +// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and +// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. + +#include <WinSDKVer.h> + +#define _WIN32_WINNT _WIN32_WINNT_WIN7 + +#include <SDKDDKVer.h> diff --git a/windows/windows-libraries b/windows/windows-libraries -Subproject b94fe4069a09fd2509bc8bf9d0f40197bc7d667 +Subproject a1128567944fbb6472c953d39b35b2d700fe1c0 |
