Trait memflow::os::root::Os

source ·
pub trait Os: Send {
    type ProcessType<'a>: Process + MemoryView + 'a
       where Self: 'a;
    type IntoProcessType: Process + MemoryView + Clone + 'static;

Show 32 methods // Required methods fn process_address_list_callback( &mut self, callback: AddressCallback<'_> ) -> Result<()>; fn process_info_by_address( &mut self, address: Address ) -> Result<ProcessInfo>; fn process_by_info( &mut self, info: ProcessInfo ) -> Result<Self::ProcessType<'_>>; fn into_process_by_info( self, info: ProcessInfo ) -> Result<Self::IntoProcessType>; fn module_address_list_callback( &mut self, callback: AddressCallback<'_> ) -> Result<()>; fn module_by_address(&mut self, address: Address) -> Result<ModuleInfo>; fn primary_module_address(&mut self) -> Result<Address>; fn module_import_list_callback( &mut self, info: &ModuleInfo, callback: ImportCallback<'_> ) -> Result<()>; fn module_export_list_callback( &mut self, info: &ModuleInfo, callback: ExportCallback<'_> ) -> Result<()>; fn module_section_list_callback( &mut self, info: &ModuleInfo, callback: SectionCallback<'_> ) -> Result<()>; fn info(&self) -> &OsInfo; // Provided methods fn process_address_list(&mut self) -> Result<Vec<Address>> { ... } fn process_info_list_callback( &mut self, callback: ProcessInfoCallback<'_> ) -> Result<()> { ... } fn process_info_list(&mut self) -> Result<Vec<ProcessInfo>> { ... } fn process_info_by_name(&mut self, name: &str) -> Result<ProcessInfo> { ... } fn process_info_by_pid(&mut self, pid: Pid) -> Result<ProcessInfo> { ... } fn process_by_address( &mut self, addr: Address ) -> Result<Self::ProcessType<'_>> { ... } fn process_by_name(&mut self, name: &str) -> Result<Self::ProcessType<'_>> { ... } fn process_by_pid(&mut self, pid: Pid) -> Result<Self::ProcessType<'_>> { ... } fn into_process_by_address( self, addr: Address ) -> Result<Self::IntoProcessType> where Self: Sized { ... } fn into_process_by_name(self, name: &str) -> Result<Self::IntoProcessType> where Self: Sized { ... } fn into_process_by_pid(self, pid: Pid) -> Result<Self::IntoProcessType> where Self: Sized { ... } fn module_list_callback( &mut self, callback: ModuleInfoCallback<'_> ) -> Result<()> { ... } fn module_by_name(&mut self, name: &str) -> Result<ModuleInfo> { ... } fn module_list(&mut self) -> Result<Vec<ModuleInfo>> { ... } fn primary_module(&mut self) -> Result<ModuleInfo> { ... } fn module_import_list( &mut self, info: &ModuleInfo ) -> Result<Vec<ImportInfo>> { ... } fn module_export_list( &mut self, info: &ModuleInfo ) -> Result<Vec<ExportInfo>> { ... } fn module_section_list( &mut self, info: &ModuleInfo ) -> Result<Vec<SectionInfo>> { ... } fn module_import_by_name( &mut self, info: &ModuleInfo, name: &str ) -> Result<ImportInfo> { ... } fn module_export_by_name( &mut self, info: &ModuleInfo, name: &str ) -> Result<ExportInfo> { ... } fn module_section_by_name( &mut self, info: &ModuleInfo, name: &str ) -> Result<SectionInfo> { ... }
}
Expand description

High level OS trait implemented by OS layers.

This trait provides all necessary functions for handling an OS, retrieving processes, and moving resources into processes.

There are also methods for accessing system level modules.

Required Associated Types§

source

type ProcessType<'a>: Process + MemoryView + 'a where Self: 'a

source

type IntoProcessType: Process + MemoryView + Clone + 'static

Required Methods§

source

fn process_address_list_callback( &mut self, callback: AddressCallback<'_> ) -> Result<()>

Walks a process list and calls a callback for each process structure address

The callback is fully opaque. We need this style so that C FFI can work seamlessly.

source

fn process_info_by_address(&mut self, address: Address) -> Result<ProcessInfo>

Find process information by its internal address

source

fn process_by_info( &mut self, info: ProcessInfo ) -> Result<Self::ProcessType<'_>>

Construct a process by its info, borrowing the OS

It will share the underlying memory resources

source

fn into_process_by_info( self, info: ProcessInfo ) -> Result<Self::IntoProcessType>

Construct a process by its info, consuming the OS

This function will consume the Kernel instance and move its resources into the process

source

fn module_address_list_callback( &mut self, callback: AddressCallback<'_> ) -> Result<()>

Walks the OS module list and calls the provided callback for each module structure address

Arguments
  • callback - where to pass each matching module to. This is an opaque callback.
source

fn module_by_address(&mut self, address: Address) -> Result<ModuleInfo>

Retrieves a module by its structure address

Arguments
  • address - address where module’s information resides in
source

fn primary_module_address(&mut self) -> Result<Address>

Retrieves address of the primary module of the OS

This will generally be for the main kernel process/module

source

fn module_import_list_callback( &mut self, info: &ModuleInfo, callback: ImportCallback<'_> ) -> Result<()>

Retrieves a list of all imports of a given module

source

fn module_export_list_callback( &mut self, info: &ModuleInfo, callback: ExportCallback<'_> ) -> Result<()>

Retrieves a list of all exports of a given module

source

fn module_section_list_callback( &mut self, info: &ModuleInfo, callback: SectionCallback<'_> ) -> Result<()>

Retrieves a list of all sections of a given module

source

fn info(&self) -> &OsInfo

Retrieves the OS info

Provided Methods§

source

fn process_address_list(&mut self) -> Result<Vec<Address>>

Retrieves a process address list

This will be a list of unique internal addresses for underlying process structures

source

fn process_info_list_callback( &mut self, callback: ProcessInfoCallback<'_> ) -> Result<()>

Walks a process list and calls a callback for each process

The callback is fully opaque. We need this style so that C FFI can work seamlessly.

source

fn process_info_list(&mut self) -> Result<Vec<ProcessInfo>>

Retrieves a process list

source

fn process_info_by_name(&mut self, name: &str) -> Result<ProcessInfo>

Find process information by its name

Remarks:

This function only returns processes whose state is not ProcessState::Dead.

source

fn process_info_by_pid(&mut self, pid: Pid) -> Result<ProcessInfo>

Find process information by its ID

source

fn process_by_address(&mut self, addr: Address) -> Result<Self::ProcessType<'_>>

Creates a process by its internal address, borrowing the OS

It will share the underlying memory resources

If no process with the specified address can be found this function will return an Error.

This function can be useful for quickly accessing a process.

source

fn process_by_name(&mut self, name: &str) -> Result<Self::ProcessType<'_>>

Creates a process by its name, borrowing the OS

It will share the underlying memory resources

If no process with the specified name can be found this function will return an Error.

This function can be useful for quickly accessing a process.

Remarks:

This function only returns processes whose state is not ProcessState::Dead.

source

fn process_by_pid(&mut self, pid: Pid) -> Result<Self::ProcessType<'_>>

Creates a process by its ID, borrowing the OS

It will share the underlying memory resources

If no process with the specified ID can be found this function will return an Error.

This function can be useful for quickly accessing a process.

source

fn into_process_by_address(self, addr: Address) -> Result<Self::IntoProcessType>
where Self: Sized,

Creates a process by its internal address, consuming the OS

It will consume the OS and not affect memory usage

If no process with the specified address can be found this function will return an Error.

This function can be useful for quickly accessing a process.

source

fn into_process_by_name(self, name: &str) -> Result<Self::IntoProcessType>
where Self: Sized,

Creates a process by its name, consuming the OS

It will consume the OS and not affect memory usage

If no process with the specified name can be found this function will return an Error.

This function can be useful for quickly accessing a process.

Remarks:

This function only returns processes whose state is not ProcessState::Dead.

source

fn into_process_by_pid(self, pid: Pid) -> Result<Self::IntoProcessType>
where Self: Sized,

Creates a process by its ID, consuming the OS

It will consume the OS and not affect memory usage

If no process with the specified ID can be found this function will return an Error.

This function can be useful for quickly accessing a process.

source

fn module_list_callback( &mut self, callback: ModuleInfoCallback<'_> ) -> Result<()>

Walks the OS module list and calls the provided callback for each module

Arguments
  • callback - where to pass each matching module to. This is an opaque callback.
source

fn module_by_name(&mut self, name: &str) -> Result<ModuleInfo>

Finds a OS module by its name

This function can be useful for quickly accessing a specific module

source

fn module_list(&mut self) -> Result<Vec<ModuleInfo>>

Retrieves a module list for the OS

source

fn primary_module(&mut self) -> Result<ModuleInfo>

Retrieves information for the primary module of the OS

This will generally be for the main kernel process/module

source

fn module_import_list(&mut self, info: &ModuleInfo) -> Result<Vec<ImportInfo>>

Retrieves a list of all imports of a given module

source

fn module_export_list(&mut self, info: &ModuleInfo) -> Result<Vec<ExportInfo>>

Retrieves a list of all exports of a given module

source

fn module_section_list(&mut self, info: &ModuleInfo) -> Result<Vec<SectionInfo>>

Retrieves a list of all sections of a given module

source

fn module_import_by_name( &mut self, info: &ModuleInfo, name: &str ) -> Result<ImportInfo>

Finds a single import of a given module by its name

source

fn module_export_by_name( &mut self, info: &ModuleInfo, name: &str ) -> Result<ExportInfo>

Finds a single export of a given module by its name

source

fn module_section_by_name( &mut self, info: &ModuleInfo, name: &str ) -> Result<SectionInfo>

Finds a single section of a given module by its name

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<'cglue_a, CGlueO: 'cglue_a + GetContainer + GetVtbl<OsVtbl<'cglue_a, <Self as GetContainer>::ContType>> + Send + OsOpaqueObj<'cglue_a>> Os for CGlueO
where OsVtbl<'cglue_a, <Self as GetContainer>::ContType>: StableAbi,

§

type ProcessType<'a> = ProcessInstance<'a, CBox<'a, c_void>, <<CGlueO as GetContainer>::ContType as CGlueObjBase>::Context> where Self: 'a

§

type IntoProcessType = IntoProcessInstance<'static, CBox<'static, c_void>, <<CGlueO as GetContainer>::ContType as CGlueObjBase>::Context>