Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove winapi #77

Merged
merged 6 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "MIT"
[dependencies]
byteorder = "1.3.2"
cfg-if = "1.0"
crash-context = "0.5"
crash-context = "0.6"
memoffset = "0.8"
minidump-common = "0.15"
scroll = "0.11"
Expand All @@ -31,16 +31,13 @@ nix = { version = "0.26", default-features = false, features = [
"user",
] }

[target.'cfg(target_os = "windows")'.dependencies]
bitflags = "2.0"

[target.'cfg(target_os = "macos")'.dependencies]
# Binds some additional mac specifics not in libc
mach2 = "0.4"

# Additional bindings to Windows specific APIs. Note we don't use windows-sys
# due to massive version churn
[target.'cfg(target_os = "windows")'.dependencies.winapi]
version = "0.3"
features = ["handleapi", "minwindef", "processthreadsapi", "winnt"]

[dev-dependencies]
# Minidump-processor is async so we need an executor
futures = { version = "0.3", features = ["executor"] }
Expand Down
19 changes: 11 additions & 8 deletions src/bin/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,25 @@ mod linux {

#[cfg(target_os = "windows")]
mod windows {
use minidump_writer::ffi::{
GetCurrentProcessId, GetCurrentThread, GetCurrentThreadId, GetThreadContext,
EXCEPTION_POINTERS, EXCEPTION_RECORD,
};

use super::*;
use std::mem;

#[link(name = "kernel32")]
extern "system" {
pub fn GetCurrentProcessId() -> u32;
pub fn GetCurrentThreadId() -> u32;
pub fn GetCurrentThread() -> isize;
pub fn GetThreadContext(thread: isize, context: *mut crash_context::CONTEXT) -> i32;
}

#[inline(never)]
pub(super) fn real_main(args: Vec<String>) -> Result<()> {
let exception_code = u32::from_str_radix(&args[0], 16).unwrap();

// Generate the exception and communicate back where the exception pointers
// are
unsafe {
let mut exception_record: EXCEPTION_RECORD = mem::zeroed();
let mut exception_record: crash_context::EXCEPTION_RECORD = mem::zeroed();
let mut exception_context = std::mem::MaybeUninit::uninit();

let pid = GetCurrentProcessId();
Expand All @@ -320,12 +323,12 @@ mod windows {

let mut exception_context = exception_context.assume_init();

let exception_ptrs = EXCEPTION_POINTERS {
let exception_ptrs = crash_context::EXCEPTION_POINTERS {
ExceptionRecord: &mut exception_record,
ContextRecord: &mut exception_context,
};

exception_record.ExceptionCode = exception_code;
exception_record.ExceptionCode = exception_code as _;

let exc_ptr_addr = &exception_ptrs as *const _ as usize;

Expand Down
4 changes: 3 additions & 1 deletion src/windows.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod errors;
pub mod ffi;
mod ffi;
pub mod minidump_writer;

pub use ffi::MinidumpType;
Loading