Skip to main content

BorrowedProcess

Struct BorrowedProcess 

Source
pub struct BorrowedProcess<'a>(/* private fields */);
Available on Windows only.
Expand description

A struct representing a running process. This struct does NOT own the underlying process handle (see also OwnedProcess for an owned version).

§Note

The underlying handle has the following privileges:

  • PROCESS_CREATE_THREAD
  • PROCESS_QUERY_INFORMATION
  • PROCESS_VM_OPERATION
  • PROCESS_VM_WRITE
  • PROCESS_VM_READ

Implementations§

Source§

impl<'a> BorrowedProcess<'a>

Source

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

Tries to create a new OwnedProcess instance for this process.

Source

pub fn module_handles( &self, ) -> Result<impl ExactSizeIterator<Item = ModuleHandle>, Error>

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.

Trait Implementations§

Source§

impl AsHandle for BorrowedProcess<'_>

Source§

fn as_handle(&self) -> BorrowedHandle<'_>

Borrows the handle. Read more
Source§

impl AsRawHandle for BorrowedProcess<'_>

Source§

fn as_raw_handle(&self) -> HANDLE

Extracts the raw handle. Read more
Source§

impl<'a> Clone for BorrowedProcess<'a>

Source§

fn clone(&self) -> BorrowedProcess<'a>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Copy for BorrowedProcess<'a>

Source§

impl<'a> Debug for BorrowedProcess<'a>

Source§

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

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

impl Eq for BorrowedProcess<'_>

Source§

impl<'a> From<&'a OwnedProcess> for BorrowedProcess<'a>

Source§

fn from(process: &'a OwnedProcess) -> Self

Converts to this type from the input type.
Source§

impl Hash for BorrowedProcess<'_>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq<BorrowedProcess<'_>> for OwnedProcess

Source§

fn eq(&self, other: &BorrowedProcess<'_>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, 'b> PartialEq<BorrowedProcess<'a>> for BorrowedProcess<'b>

Source§

fn eq(&self, other: &BorrowedProcess<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<OwnedProcess> for BorrowedProcess<'_>

Source§

fn eq(&self, other: &OwnedProcess) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Process for BorrowedProcess<'a>

Source§

type Handle = BorrowedHandle<'a>

The underlying handle type.
Source§

fn borrowed(&self) -> BorrowedProcess<'a>

Returns a borrowed instance of this process.
Source§

fn into_handle(self) -> Self::Handle

Returns the underlying process handle.
Source§

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

Tries to clone this process into a new instance.
Source§

unsafe fn from_handle_unchecked(handle: Self::Handle) -> Self

Creates a new instance from the given handle. Read more
Source§

fn current_handle() -> Self::Handle

Returns the pseudo handle representing the current process.
Source§

fn find_module_by_name( &self, module_name: impl AsRef<Path>, ) -> Result<Option<ProcessModule<BorrowedProcess<'a>>>, Error>

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. Read more
Source§

fn find_module_by_path( &self, module_path: impl AsRef<Path>, ) -> Result<Option<ProcessModule<BorrowedProcess<'a>>>, Error>

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. Read more
Source§

fn wait_for_module_by_name( &self, module_name: impl AsRef<Path>, timeout: Duration, ) -> Result<Option<ProcessModule<BorrowedProcess<'a>>>, Error>

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§

fn wait_for_module_by_path( &self, module_path: impl AsRef<Path>, timeout: Duration, ) -> Result<Option<ProcessModule<BorrowedProcess<'a>>>, Error>

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.
Source§

fn raw_current_handle() -> ProcessHandle

Returns the raw pseudo handle representing the current process.
Source§

fn current() -> Self
where Self: Sized,

Returns an instance representing the current process.
Source§

fn is_current(&self) -> bool

Returns whether this instance represents the current process.
Source§

fn is_alive(&self) -> bool

Returns whether this process is still alive and running. Read more
Source§

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

Returns the id of this process.
Source§

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

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

fn is_x64(&self) -> Result<bool, Error>

Returns whether this process is a 64-bit process.
Source§

fn is_x86(&self) -> Result<bool, Error>

Returns whether this process is a 32-bit process.
Source§

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

Returns the executable path of this process.
Source§

fn base_name(&self) -> Result<OsString, Error>

Returns the file name of the executable of this process.
Source§

fn kill(&self) -> Result<(), Error>

Terminates this process with exit code 1.
Source§

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

Terminates this process with the given exit code.
Source§

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

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§

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

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

fn modules(&self) -> Result<Vec<ProcessModule<Self>>, Error>
where Self: Sized,

Returns a snapshot of all modules currently loaded in this process. Read more
Source§

impl Send for BorrowedProcess<'_>

Source§

impl Sync for BorrowedProcess<'_>

Source§

impl TryFrom<BorrowedProcess<'_>> for OwnedProcess

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(process: BorrowedProcess<'_>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> Freeze for BorrowedProcess<'a>

§

impl<'a> RefUnwindSafe for BorrowedProcess<'a>

§

impl<'a> Unpin for BorrowedProcess<'a>

§

impl<'a> UnsafeUnpin for BorrowedProcess<'a>

§

impl<'a> UnwindSafe for BorrowedProcess<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DropFlavorWrapper<T> for T

Source§

type Flavor = MayDrop

The DropFlavor that wraps T into Self
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

Source§

const WITNESS: W = W::MAKE

A constant of the type witness
Source§

impl<T> Identity for T
where T: ?Sized,

Source§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
Source§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.