VmmPluginContext

Struct VmmPluginContext 

Source
pub struct VmmPluginContext<'a, T> {
    pub vmm: Vmm<'a>,
    pub ctxlock: RwLock<T>,
    /* private fields */
}
Expand description

Plugin Context: Supplied by MemProcFS to plugin callback functions.

Contains the vmm field which gives access to the general API.

Contains the ctxlock field which gives access to the user-defined generic struct set at plugin initialization.

The ctxlock field is a std::sync::RwLock and the inner user-defined generic struct may be accessed in either multi-threaded read-mode or single-threaded mutable write-mode. Read mode is more efficient.

See the plugin example for additional use cases and documentation.

§Created By

  • plugin sub-system

§Examples

// Access the `vmm` field to retrieve a process for pid 768.
// Some `vmm` calls such as `vmm.process(pid)` may fail. In this case if
// the process does not exist. It is recommended to handle these errors
// gracefully as per below.
if let Ok(systemprocess) = plugin_ctx.vmm.process(768) {
    // ...
}
// Access the `vmm` field to retrieve a process for pid 768.
// Some `vmm` calls such as `vmm.process(pid)` may fail. It is possible to
// use error propagation for simplicity. Errors will be handled by upper
// plugin layers. If this is preferred error propagation may be simpler.
let systemprocess = plugin_ctx.vmm.process(768)?;
// Access the ctxlock in multi-threaded read-mode:
// The lock should always contain a generic so unwrap() should be safe.
let user_ctx = plugin_ctx.ctxlock.read().unwrap();
// Access the ctxlock in single-threaded mutable write-mode:
// The lock should always contain a generic so unwrap() should be safe.
let mut user_ctx = plugin_ctx.ctxlock.write().unwrap();

See the plugin example about usage of the ctxlock field.

Fields§

§vmm: Vmm<'a>

Access the general MemProcFS API through the vmm field.

§ctxlock: RwLock<T>

Access generic user-set plugin context in a thread-safe way.

Trait Implementations§

Source§

impl<T> Display for VmmPluginContext<'_, T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T> !Freeze for VmmPluginContext<'a, T>

§

impl<'a, T> RefUnwindSafe for VmmPluginContext<'a, T>

§

impl<'a, T> Send for VmmPluginContext<'a, T>
where T: Send,

§

impl<'a, T> Sync for VmmPluginContext<'a, T>
where T: Send + Sync,

§

impl<'a, T> Unpin for VmmPluginContext<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for VmmPluginContext<'a, T>

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.