Skip to content

Commit b69f1c4

Browse files
committed
Fix errors
1 parent c16ac40 commit b69f1c4

File tree

5 files changed

+78
-31
lines changed

5 files changed

+78
-31
lines changed

Cargo.lock

Lines changed: 58 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ features = [
6060
"Win32_System_SystemInformation",
6161
"Win32_System_Threading",
6262
"Win32_System_WindowsProgramming",
63+
"Win32_Globalization",
6364
]
6465

6566
[build-dependencies]

src/backtrace/dbghelp64.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
99
#![allow(bad_style)]
1010

11-
use super::super::windows::*;
11+
use windows_sys::Win32::System::Diagnostics::Debug::*;
1212
use core::ffi::c_void;
1313

1414
#[derive(Clone, Copy)]
@@ -17,7 +17,7 @@ pub struct Frame {
1717
ip: *mut c_void,
1818
sp: *mut c_void,
1919
#[cfg(not(target_env = "gnu"))]
20-
inline_context: Option<DWORD>,
20+
inline_context: Option<u32>,
2121
}
2222

2323
// we're just sending around raw pointers and reading them, never interpreting
@@ -43,7 +43,7 @@ impl Frame {
4343
}
4444

4545
#[cfg(not(target_env = "gnu"))]
46-
pub fn inline_context(&self) -> Option<DWORD> {
46+
pub fn inline_context(&self) -> Option<u32> {
4747
self.inline_context
4848
}
4949
}
@@ -54,12 +54,12 @@ struct MyContext(CONTEXT);
5454
#[cfg(any(target_arch = "x86_64", target_arch = "arm64ec"))]
5555
impl MyContext {
5656
#[inline(always)]
57-
fn ip(&self) -> DWORD64 {
57+
fn ip(&self) -> u64 {
5858
self.0.Rip
5959
}
6060

6161
#[inline(always)]
62-
fn sp(&self) -> DWORD64 {
62+
fn sp(&self) -> u64 {
6363
self.0.Rsp
6464
}
6565
}
@@ -133,7 +133,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
133133
ip,
134134
fn_entry,
135135
&mut context.0,
136-
ptr::addr_of_mut!(handler_data).cast::<PVOID>(),
136+
ptr::addr_of_mut!(handler_data).cast::<*mut c_void>(),
137137
&mut establisher_frame,
138138
ptr::null_mut(),
139139
);

src/dbghelp.rs

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use alloc::vec::Vec;
2828
use windows_sys::{
2929
core::*, Win32::Foundation::*, Win32::System::Diagnostics::Debug::*,
3030
Win32::System::LibraryLoader::*, Win32::System::Threading::*,
31-
Win32::System::WindowsProgramming::*,
31+
Win32::System::WindowsProgramming::*, Win32::Globalization::*,
3232
};
3333

3434
use core::ffi::c_void;
@@ -151,7 +151,7 @@ dbghelp! {
151151
fn EnumerateLoadedModulesW64(
152152
hprocess: HANDLE,
153153
enumloadedmodulescallback: PENUMLOADED_MODULES_CALLBACKW64,
154-
usercontext: PVOID
154+
usercontext: *const c_void
155155
) -> BOOL;
156156
fn StackWalk64(
157157
MachineType: u32,
@@ -224,18 +224,6 @@ dbghelp! {
224224
CurContext: *mut u32,
225225
CurFrameIndex: *mut u32
226226
) -> BOOL;
227-
fn SymFromAddrW(
228-
hProcess: HANDLE,
229-
Address: u64,
230-
Displacement: *mut u64,
231-
Symbol: PSYMBOL_INFOW
232-
) -> BOOL;
233-
fn SymGetLineFromAddrW64(
234-
hProcess: HANDLE,
235-
dwAddr: u64,
236-
pdwDisplacement: *mut u32,
237-
Line: PIMAGEHLP_LINEW64
238-
) -> BOOL;
239227
}
240228
}
241229

@@ -308,7 +296,7 @@ pub fn init() -> Result<Init, ()> {
308296
let mut lock = LOCK.load(SeqCst);
309297
if lock.is_null() {
310298
let name = mutex_name();
311-
lock = CreateMutexA(ptr::null_mut(), 0, name.as_ptr().cast::<i8>());
299+
lock = CreateMutexA(ptr::null_mut(), 0, name.as_ptr());
312300
if lock.is_null() {
313301
return Err(());
314302
}
@@ -387,7 +375,7 @@ fn set_optional_options() -> Option<()> {
387375
) == 1
388376
{
389377
// Trim the buffer to the actual length of the string.
390-
let len = lstrlenW(search_path_buf.as_mut_ptr());
378+
let len = lstrlenW(search_path_buf.as_mut_ptr());
391379
assert!(len >= 0);
392380
search_path_buf.truncate(len as usize);
393381
} else {
@@ -461,16 +449,16 @@ impl SearchPath {
461449
extern "system" fn enum_loaded_modules_callback(
462450
module_name: PCWSTR,
463451
_: u64,
464-
_: ULONG,
465-
user_context: PVOID,
452+
_: u32,
453+
user_context: *const c_void,
466454
) -> BOOL {
467455
// `module_name` is an absolute path like `C:\path\to\module.dll`
468456
// or `C:\path\to\module.exe`
469457
let len: usize = unsafe { lstrlenW(module_name).try_into().unwrap() };
470458

471459
if len == 0 {
472460
// This should not happen, but if it does, we can just ignore it.
473-
return TRUE;
461+
return 1;
474462
}
475463

476464
let module_name = unsafe { slice::from_raw_parts(module_name, len) };
@@ -483,13 +471,13 @@ extern "system" fn enum_loaded_modules_callback(
483471
else {
484472
// `module_name` being an absolute path, it should always contain at least one
485473
// path separator. If not, there is nothing we can do.
486-
return TRUE;
474+
return 1;
487475
};
488476

489477
let search_path = unsafe { &mut *(user_context as *mut SearchPath) };
490478
search_path.add(&module_name[..end_of_directory]);
491479

492-
TRUE
480+
1
493481
}
494482

495483
impl Drop for Init {

src/symbolize/dbghelp.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
use windows_sys::{
2121
Win32::Foundation::*, Win32::System::Diagnostics::Debug::*, Win32::System::Threading::*,
22+
Win32::Globalization::*,
2223
};
2324

2425
use super::super::dbghelp;
@@ -180,7 +181,7 @@ unsafe fn resolve_with_inline(
180181
addr,
181182
&mut inline_context,
182183
&mut 0,
183-
) != TRUE)
184+
) != 1)
184185
|| inlined_frame_count == 0
185186
{
186187
inlined_frame_count = 0;
@@ -212,7 +213,7 @@ unsafe fn do_resolve(
212213
const SIZE: usize = 2 * MAX_SYM_NAME as usize + mem::size_of::<SYMBOL_INFOW>();
213214
let mut data = Aligned8([0u8; SIZE]);
214215
let info = &mut *data.0.as_mut_ptr().cast::<SYMBOL_INFOW>();
215-
info.MaxNameLen = MAX_SYM_NAME as ULONG;
216+
info.MaxNameLen = MAX_SYM_NAME as u32;
216217
// the struct size in C. the value is different to
217218
// `size_of::<SYMBOL_INFOW>() - MAX_SYM_NAME + 1` (== 81)
218219
// due to struct alignment.
@@ -236,7 +237,7 @@ unsafe fn do_resolve(
236237
0,
237238
name_ptr,
238239
name_len as i32,
239-
name_buffer.as_mut_ptr().cast::<i8>(),
240+
name_buffer.as_mut_ptr(),
240241
name_buffer.len() as i32,
241242
core::ptr::null_mut(),
242243
core::ptr::null_mut(),

0 commit comments

Comments
 (0)