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§
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>
impl<'a, T> Unpin for VmmPluginContext<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for VmmPluginContext<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more