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.
Plugin is hidden in the file system root.
is_process_module: bool
Plugin shows up on a per-process basis.
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>
impl<T> VmmPluginInitializationContext<T>
Sourcepub fn register(self) -> ResultEx<()>
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();