Skip to content

Commit

Permalink
Merge branch 'remove-direct-winapi-dep'
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Dec 19, 2024
2 parents e73ab2e + b4ba15b commit 1e100f9
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions mullvad-daemon/src/exception_logging/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 {
Expand All @@ -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 \
Expand All @@ -260,13 +262,15 @@ 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 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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down

0 comments on commit 1e100f9

Please sign in to comment.