Struct LinuxTaskStruct

Source
pub struct LinuxTaskStruct<'a, Driver>
where Driver: VmiDriver, Driver::Architecture: Architecture + ArchAdapter<Driver>,
{ /* private fields */ }
Expand description

A Linux task struct.

The task_struct is the process descriptor in the Linux kernel, representing a task (process or thread).

§Implementation Details

Corresponds to task_struct.

Implementations§

Source§

impl<'a, Driver> LinuxTaskStruct<'a, Driver>
where Driver: VmiDriver, Driver::Architecture: Architecture + ArchAdapter<Driver>,

Source

pub fn new( vmi: VmiState<'a, Driver, LinuxOs<Driver>>, process: ProcessObject, ) -> Self

Creates a new Linux task struct.

Source

pub fn flags(&self) -> Result<u32, VmiError>

Returns the process flags.

Process flags in Linux include information about the process state, such as whether it’s exiting, a kernel thread, etc.

§Implementation Details

Corresponds to task_struct.flags.

Source

pub fn mm(&self) -> Result<Option<LinuxMmStruct<'a, Driver>>, VmiError>

Returns the memory descriptor (mm_struct) of the user-mode process.

The mm_struct contains the memory management information for a process. Kernel threads don’t have an mm_struct and return None.

§Implementation Details

Corresponds to task_struct->mm.

Source

pub fn active_mm(&self) -> Result<LinuxMmStruct<'a, Driver>, VmiError>

Returns the active memory context (mm_struct) of the process.

Used by kernel threads to reference the last used mm_struct before entering kernel mode.

If a kernel thread (mm() is None) needs memory access, it temporarily borrows active_mm from the last scheduled user-space process.

When the kernel thread exits, the original mm_struct is restored.

§Implementation Details

Corresponds to task_struct->active_mm.

Source

pub fn fs(&self) -> Result<Option<LinuxFsStruct<'a, Driver>>, VmiError>

Returns the filesystem context (fs_struct) of the process.

fs_struct contains:

  • root: The process’s root directory (used for chroot).
  • pwd: The current working directory.

All threads in the same process share the same fs_struct, unless explicitly changed.

Kernel threads don’t have an fs_struct and return None.

§Implementation Details

Corresponds to task_struct->fs.

Source

pub fn d_path( &self, path: &LinuxPath<'_, Driver>, ) -> Result<Option<String>, VmiError>

Constructs the absolute path from a path structure.

Takes into account the process’s filesystem root when constructing the absolute path.

Returns the resolved path as a string if successful, or None if the path could not be resolved (e.g., if the root is null).

§Implementation Details

Concatenates task_struct->fs->root with the path structure to construct the absolute path.

Source

pub fn image_path(&self) -> Result<Option<String>, VmiError>

Returns the path of the executable image for a process.

Returns the executable path as a string, or None for special processes like kernel threads or those in the process of exiting.

§Implementation Details

Corresponds to d_path(task->mm->exe_file->f_path).

Trait Implementations§

Source§

impl<'a, Driver> VmiOsProcess<'a, Driver> for LinuxTaskStruct<'a, Driver>
where Driver: VmiDriver, Driver::Architecture: Architecture + ArchAdapter<Driver>,

Source§

type Os = LinuxOs<Driver>

The VMI OS type.
Source§

fn id(&self) -> Result<ProcessId, VmiError>

Returns the process ID.
Source§

fn object(&self) -> Result<ProcessObject, VmiError>

Returns the process object.
Source§

fn name(&self) -> Result<String, VmiError>

Returns the name of the process. Read more
Source§

fn parent_id(&self) -> Result<ProcessId, VmiError>

Returns the parent process ID.
Source§

fn architecture(&self) -> Result<VmiOsImageArchitecture, VmiError>

Returns the architecture of the process.
Source§

fn translation_root(&self) -> Result<Pa, VmiError>

Returns the process’s page table translation root.
Source§

fn user_translation_root(&self) -> Result<Pa, VmiError>

Returns the user-mode page table translation root. Read more
Source§

fn image_base(&self) -> Result<Va, VmiError>

Returns the base address of the process image.
Source§

fn regions( &self, ) -> Result<impl Iterator<Item = Result<<Self::Os as VmiOs<Driver>>::Region<'a>, VmiError>>, VmiError>

Returns an iterator over the process’s memory regions.
Source§

fn find_region( &self, _address: Va, ) -> Result<Option<<Self::Os as VmiOs<Driver>>::Region<'a>>, VmiError>

Finds the memory region containing the given address.
Source§

fn threads( &self, ) -> Result<impl Iterator<Item = Result<<Self::Os as VmiOs<Driver>>::Thread<'a>, VmiError>>, VmiError>

Returns an iterator over the threads in the process. Read more
Source§

fn is_valid_address(&self, _address: Va) -> Result<Option<bool>, VmiError>

Checks whether the given virtual address is valid in the process. Read more
Source§

impl<Driver> VmiVa for LinuxTaskStruct<'_, Driver>
where Driver: VmiDriver, Driver::Architecture: Architecture + ArchAdapter<Driver>,

Source§

fn va(&self) -> Va

Returns the virtual address.

Auto Trait Implementations§

§

impl<'a, Driver> !Freeze for LinuxTaskStruct<'a, Driver>

§

impl<'a, Driver> !RefUnwindSafe for LinuxTaskStruct<'a, Driver>

§

impl<'a, Driver> !Send for LinuxTaskStruct<'a, Driver>

§

impl<'a, Driver> !Sync for LinuxTaskStruct<'a, Driver>

§

impl<'a, Driver> Unpin for LinuxTaskStruct<'a, Driver>

§

impl<'a, Driver> !UnwindSafe for LinuxTaskStruct<'a, Driver>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more