vmi_core/os/
module.rs

1use super::VmiOs;
2use crate::{Va, VmiDriver, VmiError, VmiVa};
3
4/// A trait for kernel modules.
5///
6/// This trait provides an abstraction over dynamically loaded modules,
7/// such as kernel drivers and shared libraries, within a guest OS.
8pub trait VmiOsModule<'a, Driver>: VmiVa + 'a
9where
10    Driver: VmiDriver,
11{
12    /// The VMI OS type.
13    type Os: VmiOs<Driver>;
14
15    /// Returns the base address of the module.
16    ///
17    /// # Platform-specific
18    ///
19    /// - **Windows**: `KLDR_DATA_TABLE_ENTRY.DllBase`
20    /// - **Linux**:
21    ///   - since v6.4-rc1: `module::mem[0 /* MOD_TEXT */].base`
22    ///   - before v6.4-rc1: `module::core_layout.base`
23    fn base_address(&self) -> Result<Va, VmiError>;
24
25    /// Returns the size of the module.
26    ///
27    /// # Platform-specific
28    ///
29    /// - **Windows**: `KLDR_DATA_TABLE_ENTRY.SizeOfImage`
30    /// - **Linux**:
31    ///   - since v6.4-rc1: sum of `module::mem[MOD_*].size`
32    ///   - before v6.4-rc1: `module::init_layout.size + module::core_layout.size (+ module::data_layout.size)`
33    fn size(&self) -> Result<u64, VmiError>;
34
35    /// Returns the name of the module.
36    ///
37    /// # Platform-specific
38    ///
39    /// - **Windows**: `KLDR_DATA_TABLE_ENTRY.BaseDllName`
40    /// - **Linux**: `module::name`
41    fn name(&self) -> Result<String, VmiError>;
42}