From eeae8c3ec9785f1e6ee87396bc36213c57f57461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 19 Dec 2024 13:16:17 +0100 Subject: [PATCH] Replace winapi with windows-sys in exception handler --- Cargo.lock | 1 - mullvad-daemon/Cargo.toml | 1 - mullvad-daemon/src/exception_logging/win.rs | 22 ++++++++++++--------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3cae9294d5ef..a259cdf332e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2399,7 +2399,6 @@ dependencies = [ "thiserror", "tokio", "tokio-stream", - "winapi", "windows-service", "windows-sys 0.52.0", "winres", diff --git a/mullvad-daemon/Cargo.toml b/mullvad-daemon/Cargo.toml index d0986fa70f71..c02a1a2793ea 100644 --- a/mullvad-daemon/Cargo.toml +++ b/mullvad-daemon/Cargo.toml @@ -67,7 +67,6 @@ objc = { version = "0.2.7", features = ["exception", "verify_message"] } [target.'cfg(windows)'.dependencies] ctrlc = "3.0" windows-service = "0.6.0" -winapi = { version = "0.3", features = ["winnt", "excpt", "winerror"] } dirs = "5.0.1" talpid-windows = { path = "../talpid-windows" } diff --git a/mullvad-daemon/src/exception_logging/win.rs b/mullvad-daemon/src/exception_logging/win.rs index 94f78018d7b7..0670cc9daaee 100644 --- a/mullvad-daemon/src/exception_logging/win.rs +++ b/mullvad-daemon/src/exception_logging/win.rs @@ -11,7 +11,7 @@ use std::{ }; use talpid_types::ErrorExt; use talpid_windows::process::{ModuleEntry, ProcessSnapshot}; -use winapi::vc::excpt::EXCEPTION_EXECUTE_HANDLER; +use windows_sys::Win32::System::Diagnostics::Debug::EXCEPTION_EXECUTE_HANDLER; use windows_sys::Win32::{ Foundation::HANDLE, System::{ @@ -211,11 +211,13 @@ unsafe extern "system" fn logging_exception_filter(info_ptr: *const EXCEPTION_PO #[cfg(target_arch = "aarch64")] fn get_context_info(context: &CONTEXT) -> String { - use winapi::um::winnt::{CONTEXT_CONTROL, CONTEXT_FLOATING_POINT, CONTEXT_INTEGER}; + use windows_sys::Win32::System::Diagnostics::Debug::{ + CONTEXT_CONTROL_ARM64, CONTEXT_FLOATING_POINT_ARM64, CONTEXT_INTEGER_ARM64, + }; let mut context_str = "Context:\n".to_string(); - if context.ContextFlags & CONTEXT_CONTROL != 0 { + if context.ContextFlags & CONTEXT_CONTROL_ARM64 != 0 { writeln!( &mut context_str, "\n\tFp: {:#x?}\n \ @@ -232,7 +234,7 @@ fn get_context_info(context: &CONTEXT) -> String { .unwrap(); } - if context.ContextFlags & CONTEXT_INTEGER != 0 { + if context.ContextFlags & CONTEXT_INTEGER_ARM64 != 0 { context_str.push('\n'); for x in 0..=28 { writeln!(&mut context_str, "\tX{}: {:#x?}", x, unsafe { @@ -241,7 +243,7 @@ fn get_context_info(context: &CONTEXT) -> String { .unwrap(); } } - if context.ContextFlags & CONTEXT_FLOATING_POINT != 0 { + if context.ContextFlags & CONTEXT_FLOATING_POINT_ARM64 != 0 { writeln!( &mut context_str, "\n\tFpcr: {:#x?}\n \ @@ -262,11 +264,13 @@ fn get_context_info(context: &CONTEXT) -> String { #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] fn get_context_info(context: &CONTEXT) -> String { - use winapi::um::winnt::{CONTEXT_CONTROL, CONTEXT_INTEGER, CONTEXT_SEGMENTS}; + use windows_sys::Win32::System::Diagnostics::Debug::{ + CONTEXT_CONTROL_AMD64, CONTEXT_INTEGER_AMD64, CONTEXT_SEGMENTS_AMD64, + }; let mut context_str = "Context:\n".to_string(); - if context.ContextFlags & CONTEXT_CONTROL != 0 { + if context.ContextFlags & CONTEXT_CONTROL_AMD64 != 0 { writeln!( &mut context_str, "\n\tSegSs: {:#x?}\n \ @@ -279,7 +283,7 @@ fn get_context_info(context: &CONTEXT) -> String { .unwrap(); } - if context.ContextFlags & CONTEXT_INTEGER != 0 { + if context.ContextFlags & CONTEXT_INTEGER_AMD64 != 0 { writeln!( &mut context_str, "\n\tRax: {:#x?}\n \ @@ -316,7 +320,7 @@ fn get_context_info(context: &CONTEXT) -> String { .unwrap(); } - if context.ContextFlags & CONTEXT_SEGMENTS != 0 { + if context.ContextFlags & CONTEXT_SEGMENTS_AMD64 != 0 { writeln!( &mut context_str, "\n\tSegDs: {:#x?}\n \