vmi_core/os/user_module.rs
1use super::{VmiOs, impl_predicate};
2use crate::{Va, VmiDriver, VmiError, VmiVa};
3
4impl_predicate! {
5 /// Predicate used for filtering user modules.
6 pub trait UserModulePredicate & impl for &str {
7 fn matches(&self, module: &Os::UserModule<'_>) -> Result<bool, VmiError> {
8 Ok(module.name()?.eq_ignore_ascii_case(self))
9 }
10 }
11
12 #[any]
13 pub struct AnyUserModule;
14}
15
16/// A trait for user-mode modules.
17///
18/// This trait provides an abstraction over modules loaded into a process
19/// address space, such as executables and shared libraries.
20pub trait VmiOsUserModule<'a, Driver>: VmiVa + 'a
21where
22 Driver: VmiDriver,
23{
24 /// The VMI OS type.
25 type Os: VmiOs<Driver = Driver, UserModule<'a> = Self>;
26
27 /// Returns the base address of the module.
28 ///
29 /// # Platform-specific
30 ///
31 /// - **Windows**: `LDR_DATA_TABLE_ENTRY.DllBase`
32 fn base_address(&self) -> Result<Va, VmiError>;
33
34 /// Returns the size of the module.
35 ///
36 /// # Platform-specific
37 ///
38 /// - **Windows**: `LDR_DATA_TABLE_ENTRY.SizeOfImage`
39 fn size(&self) -> Result<u64, VmiError>;
40
41 /// Returns the name of the module.
42 ///
43 /// # Platform-specific
44 ///
45 /// - **Windows**: `LDR_DATA_TABLE_ENTRY.BaseDllName`
46 fn name(&self) -> Result<String, VmiError>;
47}