use lief_ffi as ffi;
use crate::common::FromFFI;
use std::marker::PhantomData;
pub struct MappingInfo<'a> {
ptr: cxx::UniquePtr<ffi::dsc_MappingInfo>,
_owner: PhantomData<&'a ()>,
}
impl FromFFI<ffi::dsc_MappingInfo> for MappingInfo<'_> {
fn from_ffi(ptr: cxx::UniquePtr<ffi::dsc_MappingInfo>) -> Self {
Self {
ptr,
_owner: PhantomData,
}
}
}
impl MappingInfo<'_> {
pub fn address(&self) -> u64 {
self.ptr.address()
}
pub fn size(&self) -> u64 {
self.ptr.size()
}
pub fn end_address(&self) -> u64 {
self.ptr.end_address()
}
pub fn file_offset(&self) -> u64 {
self.ptr.file_offset()
}
pub fn max_prot(&self) -> u32 {
self.ptr.max_prot()
}
pub fn init_prot(&self) -> u32 {
self.ptr.init_prot()
}
}
impl std::fmt::Debug for MappingInfo<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("MappingInfo")
.field("address", &self.address())
.field("end_address", &self.end_address())
.field("size", &self.size())
.field("file_offset", &self.file_offset())
.field("max_prot", &self.max_prot())
.field("init_prot", &self.init_prot())
.finish()
}
}