diff options
| author | David Lönnhager <david.l@mullvad.net> | 2020-08-13 13:35:05 +0200 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2020-08-13 13:35:05 +0200 |
| commit | 6c4cfea7fd373579e604804eca66d3645a5421f2 (patch) | |
| tree | 83267bb409434adb3f913b1da4ccfe1801720b2f | |
| parent | fb8db653c9154dcd4a8b7dc9325c33b2da724cf5 (diff) | |
| parent | 14b0a39e02ded2e9e8e5a51a4f49cb943d32a8b9 (diff) | |
| download | mullvadvpn-6c4cfea7fd373579e604804eca66d3645a5421f2.tar.xz mullvadvpn-6c4cfea7fd373579e604804eca66d3645a5421f2.zip | |
Merge branch 'migrate-win-migration'
27 files changed, 217 insertions, 975 deletions
diff --git a/Cargo.lock b/Cargo.lock index 2897fa5ecb..dc75be1503 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1386,6 +1386,7 @@ dependencies = [ "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)", "ctrlc 3.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "duct 0.13.2 (registry+https://github.com/rust-lang/crates.io-index)", "err-derive 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "fern 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)", @@ -200,7 +200,6 @@ if [[ "$BUILD_MODE" == "release" && "$(uname -s)" == "MINGW"* ]]; then windows/winfw/bin/x64-Release/winfw.dll windows/windns/bin/x64-Release/windns.dll windows/winnet/bin/x64-Release/winnet.dll - windows/winutil/bin/x64-Release/winutil.dll windows/driverlogic/bin/x64-Release/driverlogic.exe windows/nsis-plugins/bin/Win32-Release/*.dll build/lib/x86_64-pc-windows-msvc/libwg.dll diff --git a/build_windows_modules.sh b/build_windows_modules.sh index 7d429daf26..221ee662fb 100755 --- a/build_windows_modules.sh +++ b/build_windows_modules.sh @@ -164,17 +164,14 @@ function main local winfw_root_path=${CPP_ROOT_PATH:-"./windows/winfw"} local windns_root_path=${CPP_ROOT_PATH:-"./windows/windns"} local winnet_root_path=${CPP_ROOT_PATH:-"./windows/winnet"} - local winutil_root_path=${CPP_ROOT_PATH:-"./windows/winutil"} build_solution "$winfw_root_path" "winfw.sln" build_solution "$windns_root_path" "windns.sln" build_solution "$winnet_root_path" "winnet.sln" - build_solution "$winutil_root_path" "winutil.sln" copy_outputs $winfw_root_path "winfw.dll" copy_outputs $windns_root_path "windns.dll" copy_outputs $winnet_root_path "winnet.dll" - copy_outputs $winutil_root_path "winutil.dll" local driverlogic_root_path=${CPP_ROOT_PATH:-"./windows/driverlogic"} build_solution "$driverlogic_root_path" "driverlogic.sln" diff --git a/gui/tasks/distribution.js b/gui/tasks/distribution.js index 814488e83f..99c812c615 100644 --- a/gui/tasks/distribution.js +++ b/gui/tasks/distribution.js @@ -92,7 +92,6 @@ const config = { { from: root('windows/winfw/bin/x64-Release/winfw.dll'), to: '.' }, { from: root('windows/windns/bin/x64-Release/windns.dll'), to: '.' }, { from: root('windows/winnet/bin/x64-Release/winnet.dll'), to: '.' }, - { from: root('windows/winutil/bin/x64-Release/winutil.dll'), to: '.' }, { from: distAssets('binaries/x86_64-pc-windows-msvc/openvpn.exe'), to: '.' }, { from: distAssets('binaries/x86_64-pc-windows-msvc/sslocal.exe'), to: '.' }, { from: root('build/lib/x86_64-pc-windows-msvc/libwg.dll'), to: '.' }, diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index 0ebffd12ea..a33f808ec2 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -56,6 +56,7 @@ ctrlc = "3.0" duct = "0.13" windows-service = "0.3" winapi = { version = "0.3", features = ["errhandlingapi", "handleapi", "libloaderapi", "ntlsa", "synchapi", "tlhelp32", "winbase", "winerror", "winuser"] } +dirs = "2.0" [target.'cfg(windows)'.build-dependencies] winres = "0.1" diff --git a/mullvad-daemon/build.rs b/mullvad-daemon/build.rs index f11b2fd9da..c2571ca799 100644 --- a/mullvad-daemon/build.rs +++ b/mullvad-daemon/build.rs @@ -1,51 +1,5 @@ use std::{env, fs, path::PathBuf, process::Command}; -#[cfg(windows)] -mod win { - use std::{env, path::PathBuf}; - - pub static WINUTIL_BUILD_DIR: &'static str = "..\\windows\\winutil\\bin"; - - pub fn default_windows_build_artifact_dir(build_dir: &str) -> PathBuf { - manifest_dir().join(build_dir).join(&target_platform_dir()) - } - - fn target_platform_dir() -> PathBuf { - let target = env::var("TARGET").expect("TARGET env var not set"); - - let target_dir = match target.as_str() { - "i686-pc-windows-msvc" => format!("Win32-{}", get_build_mode()), - "x86_64-pc-windows-msvc" => format!("x64-{}", get_build_mode()), - _ => panic!("uncrecognized target: {}", target), - }; - target_dir.into() - } - - fn get_build_mode() -> &'static str { - let profile = env::var("PROFILE").expect("PROFILE env var not set"); - if profile == "release" { - "Release" - } else { - "Debug" - } - } - - pub fn declare_library(env_var: &str, default_dir: &str, lib_name: &str) { - println!("cargo:rerun-if-env-changed={}", env_var); - let lib_dir = env::var_os(env_var) - .map(PathBuf::from) - .unwrap_or_else(|| default_windows_build_artifact_dir(default_dir)); - println!("cargo:rustc-link-search={}", lib_dir.display()); - println!("cargo:rustc-link-lib=dylib={}", lib_name); - } - - fn manifest_dir() -> PathBuf { - env::var("CARGO_MANIFEST_DIR") - .map(PathBuf::from) - .expect("CARGO_MANIFEST_DIR env var not set") - } -} - fn main() { let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap()); @@ -73,14 +27,6 @@ fn main() { } res.compile().expect("Unable to generate windows resources"); } - - #[cfg(windows)] - { - use crate::win::*; - - const WINUTIL_DIR_VAR: &str = "WINUTIL_LIB_DIR"; - declare_library(WINUTIL_DIR_VAR, WINUTIL_BUILD_DIR, "winutil"); - } } fn commit_date() -> String { diff --git a/mullvad-daemon/src/settings.rs b/mullvad-daemon/src/settings.rs index 0b25a14157..c343d7c336 100644 --- a/mullvad-daemon/src/settings.rs +++ b/mullvad-daemon/src/settings.rs @@ -11,11 +11,8 @@ use std::{ }; use talpid_types::ErrorExt; -#[cfg(windows)] -use talpid_core::logging::windows::log_sink; - -static SETTINGS_FILE: &str = "settings.json"; +const SETTINGS_FILE: &str = "settings.json"; #[derive(err_derive::Error, Debug)] @@ -43,8 +40,8 @@ enum LoadSettingsError { ParseError(#[error(source)] mullvad_types::settings::Error), #[cfg(windows)] - #[error(display = "Failed to restore Windows Update backup: {}", _0)] - WinMigrationError(ffi::WinUtilMigrationStatus), + #[error(display = "Failed to restore Windows update backup")] + WinMigrationError(#[error(source)] windows::Error), } @@ -81,21 +78,38 @@ impl SettingsPersister { } fn load_settings(path: &Path) -> (Settings, bool) { - Self::load_settings_from_file(path) - .or_else(|error| match error { - #[cfg(windows)] - LoadSettingsError::FileNotFound => { - Self::try_load_settings_after_windows_update(path) - } - _ => Err(error), - }) - .unwrap_or_else(|error| { - info!( - "{}", - error.display_chain_with_msg("Failed to load settings. Using defaults.") - ); - (Settings::default(), true) - }) + let error = match Self::load_settings_from_file(path) { + Ok(value) => return value, + Err(error) => error, + }; + + #[cfg(windows)] + let error = if let LoadSettingsError::FileNotFound = error { + info!( + "No settings file found. Attempting migration from Windows update backup location" + ); + match windows::migrate_after_windows_update() { + Ok(Some(())) => match Self::load_settings_from_file(path) { + Ok(value) => return value, + Err(error) => error, + }, + Ok(None) => LoadSettingsError::FileNotFound, + Err(error) => LoadSettingsError::WinMigrationError(error), + } + } else { + error + }; + + if let LoadSettingsError::FileNotFound = error { + info!("No settings were found. Using defaults."); + } else { + info!( + "{}", + error.display_chain_with_msg("Failed to load settings. Using defaults.") + ); + } + + (Settings::default(), true) } fn load_settings_from_file(path: &Path) -> Result<(Settings, bool), LoadSettingsError> { @@ -117,24 +131,6 @@ impl SettingsPersister { .map_err(LoadSettingsError::ParseError) } - #[cfg(windows)] - fn try_load_settings_after_windows_update( - path: &Path, - ) -> Result<(Settings, bool), LoadSettingsError> { - info!("No settings file found. Attempting migration from Windows Update backup location"); - - Self::migrate_after_windows_update()?; - Self::load_settings_from_file(path) - } - - #[cfg(windows)] - fn migrate_after_windows_update() -> Result<(), LoadSettingsError> { - unsafe { - ffi::WinUtil_MigrateAfterWindowsUpdate(Some(log_sink), b"Settings migrator\0".as_ptr()) - .into() - } - } - /// Serializes the settings and saves them to the file it was loaded from. fn save(&mut self) -> Result<(), Error> { debug!("Writing settings to {}", self.path.display()); @@ -274,51 +270,196 @@ impl Deref for SettingsPersister { #[cfg(windows)] -mod ffi { - use std::fmt; - use talpid_core::logging::windows::LogSink; +mod windows { + use std::{ffi::OsStr, fs, io, os::windows::ffi::OsStrExt, path::Path, ptr}; + use talpid_types::ErrorExt; + use winapi::{ + shared::{minwindef::TRUE, winerror::ERROR_SUCCESS}, + um::{ + accctrl::{SE_FILE_OBJECT, SE_OBJECT_TYPE}, + aclapi::GetNamedSecurityInfoW, + securitybaseapi::IsWellKnownSid, + winbase::LocalFree, + winnt::{ + WinBuiltinAdministratorsSid, WinLocalSystemSid, OWNER_SECURITY_INFORMATION, PSID, + SECURITY_DESCRIPTOR, SECURITY_INFORMATION, SID, WELL_KNOWN_SID_TYPE, + }, + }, + }; + + const MIGRATION_DIRNAME: &str = "windows.old"; + const MIGRATE_FILES: [(&str, bool); 2] = + [("settings.json", true), ("account-history.json", false)]; + + #[derive(err_derive::Error, Debug)] + #[error(no_from)] + pub enum Error { + #[error(display = "Unable to find settings directory")] + FindSettings(#[error(source)] mullvad_paths::Error), - #[derive(Debug)] - #[allow(dead_code)] - #[repr(u32)] - pub enum WinUtilMigrationStatus { - Success = 0, - Aborted = 1, - NothingToMigrate = 2, - Failed = 3, + #[error(display = "Unable to find local appdata directory")] + FindAppData, + + #[error(display = "Could not acquire security descriptor of backup directory")] + SecurityInformation(#[error(source)] io::Error), + + #[error(display = "Backup directory is not owned by SYSTEM or Built-in Administrators")] + WrongOwner, + + #[error(display = "Failed to copy files during migration")] + IoError(#[error(source)] io::Error), } - impl fmt::Display for WinUtilMigrationStatus { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - use WinUtilMigrationStatus::*; - write!( - f, - "{}", - match self { - Success => "Migration completed successfully", - Aborted => "Migration was aborted to avoid overwriting current settings", - NothingToMigrate => "Could not migrate settings - no backup present", - Failed => "Migration failed", + /// Attempts to restore the Mullvad settings from `C:\windows.old` after an update of Windows. + /// Upon success, it returns `Ok(Some(()))` if the migration succeeded, and `Ok(None)` if no + /// migration was needed. + pub fn migrate_after_windows_update() -> Result<Option<()>, Error> { + let destination_settings_dir = + mullvad_paths::settings_dir().map_err(Error::FindSettings)?; + + let system_appdata_dir = dirs::data_local_dir().ok_or(Error::FindAppData)?; + if !destination_settings_dir.starts_with(system_appdata_dir) { + return Ok(None); + } + + let settings_path = destination_settings_dir.join(super::SETTINGS_FILE); + if settings_path.exists() { + return Ok(None); + } + + let mut components = destination_settings_dir.components(); + let prefix = if let Some(prefix) = components.next() { + prefix + } else { + return Ok(None); + }; + let root = if let Some(root) = components.next() { + root + } else { + return Ok(None); + }; + + let windows_old_dir = Path::new(&prefix).join(&root).join(MIGRATION_DIRNAME); + let source_settings_dir = Path::new(&windows_old_dir).join(&components); + if !source_settings_dir.exists() { + return Ok(None); + } + + let security_info = + SecurityInformation::from_file(windows_old_dir.as_path(), OWNER_SECURITY_INFORMATION) + .map_err(Error::SecurityInformation)?; + + let owner_sid = security_info.owner().ok_or(Error::WrongOwner)?; + + if !is_well_known_sid(owner_sid, WinLocalSystemSid) + && !is_well_known_sid(owner_sid, WinBuiltinAdministratorsSid) + { + return Err(Error::WrongOwner); + } + + if !destination_settings_dir.exists() { + fs::create_dir_all(&destination_settings_dir).map_err(Error::IoError)?; + } + + let mut result = Ok(Some(())); + + for (file, required) in &MIGRATE_FILES { + let from = source_settings_dir.join(file); + let to = destination_settings_dir.join(file); + + log::debug!("Migrating {} to {}", from.display(), to.display()); + + match fs::copy(&from, &to) { + Ok(_) => { + let _ = fs::remove_file(from); } - ) + Err(error) => { + log::error!( + "{}", + error.display_chain_with_msg(&format!( + "Failed to copy {} to {}", + from.display(), + to.display() + )) + ); + if *required { + result = Err(Error::IoError(error)); + } + } + } + } + + if let Err(error) = fs::remove_dir(source_settings_dir) { + log::trace!( + "{}", + error.display_chain_with_msg("Failed to delete backup directory") + ); } + + result + } + + struct SecurityInformation { + security_descriptor: *mut SECURITY_DESCRIPTOR, + owner: PSID, } - impl Into<Result<(), super::LoadSettingsError>> for WinUtilMigrationStatus { - fn into(self) -> Result<(), super::LoadSettingsError> { - match self { - WinUtilMigrationStatus::Success => Ok(()), - val => Err(super::LoadSettingsError::WinMigrationError(val)), + impl SecurityInformation { + pub fn from_file<T: AsRef<OsStr>>( + path: T, + security_information: SECURITY_INFORMATION, + ) -> Result<Self, io::Error> { + Self::from_object(path, SE_FILE_OBJECT, security_information) + } + + pub fn from_object<T: AsRef<OsStr>>( + object_name: T, + object_type: SE_OBJECT_TYPE, + security_information: SECURITY_INFORMATION, + ) -> Result<Self, io::Error> { + let mut u16_path: Vec<u16> = object_name.as_ref().encode_wide().collect(); + u16_path.push(0u16); + + let mut security_descriptor = ptr::null_mut(); + let mut owner = ptr::null_mut(); + + let status = unsafe { + GetNamedSecurityInfoW( + u16_path.as_ptr(), + object_type, + security_information, + &mut owner, + ptr::null_mut(), + ptr::null_mut(), + ptr::null_mut(), + &mut security_descriptor, + ) + }; + + if status != ERROR_SUCCESS { + return Err(std::io::Error::from_raw_os_error(status as i32)); } + + Ok(SecurityInformation { + security_descriptor: security_descriptor as *mut _, + owner, + }) + } + + pub fn owner(&self) -> Option<&SID> { + unsafe { (self.owner as *const SID).as_ref() } + } + + // TODO: Can be expanded with `group()`, `dacl()`, and `sacl()`. + } + + impl Drop for SecurityInformation { + fn drop(&mut self) { + unsafe { LocalFree(self.security_descriptor as *mut _) }; } } - #[allow(non_snake_case)] - extern "system" { - #[link_name = "WinUtil_MigrateAfterWindowsUpdate"] - pub fn WinUtil_MigrateAfterWindowsUpdate( - sink: Option<LogSink>, - sink_context: *const u8, - ) -> WinUtilMigrationStatus; + fn is_well_known_sid(sid: &SID, well_known_sid_type: WELL_KNOWN_SID_TYPE) -> bool { + unsafe { IsWellKnownSid(sid as *const SID as *mut _, well_known_sid_type) == TRUE } } } diff --git a/windows/winutil/extras.sln b/windows/winutil/extras.sln deleted file mode 100644 index 02e5b42d6b..0000000000 --- a/windows/winutil/extras.sln +++ /dev/null @@ -1,73 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29324.140 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "migration", "src\extras\migration\migration.vcxproj", "{5DDDC994-A1C4-4B5C-8909-B576E490E40E}" - ProjectSection(ProjectDependencies) = postProject - {C075F50C-1A62-46D1-9494-02C8F48A9419} = {C075F50C-1A62-46D1-9494-02C8F48A9419} - {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF} - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} = {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winutil", "src\winutil\winutil.vcxproj", "{C075F50C-1A62-46D1-9494-02C8F48A9419}" - ProjectSection(ProjectDependencies) = postProject - {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF} - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} = {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} - EndProjectSection -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}") = "libshared", "..\libshared\src\libshared\libshared.vcxproj", "{EE69EA4A-CF71-4B88-866B-957F60C4CE0D}" - ProjectSection(ProjectDependencies) = postProject - {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5DDDC994-A1C4-4B5C-8909-B576E490E40E}.Debug|x64.ActiveCfg = Debug|x64 - {5DDDC994-A1C4-4B5C-8909-B576E490E40E}.Debug|x64.Build.0 = Debug|x64 - {5DDDC994-A1C4-4B5C-8909-B576E490E40E}.Debug|x86.ActiveCfg = Debug|Win32 - {5DDDC994-A1C4-4B5C-8909-B576E490E40E}.Debug|x86.Build.0 = Debug|Win32 - {5DDDC994-A1C4-4B5C-8909-B576E490E40E}.Release|x64.ActiveCfg = Release|x64 - {5DDDC994-A1C4-4B5C-8909-B576E490E40E}.Release|x64.Build.0 = Release|x64 - {5DDDC994-A1C4-4B5C-8909-B576E490E40E}.Release|x86.ActiveCfg = Release|Win32 - {5DDDC994-A1C4-4B5C-8909-B576E490E40E}.Release|x86.Build.0 = Release|Win32 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Debug|x64.ActiveCfg = Debug|x64 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Debug|x64.Build.0 = Debug|x64 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Debug|x86.ActiveCfg = Debug|Win32 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Debug|x86.Build.0 = Debug|Win32 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Release|x64.ActiveCfg = Release|x64 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Release|x64.Build.0 = Release|x64 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Release|x86.ActiveCfg = Release|Win32 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Release|x86.Build.0 = Release|Win32 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x64.ActiveCfg = Debug|x64 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x64.Build.0 = Debug|x64 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.ActiveCfg = Debug|Win32 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.Build.0 = Debug|Win32 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x64.ActiveCfg = Release|x64 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x64.Build.0 = Release|x64 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.ActiveCfg = Release|Win32 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.Build.0 = Release|Win32 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x64.ActiveCfg = Debug|x64 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x64.Build.0 = Debug|x64 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x86.ActiveCfg = Debug|Win32 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x86.Build.0 = Debug|Win32 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x64.ActiveCfg = Release|x64 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x64.Build.0 = Release|x64 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x86.ActiveCfg = Release|Win32 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {815EF55F-6262-47E1-A2F9-B37DDC3FC926} - EndGlobalSection -EndGlobal diff --git a/windows/winutil/src/extras/migration/migration.cpp b/windows/winutil/src/extras/migration/migration.cpp deleted file mode 100644 index e5fdf3f5ef..0000000000 --- a/windows/winutil/src/extras/migration/migration.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "stdafx.h" -#include <iostream> -#include <libshared/logging/stdoutlogger.h> -#include <winutil/winutil.h> - -int main() -{ - const auto status = WinUtil_MigrateAfterWindowsUpdate(shared::logging::StdoutLogger, nullptr); - - switch (status) - { - case WINUTIL_MIGRATION_STATUS_SUCCESS: - { - std::wcout << L"Success" << std::endl; - break; - } - case WINUTIL_MIGRATION_STATUS_ABORTED: - { - std::wcout << L"Aborted" << std::endl; - break; - } - case WINUTIL_MIGRATION_STATUS_NOTHING_TO_MIGRATE: - { - std::wcout << L"Nothing to migrate" << std::endl; - break; - } - case WINUTIL_MIGRATION_STATUS_FAILED: - { - std::wcout << L"Failed" << std::endl; - break; - } - } - - return 0; -} diff --git a/windows/winutil/src/extras/migration/migration.vcxproj b/windows/winutil/src/extras/migration/migration.vcxproj deleted file mode 100644 index a030827149..0000000000 --- a/windows/winutil/src/extras/migration/migration.vcxproj +++ /dev/null @@ -1,193 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="16.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> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <VCProjectVersion>16.0</VCProjectVersion> - <ProjectGuid>{5DDDC994-A1C4-4B5C-8909-B576E490E40E}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>migration</RootNamespace> - <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> - </PropertyGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>Application</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</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> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <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|x64'"> - <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)'=='Debug|x64'"> - <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> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <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>Level4</WarningLevel> - <Optimization>Disabled</Optimization> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <LanguageStandard>stdcpplatest</LanguageStandard> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <AdditionalIncludeDirectories>$(ProjectDir)../../../../winutil/src/;$(ProjectDir)../../../../libshared/src</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>libshared.lib;winutil.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> - <AdditionalLibraryDirectories>$(SolutionDir)\bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level4</WarningLevel> - <Optimization>Disabled</Optimization> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <LanguageStandard>stdcpplatest</LanguageStandard> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <AdditionalIncludeDirectories>$(ProjectDir)../../../../winutil/src/;$(ProjectDir)../../../../libshared/src</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>libshared.lib;winutil.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> - <AdditionalLibraryDirectories>$(SolutionDir)\bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level4</WarningLevel> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <LanguageStandard>stdcpplatest</LanguageStandard> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <AdditionalIncludeDirectories>$(ProjectDir)../../../../winutil/src/;$(ProjectDir)../../../../libshared/src</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>libshared.lib;winutil.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> - <AdditionalLibraryDirectories>$(SolutionDir)\bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level4</WarningLevel> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <LanguageStandard>stdcpplatest</LanguageStandard> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <AdditionalIncludeDirectories>$(ProjectDir)../../../../winutil/src/;$(ProjectDir)../../../../libshared/src</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Console</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalDependencies>libshared.lib;winutil.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> - <AdditionalLibraryDirectories>$(SolutionDir)\bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> - </Link> - </ItemDefinitionGroup> - <ItemGroup> - <ClInclude Include="stdafx.h" /> - <ClInclude Include="targetver.h" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="migration.cpp" /> - <ClCompile Include="stdafx.cpp"> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> - </ClCompile> - </ItemGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/windows/winutil/src/extras/migration/migration.vcxproj.filters b/windows/winutil/src/extras/migration/migration.vcxproj.filters deleted file mode 100644 index 9aadc39b15..0000000000 --- a/windows/winutil/src/extras/migration/migration.vcxproj.filters +++ /dev/null @@ -1,11 +0,0 @@ -<?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="migration.cpp" /> - <ClCompile Include="stdafx.cpp" /> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/windows/winutil/src/extras/migration/stdafx.cpp b/windows/winutil/src/extras/migration/stdafx.cpp Binary files differdeleted file mode 100644 index 326c6605d8..0000000000 --- a/windows/winutil/src/extras/migration/stdafx.cpp +++ /dev/null diff --git a/windows/winutil/src/extras/migration/stdafx.h b/windows/winutil/src/extras/migration/stdafx.h Binary files differdeleted file mode 100644 index 94d4ed877d..0000000000 --- a/windows/winutil/src/extras/migration/stdafx.h +++ /dev/null diff --git a/windows/winutil/src/extras/migration/targetver.h b/windows/winutil/src/extras/migration/targetver.h Binary files differdeleted file mode 100644 index 567cd346ef..0000000000 --- a/windows/winutil/src/extras/migration/targetver.h +++ /dev/null diff --git a/windows/winutil/src/winutil/dllmain.cpp b/windows/winutil/src/winutil/dllmain.cpp deleted file mode 100644 index f11c65c519..0000000000 --- a/windows/winutil/src/winutil/dllmain.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "stdafx.h" -#include <windows.h> - -BOOL APIENTRY DllMain(HMODULE, DWORD, LPVOID) -{ - // - // Avoid doing work in DllMain since the loader lock is held - // - - return TRUE; -} diff --git a/windows/winutil/src/winutil/migration.cpp b/windows/winutil/src/winutil/migration.cpp deleted file mode 100644 index a5feb6a8b4..0000000000 --- a/windows/winutil/src/winutil/migration.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include "stdafx.h" -#include "migration.h" -#include <libcommon/filesystem.h> -#include <libcommon/error.h> -#include <filesystem> - -namespace migration { - -// -// This is being called in a x64 SYSTEM user context -// -MigrationStatus MigrateAfterWindowsUpdate() -{ - const auto localAppData = common::fs::GetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_DEFAULT, nullptr); - const auto mullvadAppData = std::filesystem::path(localAppData).append(L"Mullvad VPN"); - - // - // The main settings file is 'settings.json' - // If this file is present inside 'mullvadAppData' we should abort the migration - // - - const auto settingsFile = std::filesystem::path(mullvadAppData).append(L"settings.json"); - - if (std::filesystem::exists(settingsFile)) - { - return MigrationStatus::Aborted; - } - - // - // Validate backup location path and ownership - // - - const auto backupRoot = mullvadAppData.root_path().append(L"windows.old"); - const auto backupMullvadAppData = backupRoot / mullvadAppData.relative_path(); - - if (false == std::filesystem::exists(backupMullvadAppData)) - { - return MigrationStatus::NothingToMigrate; - } - - DWORD bufferSize = 128; - std::vector<uint8_t> buffer(bufferSize); - - for (;;) - { - if (FALSE == GetFileSecurityW(backupRoot.c_str(), OWNER_SECURITY_INFORMATION, - &buffer[0], static_cast<DWORD>(buffer.size()), &bufferSize)) - { - if (ERROR_INSUFFICIENT_BUFFER == GetLastError()) - { - buffer.resize(bufferSize); - continue; - } - - THROW_ERROR("Could not acquire security descriptor of backup directory"); - } - - break; - } - - SID *sid = nullptr; - BOOL ownerDefaulted = FALSE; - - if (FALSE == GetSecurityDescriptorOwner(reinterpret_cast<SECURITY_DESCRIPTOR *>(&buffer[0]), - reinterpret_cast<PSID *>(&sid), &ownerDefaulted)) - { - THROW_ERROR("Could not determine owner of backup directory"); - } - - if (FALSE == IsWellKnownSid(sid, WinLocalSystemSid) - && FALSE == IsWellKnownSid(sid, WinBuiltinAdministratorsSid)) - { - THROW_ERROR("Backup directory is not owned by SYSTEM or Built-in Administrators"); - } - - // - // Ensure destination directory exists - // - - if (false == std::filesystem::exists(mullvadAppData) - && false == std::filesystem::create_directory(mullvadAppData)) - { - THROW_ERROR("Could not create destination directory during migration"); - } - - // - // Specify files that need to be copied over - // - - struct FileMigration - { - std::wstring filename; - bool required; - }; - - const FileMigration filesToMigrate[] = { - { L"settings.json", true }, - { L"account-history.json", false }, - }; - - // - // Copy and delete files - // - - bool copyStatus = true; - - for (const auto file : filesToMigrate) - { - const auto from = std::filesystem::path(backupMullvadAppData).append(file.filename); - const auto to = std::filesystem::path(mullvadAppData).append(file.filename); - - std::error_code error; - - if (std::filesystem::copy_file(from, to, std::filesystem::copy_options::overwrite_existing | std::filesystem::copy_options::skip_symlinks, error)) - { - std::filesystem::remove(from, error); - } - else if (file.required) - { - copyStatus = false; - } - } - - if (false == copyStatus) - { - THROW_ERROR("Failed to copy files during migration"); - } - - return MigrationStatus::Success; -} - -} diff --git a/windows/winutil/src/winutil/migration.h b/windows/winutil/src/winutil/migration.h deleted file mode 100644 index 3b9848c70a..0000000000 --- a/windows/winutil/src/winutil/migration.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -namespace migration { - -enum class MigrationStatus -{ - Success = 0, - - // Destination already exists - Aborted, - - // There's no backup - NothingToMigrate, -}; - -MigrationStatus MigrateAfterWindowsUpdate(); - -} diff --git a/windows/winutil/src/winutil/stdafx.cpp b/windows/winutil/src/winutil/stdafx.cpp Binary files differdeleted file mode 100644 index 4ab693824c..0000000000 --- a/windows/winutil/src/winutil/stdafx.cpp +++ /dev/null diff --git a/windows/winutil/src/winutil/stdafx.h b/windows/winutil/src/winutil/stdafx.h Binary files differdeleted file mode 100644 index b937b12ccd..0000000000 --- a/windows/winutil/src/winutil/stdafx.h +++ /dev/null diff --git a/windows/winutil/src/winutil/targetver.h b/windows/winutil/src/winutil/targetver.h deleted file mode 100644 index ae4a5c032c..0000000000 --- a/windows/winutil/src/winutil/targetver.h +++ /dev/null @@ -1,12 +0,0 @@ -#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/winutil/src/winutil/winutil.cpp b/windows/winutil/src/winutil/winutil.cpp deleted file mode 100644 index b5b809a216..0000000000 --- a/windows/winutil/src/winutil/winutil.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "stdafx.h" -#include "winutil.h" -#include "migration.h" -#include <libshared/logging/unwind.h> -#include <libcommon/valuemapper.h> -#include <stdexcept> - -extern "C" -WINUTIL_LINKAGE -WINUTIL_MIGRATION_STATUS -WINUTIL_API -WinUtil_MigrateAfterWindowsUpdate( - MullvadLogSink logSink, - void *logSinkContext -) -{ - try - { - return common::ValueMapper::Map(migration::MigrateAfterWindowsUpdate(), { - std::make_pair(migration::MigrationStatus::Success, WINUTIL_MIGRATION_STATUS_SUCCESS), - std::make_pair(migration::MigrationStatus::Aborted, WINUTIL_MIGRATION_STATUS_ABORTED), - std::make_pair(migration::MigrationStatus::NothingToMigrate, WINUTIL_MIGRATION_STATUS_NOTHING_TO_MIGRATE), - }); - } - catch (const std::exception &err) - { - shared::logging::UnwindAndLog(logSink, logSinkContext, err); - return WINUTIL_MIGRATION_STATUS_FAILED; - } - catch (...) - { - return WINUTIL_MIGRATION_STATUS_FAILED; - } -} diff --git a/windows/winutil/src/winutil/winutil.def b/windows/winutil/src/winutil/winutil.def deleted file mode 100644 index 9868cafe16..0000000000 --- a/windows/winutil/src/winutil/winutil.def +++ /dev/null @@ -1,3 +0,0 @@ -LIBRARY winutil -EXPORTS - WinUtil_MigrateAfterWindowsUpdate diff --git a/windows/winutil/src/winutil/winutil.h b/windows/winutil/src/winutil/winutil.h deleted file mode 100644 index c29a57a079..0000000000 --- a/windows/winutil/src/winutil/winutil.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include <libshared/logging/logsink.h> -#include <stdint.h> - -#ifdef WINUTIL_EXPORTS -#define WINUTIL_LINKAGE __declspec(dllexport) -#else -#define WINUTIL_LINKAGE __declspec(dllimport) -#endif - -#define WINUTIL_API __stdcall - -enum WINUTIL_MIGRATION_STATUS -{ - WINUTIL_MIGRATION_STATUS_SUCCESS = 0, - - // Destination already exists - WINUTIL_MIGRATION_STATUS_ABORTED, - - // There's no backup - WINUTIL_MIGRATION_STATUS_NOTHING_TO_MIGRATE, - - WINUTIL_MIGRATION_STATUS_FAILED, -}; - -extern "C" -WINUTIL_LINKAGE -WINUTIL_MIGRATION_STATUS -WINUTIL_API -WinUtil_MigrateAfterWindowsUpdate( - MullvadLogSink logSink, - void *logSinkContext -); diff --git a/windows/winutil/src/winutil/winutil.rc b/windows/winutil/src/winutil/winutil.rc Binary files differdeleted file mode 100644 index b711893278..0000000000 --- a/windows/winutil/src/winutil/winutil.rc +++ /dev/null diff --git a/windows/winutil/src/winutil/winutil.vcxproj b/windows/winutil/src/winutil/winutil.vcxproj deleted file mode 100644 index 3113553ce3..0000000000 --- a/windows/winutil/src/winutil/winutil.vcxproj +++ /dev/null @@ -1,207 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="16.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> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <ItemGroup> - <ClCompile Include="dllmain.cpp" /> - <ClCompile Include="migration.cpp" /> - <ClCompile Include="stdafx.cpp"> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> - </ClCompile> - <ClCompile Include="winutil.cpp" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="migration.h" /> - <ClInclude Include="stdafx.h" /> - <ClInclude Include="targetver.h" /> - <ClInclude Include="winutil.h" /> - </ItemGroup> - <ItemGroup> - <None Include="winutil.def" /> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="winutil.rc" /> - </ItemGroup> - <PropertyGroup Label="Globals"> - <VCProjectVersion>16.0</VCProjectVersion> - <ProjectGuid>{C075F50C-1A62-46D1-9494-02C8F48A9419}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>winutil</RootNamespace> - <WindowsTargetPlatformVersion>10.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>v142</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <WholeProgramOptimization>true</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>true</UseDebugLibraries> - <PlatformToolset>v142</PlatformToolset> - <CharacterSet>Unicode</CharacterSet> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>DynamicLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <PlatformToolset>v142</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> - <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <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|x64'"> - <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)'=='Debug|x64'"> - <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> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <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>Level4</WarningLevel> - <Optimization>Disabled</Optimization> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>WIN32;_DEBUG;WINUTIL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <LanguageStandard>stdcpplatest</LanguageStandard> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <AdditionalIncludeDirectories>$(ProjectDir)../../../libshared/src/;$(ProjectDir)../../../windows-libraries/src/;$(ProjectDir)../../../</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> - <AdditionalDependencies>libshared.lib;libcommon.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> - <ModuleDefinitionFile>winutil.def</ModuleDefinitionFile> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level4</WarningLevel> - <Optimization>Disabled</Optimization> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>_DEBUG;WINUTIL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <LanguageStandard>stdcpplatest</LanguageStandard> - <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> - <AdditionalIncludeDirectories>$(ProjectDir)../../../libshared/src/;$(ProjectDir)../../../windows-libraries/src/;$(ProjectDir)../../../</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> - <AdditionalDependencies>libshared.lib;libcommon.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> - <ModuleDefinitionFile>winutil.def</ModuleDefinitionFile> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level4</WarningLevel> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>WIN32;NDEBUG;WINUTIL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <LanguageStandard>stdcpplatest</LanguageStandard> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <AdditionalIncludeDirectories>$(ProjectDir)../../../libshared/src/;$(ProjectDir)../../../windows-libraries/src/;$(ProjectDir)../../../</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> - <AdditionalDependencies>libshared.lib;libcommon.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> - <ModuleDefinitionFile>winutil.def</ModuleDefinitionFile> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <ClCompile> - <PrecompiledHeader>Use</PrecompiledHeader> - <WarningLevel>Level4</WarningLevel> - <Optimization>MaxSpeed</Optimization> - <FunctionLevelLinking>true</FunctionLevelLinking> - <IntrinsicFunctions>true</IntrinsicFunctions> - <SDLCheck>true</SDLCheck> - <PreprocessorDefinitions>NDEBUG;WINUTIL_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <ConformanceMode>true</ConformanceMode> - <LanguageStandard>stdcpplatest</LanguageStandard> - <RuntimeLibrary>MultiThreaded</RuntimeLibrary> - <AdditionalIncludeDirectories>$(ProjectDir)../../../libshared/src/;$(ProjectDir)../../../windows-libraries/src/;$(ProjectDir)../../../</AdditionalIncludeDirectories> - </ClCompile> - <Link> - <SubSystem>Windows</SubSystem> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - <GenerateDebugInformation>true</GenerateDebugInformation> - <AdditionalLibraryDirectories>$(SolutionDir)bin\$(Platform)-$(Configuration)\</AdditionalLibraryDirectories> - <AdditionalDependencies>libshared.lib;libcommon.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> - <ModuleDefinitionFile>winutil.def</ModuleDefinitionFile> - </Link> - </ItemDefinitionGroup> - <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> - <ImportGroup Label="ExtensionTargets"> - </ImportGroup> -</Project>
\ No newline at end of file diff --git a/windows/winutil/src/winutil/winutil.vcxproj.filters b/windows/winutil/src/winutil/winutil.vcxproj.filters deleted file mode 100644 index 52c8d08716..0000000000 --- a/windows/winutil/src/winutil/winutil.vcxproj.filters +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup> - <ClCompile Include="dllmain.cpp" /> - <ClCompile Include="stdafx.cpp" /> - <ClCompile Include="winutil.cpp" /> - <ClCompile Include="migration.cpp" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="stdafx.h" /> - <ClInclude Include="targetver.h" /> - <ClInclude Include="winutil.h" /> - <ClInclude Include="migration.h" /> - </ItemGroup> - <ItemGroup> - <None Include="winutil.def" /> - </ItemGroup> - <ItemGroup> - <ResourceCompile Include="winutil.rc" /> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/windows/winutil/winutil.sln b/windows/winutil/winutil.sln deleted file mode 100644 index 79dc0dc851..0000000000 --- a/windows/winutil/winutil.sln +++ /dev/null @@ -1,58 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29324.140 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "winutil", "src\winutil\winutil.vcxproj", "{C075F50C-1A62-46D1-9494-02C8F48A9419}" - ProjectSection(ProjectDependencies) = postProject - {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF} - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} = {EE69EA4A-CF71-4B88-866B-957F60C4CE0D} - EndProjectSection -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}") = "libshared", "..\libshared\src\libshared\libshared.vcxproj", "{EE69EA4A-CF71-4B88-866B-957F60C4CE0D}" - ProjectSection(ProjectDependencies) = postProject - {B52E2D10-A94A-4605-914A-2DCEF6A757EF} = {B52E2D10-A94A-4605-914A-2DCEF6A757EF} - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Debug|x64.ActiveCfg = Debug|x64 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Debug|x64.Build.0 = Debug|x64 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Debug|x86.ActiveCfg = Debug|Win32 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Debug|x86.Build.0 = Debug|Win32 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Release|x64.ActiveCfg = Release|x64 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Release|x64.Build.0 = Release|x64 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Release|x86.ActiveCfg = Release|Win32 - {C075F50C-1A62-46D1-9494-02C8F48A9419}.Release|x86.Build.0 = Release|Win32 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x64.ActiveCfg = Debug|x64 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x64.Build.0 = Debug|x64 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.ActiveCfg = Debug|Win32 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Debug|x86.Build.0 = Debug|Win32 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x64.ActiveCfg = Release|x64 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x64.Build.0 = Release|x64 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.ActiveCfg = Release|Win32 - {B52E2D10-A94A-4605-914A-2DCEF6A757EF}.Release|x86.Build.0 = Release|Win32 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x64.ActiveCfg = Debug|x64 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x64.Build.0 = Debug|x64 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x86.ActiveCfg = Debug|Win32 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Debug|x86.Build.0 = Debug|Win32 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x64.ActiveCfg = Release|x64 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x64.Build.0 = Release|x64 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x86.ActiveCfg = Release|Win32 - {EE69EA4A-CF71-4B88-866B-957F60C4CE0D}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {09660916-FAAF-4850-B5E6-681EE5C72B18} - EndGlobalSection -EndGlobal |
