pub struct ProcessKillGuard(pub OwnedProcess);
Expand description

A guard wrapping a OwnedProcess that will be automatically killed on drop.

Tuple Fields§

§0: OwnedProcess

Methods from Deref<Target = OwnedProcess>§

source

pub fn borrowed(&self) -> BorrowedProcess<'_>

Returns a borrowed instance of this process.

source

pub fn try_clone(&self) -> Result<Self, ProcessError>

Trys to clone this process instance.

source

pub fn try_to_owned(&self) -> Result<OwnedProcess, ProcessError>

Trys to create a new OwnedProcess instance for this process.

source

pub fn is_current(&self) -> bool

Returns whether this instance represents the current process.

source

pub fn is_alive(&self) -> bool

Returns whether this process is still alive and running.

Note

If the operation to determine the status fails, this function assumes that the process has exited.

source

pub fn pid(&self) -> Result<NonZeroU32, ProcessError>

Returns the id of this process.

source

pub fn runs_under_wow64(&self) -> Result<bool, ProcessError>

Returns whether this process is running under WOW64. This is the case for 32-bit programs running on a 64-bit platform.

source

pub fn is_64_bit(&self) -> Result<bool, ProcessError>

Returns whether this process is a 64-bit process.

source

pub fn is_32_bit(&self) -> Result<bool, ProcessError>

Returns whether this process is a 32-bit process.

source

pub fn bitness(&self) -> Result<usize, ProcessError>

Returns the bitness of this process.

source

pub fn path(&self) -> Result<PathBuf, ProcessError>

Returns the executable path of this process.

source

pub fn base_name(&self) -> Result<String, ProcessError>

Returns the file name of the executable of this process.

source

pub fn base_name_os(&self) -> Result<OsString, ProcessError>

Returns the file name of the executable of this process as an OsString.

source

pub fn kill(&self) -> Result<(), ProcessError>

Terminates this process with exit code 1.

source

pub fn kill_with_exit_code(&self, exit_code: u32) -> Result<(), ProcessError>

Terminates this process with the given exit code.

source

pub fn run_remote_thread<T>( &self, remote_fn: extern "system" fn(_: *mut T) -> u32, parameter: *mut T ) -> Result<u32, ProcessError>

Starts a new thread in this process with the given entry point and argument, and waits for it to finish, returning the exit code.

source

pub fn start_remote_thread<T>( &self, remote_fn: unsafe extern "system" fn(_: *mut T) -> u32, parameter: *mut T ) -> Result<OwnedHandle, ProcessError>

Starts a new thread in this process with the given entry point and argument and returns the thread handle.

source

pub fn modules(&self) -> Result<Vec<ProcessModule<Handle>>, ProcessError>

Returns a snapshot of all modules currently loaded in this process.

Note

If the process is currently starting up and has not loaded all its modules yet, the returned list may be incomplete.

source

pub fn module_handles( &self ) -> Result<impl Iterator<Item = Result<ModuleHandle, ProcessError>> + '_, ProcessError>

Returns a snapshot of the handles of the modules currently loaded in this process.

Note

If the process is currently starting up and has not yet loaded all its modules, the returned list may be incomplete. This can be worked around by repeatedly calling this method.

source

pub fn main_module(&self) -> Result<ProcessModule<Handle>, ProcessError>where Self: Sized,

Returns the main module of this process. This is typically the executable.

source

pub fn find_module_by_name( &self, module_name: impl AsRef<Path> ) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>

Searches the modules in this process for one with the given name. The comparison of names is case-insensitive. If the extension is omitted, the default library extension .dll is appended.

Note

If the process is currently starting up and has not loaded all its modules, the returned list may be incomplete. See also Process::wait_for_module_by_name.

source

pub fn find_module_by_path( &self, module_path: impl AsRef<Path> ) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>

Searches the modules in this process for one with the given path. The comparison of paths is case-insensitive. If the extension is omitted, the default library extension .dll is appended.

Note

If the process is currently starting up and has not loaded all its modules, the returned list may be incomplete. See also Process::wait_for_module_by_path.

source

pub fn wait_for_module_by_name( &self, module_name: impl AsRef<Path>, timeout: Duration ) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>

Searches the modules in this process for one with the given name repeatedly until a matching module is found or the given timeout elapses. The comparison of names is case-insensitive. If the extension is omitted, the default library extension .dll is appended.

source

pub fn wait_for_module_by_path( &self, module_path: impl AsRef<Path>, timeout: Duration ) -> Result<Option<ProcessModule<Handle>>, ProcessOrPathError>

Searches the modules in this process for one with the given path repeatedly until a matching module is found or the given timeout elapses. The comparison of paths is case-insensitive. If the extension is omitted, the default library extension .dll is appended.

Trait Implementations§

source§

impl AsMut<Process<OwnedHandle>> for ProcessKillGuard

source§

fn as_mut(&mut self) -> &mut OwnedProcess

Converts this type into a mutable reference of the (usually inferred) input type.
source§

impl AsRef<Process<OwnedHandle>> for ProcessKillGuard

source§

fn as_ref(&self) -> &OwnedProcess

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<Process<OwnedHandle>> for ProcessKillGuard

source§

fn borrow(&self) -> &OwnedProcess

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<Process<OwnedHandle>> for ProcessKillGuard

source§

fn borrow_mut(&mut self) -> &mut OwnedProcess

Mutably borrows from an owned value. Read more
source§

impl Debug for ProcessKillGuard

source§

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

Formats the value using the given formatter. Read more
source§

impl Deref for ProcessKillGuard

§

type Target = Process<OwnedHandle>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for ProcessKillGuard

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl Drop for ProcessKillGuard

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.