use crate::{
DebuggeeOffset, dbgeng::WinResult, dbgmodel::*, impl_debug_interface,
};
use windows::Win32::System::Diagnostics::Debug::Extensions::{
IDebugHostMemory, IDebugHostMemory2, Location,
};
impl_debug_interface!(
DebugHostMemory,
DebugHostMemoryRef,
IDebugHostMemory2,
IDebugHostMemory
);
impl DebugHostMemory {
pub fn read_bytes<'a>(
&self,
context: impl Into<NonNullHostContextBy<'a>>,
location: Location,
buffer: &mut [u8],
) -> WinResult<u64> {
let mut bytes_read = 0;
unsafe {
self.0.ReadBytes(
context.into().as_raw(),
location,
buffer.as_mut_ptr() as _,
buffer.len() as u64,
Some(&mut bytes_read),
)?;
}
Ok(bytes_read)
}
pub fn write_bytes<'a>(
&self,
context: impl Into<NonNullHostContextBy<'a>>,
location: Location,
buffer: &mut [u8],
) -> WinResult<u64> {
let mut bytes_written = 0;
unsafe {
self.0.WriteBytes(
context.into().as_raw(),
location,
buffer.as_mut_ptr() as _,
buffer.len() as u64,
Some(&mut bytes_written),
)?;
}
Ok(bytes_written)
}
pub fn read_pointers<'a>(
&self,
context: impl Into<NonNullHostContextBy<'a>>,
location: Location,
pointers: &mut [DebuggeeOffset],
) -> WinResult<()> {
unsafe {
self.0
.ReadPointers(context.into().as_raw(), location, pointers)
}
}
pub fn write_pointers<'a>(
&self,
context: impl Into<NonNullHostContextBy<'a>>,
location: Location,
pointers: &mut [DebuggeeOffset],
) -> WinResult<()> {
unsafe {
self.0
.WritePointers(context.into().as_raw(), location, pointers)
}
}
pub fn get_display_string_for_location<'a>(
&self,
context: impl Into<NonNullHostContextBy<'a>>,
location: Location,
verbose: bool,
) -> WinResult<String> {
unsafe {
let s = self.0.GetDisplayStringForLocation(
context.into().as_raw(),
location,
verbose as u8,
)?;
Ok(s.to_string())
}
}
}
impl DebugHostMemory {
pub fn linearize_location<'a>(
&self,
context: impl Into<NonNullHostContextBy<'a>>,
location: Location,
) -> WinResult<Location> {
unsafe { self.0.LinearizeLocation(context.into().as_raw(), location) }
}
}
impl DebugHostMemory {
}
impl DebugHostMemory {
}