From 66b1debc1e3b3ffec3bdba3751e90eaaebdfb87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 19 Dec 2024 15:39:06 +0100 Subject: [PATCH 1/2] Replace winapi with windows-sys in most cases in exception handler --- mullvad-daemon/src/exception_logging/win.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mullvad-daemon/src/exception_logging/win.rs b/mullvad-daemon/src/exception_logging/win.rs index 94f78018d7b7..157b01167161 100644 --- a/mullvad-daemon/src/exception_logging/win.rs +++ b/mullvad-daemon/src/exception_logging/win.rs @@ -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 \ From b4ba15bbb3a993d5f8345311c07ef002de6607d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Thu, 19 Dec 2024 13:17:17 +0100 Subject: [PATCH 2/2] Remove get_context_info for 32 bit x86 targets --- mullvad-daemon/src/exception_logging/win.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mullvad-daemon/src/exception_logging/win.rs b/mullvad-daemon/src/exception_logging/win.rs index 157b01167161..0a890a7e747f 100644 --- a/mullvad-daemon/src/exception_logging/win.rs +++ b/mullvad-daemon/src/exception_logging/win.rs @@ -262,7 +262,7 @@ fn get_context_info(context: &CONTEXT) -> String { context_str } -#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[cfg(target_arch = "x86_64")] fn get_context_info(context: &CONTEXT) -> String { use windows_sys::Win32::System::Diagnostics::Debug::{ CONTEXT_CONTROL_AMD64, CONTEXT_INTEGER_AMD64, CONTEXT_SEGMENTS_AMD64,