Skip to content

Commit c16ac40

Browse files
kennykerrCraftSpider
authored andcommitted
port
1 parent dcd0aaa commit c16ac40

File tree

9 files changed

+118
-900
lines changed

9 files changed

+118
-900
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- run: cargo build
6464
- run: cargo test
6565
- run: cargo test --features "serialize-serde"
66-
- run: cargo test --features "verify-winapi"
66+
- run: cargo test --features "verify-windows-sys"
6767
- run: cargo test --features "cpp_demangle"
6868
- run: cargo test --no-default-features
6969
- run: cargo test --no-default-features --features "std"
@@ -144,7 +144,7 @@ jobs:
144144
shell: bash
145145
- run: rustup target add aarch64-pc-windows-msvc
146146
- run: cargo test --no-run --target aarch64-pc-windows-msvc
147-
- run: cargo test --no-run --target aarch64-pc-windows-msvc --features verify-winapi
147+
- run: cargo test --no-run --target aarch64-pc-windows-msvc --features verify-windows-sys
148148

149149
ios:
150150
name: iOS

Cargo.toml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,18 @@ version = "0.36.0"
4949
default-features = false
5050
features = ['read_core', 'elf', 'macho', 'pe', 'xcoff', 'unaligned', 'archive']
5151

52-
[target.'cfg(windows)'.dependencies]
53-
winapi = { version = "0.3.9", optional = true }
52+
[target.'cfg(windows)'.dependencies.windows-sys]
53+
version = "0.42.0"
54+
features = [
55+
"Win32_Foundation",
56+
"Win32_Security",
57+
"Win32_System_Diagnostics_Debug",
58+
"Win32_System_Kernel",
59+
"Win32_System_LibraryLoader",
60+
"Win32_System_SystemInformation",
61+
"Win32_System_Threading",
62+
"Win32_System_WindowsProgramming",
63+
]
5464

5565
[build-dependencies]
5666
# Only needed for Android, but cannot be target dependent
@@ -82,20 +92,7 @@ dladdr = []
8292
kernel32 = []
8393
libunwind = []
8494
unix-backtrace = []
85-
verify-winapi = [
86-
'winapi/dbghelp',
87-
'winapi/handleapi',
88-
'winapi/libloaderapi',
89-
'winapi/memoryapi',
90-
'winapi/minwindef',
91-
'winapi/processthreadsapi',
92-
'winapi/synchapi',
93-
'winapi/tlhelp32',
94-
'winapi/winbase',
95-
'winapi/winnt',
96-
'winapi/winnls',
97-
'winapi/stringapiset',
98-
]
95+
verify-windows-sys = []
9996

10097
[[example]]
10198
name = "backtrace"

src/backtrace/dbghelp32.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
1212
#![allow(bad_style)]
1313

14-
use super::super::{dbghelp, windows::*};
14+
use windows_sys::{
15+
Win32::Foundation::*, Win32::System::Diagnostics::Debug::*,
16+
Win32::System::SystemInformation::*, Win32::System::Threading::*,
17+
};
18+
19+
use super::super::dbghelp;
1520
use core::ffi::c_void;
1621
use core::mem;
1722

@@ -129,7 +134,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
129134
match (*dbghelp.dbghelp()).StackWalkEx() {
130135
Some(StackWalkEx) => {
131136
let mut inner: STACKFRAME_EX = mem::zeroed();
132-
inner.StackFrameSize = mem::size_of::<STACKFRAME_EX>() as DWORD;
137+
inner.StackFrameSize = mem::size_of::<STACKFRAME_EX>() as u32;
133138
let mut frame = super::Frame {
134139
inner: Frame {
135140
stack_frame: StackFrame::New(inner),
@@ -143,7 +148,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
143148
};
144149

145150
while StackWalkEx(
146-
image as DWORD,
151+
image as u32,
147152
process,
148153
thread,
149154
frame_ptr,
@@ -153,7 +158,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
153158
Some(get_module_base),
154159
None,
155160
0,
156-
) == TRUE
161+
) == 1
157162
{
158163
frame.inner.base_address = get_module_base(process_handle, frame.ip() as _) as _;
159164

@@ -176,7 +181,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
176181
};
177182

178183
while dbghelp.StackWalk64()(
179-
image as DWORD,
184+
image as _,
180185
process,
181186
thread,
182187
frame_ptr,
@@ -185,7 +190,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
185190
Some(function_table_access),
186191
Some(get_module_base),
187192
None,
188-
) == TRUE
193+
) == 1
189194
{
190195
frame.inner.base_address = get_module_base(process_handle, frame.ip() as _) as _;
191196

@@ -198,7 +203,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
198203
}
199204

200205
#[cfg(target_arch = "x86")]
201-
fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> WORD {
206+
fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> u16 {
202207
frame.addr_pc_mut().Offset = ctx.Eip as u64;
203208
frame.addr_pc_mut().Mode = AddrModeFlat;
204209
frame.addr_stack_mut().Offset = ctx.Esp as u64;
@@ -210,7 +215,7 @@ fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> WORD {
210215
}
211216

212217
#[cfg(target_arch = "arm")]
213-
fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> WORD {
218+
fn init_frame(frame: &mut Frame, ctx: &CONTEXT) -> u16 {
214219
frame.addr_pc_mut().Offset = ctx.Pc as u64;
215220
frame.addr_pc_mut().Mode = AddrModeFlat;
216221
frame.addr_stack_mut().Offset = ctx.Sp as u64;

0 commit comments

Comments
 (0)