Struct VmmPluginInitializationContext

Source
pub struct VmmPluginInitializationContext<T> {
    pub ctx: Option<T>,
    pub path_name: String,
    pub is_root_module: bool,
    pub is_root_module_hidden: bool,
    pub is_process_module: bool,
    pub is_process_module_hidden: bool,
    pub fn_list: Option<fn(ctxp: &VmmPluginContext<'_, T>, process: Option<VmmProcess<'_>>, path: &str, file_list: &VmmPluginFileList<'_>) -> ResultEx<()>>,
    pub fn_read: Option<fn(ctxp: &VmmPluginContext<'_, T>, process: Option<VmmProcess<'_>>, file_name: &str, cb: u32, cb_offset: u64) -> ResultEx<Vec<u8>>>,
    pub fn_write: Option<fn(ctxp: &VmmPluginContext<'_, T>, process: Option<VmmProcess<'_>>, file_name: &str, data: Vec<u8>, cb_offset: u64) -> ResultEx<()>>,
    pub fn_visible: Option<fn(ctxp: &VmmPluginContext<'_, T>, process: Option<VmmProcess<'_>>) -> ResultEx<bool>>,
    pub fn_notify: Option<fn(ctxp: &VmmPluginContext<'_, T>, event_id: u32) -> ResultEx<()>>,
    /* private fields */
}
Expand description

Plugin Initialization Context.

The VmmPluginInitializationContext is used in the plugin module entry point (the exported InitializeVmmPlugin() function).

The context is to be populated by the user with information such as name, callback functions and plugin visibility.

The flow usually follows the below structure:

1: Call: memprocfs::new_plugin_initialization(native_h, native_reginfo) to create the plugin init context inside the InitializeVmmPlugin() function.

2: Fill out the required ctx and path_name struct members.

3: Fill out the module type in the is* struct members.

4: Fill out the optional pfn* callback functions.

5: Register the plugin with the VMM by calling the register() method.

For additional information check the InitializeVmmPlugin() function in the plugin example project.

§Created By

§Examples

// Retrieve the system_info and plugin_init_ctx in InitializeVmmPlugin()
let (system_info, mut plugin_init_ctx) = match new_plugin_initialization::<PluginContext>(native_h, native_reginfo) {
    Ok(r) => r,
    Err(_) => return,
};
// set plugin name:
plugin_init_ctx.path_name = String::from("/rust/example");
// Set user-defined generic plugin context:
let ctx = PluginContext {
    ...
};
plugin_init_ctx.ctx = Some(ctx);
// Set visiblity:
plugin_init_ctx.is_root_module = true;
plugin_init_ctx.is_process_module = true;
// Set callback functions:
plugin_init_ctx.fn_list = Some(plugin_list_cb);
plugin_init_ctx.fn_read = Some(plugin_read_cb);
plugin_init_ctx.fn_write = Some(plugin_write_cb);
// Register the plugin with the MemProcFS plugin manager:
let _r = plugin_init_ctx.register();

Fields§

§ctx: Option<T>

user-defined generic plugin context.

§path_name: String

Plugin path and name.

§is_root_module: bool

Plugin shows up in the file system root.

§is_root_module_hidden: bool

Plugin is hidden in the file system root.

§is_process_module: bool

Plugin shows up on a per-process basis.

§is_process_module_hidden: bool

Plugin is hidden on a per-process basis.

§fn_list: Option<fn(ctxp: &VmmPluginContext<'_, T>, process: Option<VmmProcess<'_>>, path: &str, file_list: &VmmPluginFileList<'_>) -> ResultEx<()>>

Callback function - VFS list directory. This callback used in most cases.

§fn_read: Option<fn(ctxp: &VmmPluginContext<'_, T>, process: Option<VmmProcess<'_>>, file_name: &str, cb: u32, cb_offset: u64) -> ResultEx<Vec<u8>>>

Callback function - VFS read file. This callback is used in most cases.

§fn_write: Option<fn(ctxp: &VmmPluginContext<'_, T>, process: Option<VmmProcess<'_>>, file_name: &str, data: Vec<u8>, cb_offset: u64) -> ResultEx<()>>

Callback function - VFS write file.

§fn_visible: Option<fn(ctxp: &VmmPluginContext<'_, T>, process: Option<VmmProcess<'_>>) -> ResultEx<bool>>

Callback function - plugin dynamic visiblity. This callback is rarely used, and in special circumstances only.

§fn_notify: Option<fn(ctxp: &VmmPluginContext<'_, T>, event_id: u32) -> ResultEx<()>>

Callback function - notification on an event defined by: PLUGIN_NOTIFY_* constants.

Implementations§

Source§

impl<T> VmmPluginInitializationContext<T>

Source

pub fn register(self) -> ResultEx<()>

Register the plugin with the MemProcFS plugin sub-system.

The initialiation context may not be used after the register() call.

It is possible to register additional plugins in the same plugin initialization function if a new VmmPluginInitializationContext is retrieved from the new_plugin_initialization() function.

§Examples
// Register the plugin with MemProcFS. This will consume the context
// which should not be possible to use after this.
let _r = plugin_init_ctx.register();

Trait Implementations§

Source§

impl<T> Display for VmmPluginInitializationContext<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.