Skip to content
Merged
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
15 changes: 12 additions & 3 deletions crates/rrg/src/action/dump_process_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ mod windows {
self.process.0,
self.cur_addr,
mem.as_mut_ptr(),
std::mem::size_of::<MEMORY_BASIC_INFORMATION>(),
std::mem::size_of_val(&mem),
)
};
if status == 0 {
Expand Down Expand Up @@ -534,15 +534,20 @@ mod windows {
let meta = file.metadata().unwrap();
let length = meta.len() as usize;

let len_hi = u32::try_from(meta.len() >> u32::BITS)
.expect("invalid length high bits");
let len_lo = u32::try_from(meta.len() & u64::from(!0u32))
.expect("invalid length low bits");

// SAFETY: the returned mapping will be dropped
// by `OwnedHandle`'s `drop` impl.
let mapping = unsafe {
CreateFileMappingW(
file.as_raw_handle(),
std::ptr::null(), // default security
PAGE_READWRITE, // read/write permission
0, // size of mapping object, high
length as u32, // size of mapping object, low
len_hi, // size of mapping object, high
len_lo, // size of mapping object, low
std::ptr::null(),
)
};
Expand All @@ -563,6 +568,10 @@ mod windows {
impl Drop for MappedView {
fn drop(&mut self) {
// SAFETY: we only need `unsafe` to call the FFI function here.
//
// The pointer is invalidated but it is not leaked outside
// of this type, so it is no longer accessible after the
// value is destroyed.
unsafe {
UnmapViewOfFile(self.addr);
}
Expand Down
Loading