use lief_ffi as ffi;
use crate::common::FromFFI;
use crate::declare_standalone_fwd_iterator;
use crate::to_opt;
pub struct LdrDataTableEntry {
ptr: cxx::UniquePtr<ffi::runtime_windows_LdrDataTableEntry>,
}
impl FromFFI<ffi::runtime_windows_LdrDataTableEntry> for LdrDataTableEntry {
fn from_ffi(ptr: cxx::UniquePtr<ffi::runtime_windows_LdrDataTableEntry>) -> Self {
Self { ptr }
}
}
impl LdrDataTableEntry {
pub fn dll_base(&self) -> u64 {
self.ptr.dll_base()
}
pub fn entry_point(&self) -> u64 {
self.ptr.entry_point()
}
pub fn size_of_image(&self) -> u32 {
self.ptr.size_of_image()
}
pub fn full_dll_name(&self) -> String {
self.ptr.full_dll_name().to_string()
}
pub fn base_dll_name(&self) -> String {
self.ptr.base_dll_name().to_string()
}
pub fn flags(&self) -> u32 {
self.ptr.flags()
}
pub fn obsolete_load_count(&self) -> u16 {
self.ptr.obsolete_load_count()
}
pub fn tls_index(&self) -> u16 {
self.ptr.tls_index()
}
pub fn time_date_stamp(&self) -> u32 {
self.ptr.time_date_stamp()
}
pub fn entry_point_activation_context(&self) -> u64 {
self.ptr.entry_point_activation_context()
}
pub fn lock(&self) -> u64 {
self.ptr.lock()
}
pub fn ddag_node(&self) -> Option<u64> {
to_opt!(&ffi::runtime_windows_LdrDataTableEntry::ddag_node, &self);
}
pub fn load_context(&self) -> Option<u64> {
to_opt!(&ffi::runtime_windows_LdrDataTableEntry::load_context, &self);
}
pub fn parent_dll_base(&self) -> Option<u64> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::parent_dll_base,
&self
);
}
pub fn switch_back_context(&self) -> Option<u64> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::switch_back_context,
&self
);
}
pub fn original_base(&self) -> Option<u64> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::original_base,
&self
);
}
pub fn load_time(&self) -> Option<i64> {
to_opt!(&ffi::runtime_windows_LdrDataTableEntry::load_time, &self);
}
pub fn base_name_hash_value(&self) -> Option<u32> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::base_name_hash_value,
&self
);
}
pub fn load_reason(&self) -> Option<i32> {
to_opt!(&ffi::runtime_windows_LdrDataTableEntry::load_reason, &self);
}
pub fn implicit_path_options(&self) -> Option<u32> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::implicit_path_options,
&self
);
}
pub fn reference_count(&self) -> Option<u32> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::reference_count,
&self
);
}
pub fn dependent_load_flags(&self) -> Option<u32> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::dependent_load_flags,
&self
);
}
pub fn signing_level(&self) -> Option<u8> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::signing_level,
&self
);
}
pub fn check_sum(&self) -> Option<u32> {
to_opt!(&ffi::runtime_windows_LdrDataTableEntry::check_sum, &self);
}
pub fn active_patch_image_base(&self) -> Option<u64> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::active_patch_image_base,
&self
);
}
pub fn hot_patch_state(&self) -> Option<u32> {
to_opt!(
&ffi::runtime_windows_LdrDataTableEntry::hot_patch_state,
&self
);
}
}
impl std::fmt::Display for LdrDataTableEntry {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", self.ptr.to_string())
}
}
declare_standalone_fwd_iterator!(
LdrDataTableEntries,
LdrDataTableEntry,
ffi::runtime_windows_LdrDataTableEntry,
ffi::runtime_windows_it_ldr_data_table_entry
);