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_THREADPROCESS_QUERY_INFORMATIONPROCESS_VM_OPERATIONPROCESS_VM_WRITEPROCESS_VM_READ
Implementations§
Source§impl<'a> BorrowedProcess<'a>
impl<'a> BorrowedProcess<'a>
Sourcepub fn try_to_owned(&self) -> Result<OwnedProcess, Error>
pub fn try_to_owned(&self) -> Result<OwnedProcess, Error>
Tries to create a new OwnedProcess instance for this process.
Sourcepub fn module_handles(
&self,
) -> Result<impl ExactSizeIterator<Item = ModuleHandle>, Error>
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<'_>
impl AsHandle for BorrowedProcess<'_>
Source§fn as_handle(&self) -> BorrowedHandle<'_>
fn as_handle(&self) -> BorrowedHandle<'_>
Borrows the handle. Read more
Source§impl AsRawHandle for BorrowedProcess<'_>
impl AsRawHandle for BorrowedProcess<'_>
Source§fn as_raw_handle(&self) -> HANDLE
fn as_raw_handle(&self) -> HANDLE
Extracts the raw handle. Read more
Source§impl<'a> Clone for BorrowedProcess<'a>
impl<'a> Clone for BorrowedProcess<'a>
Source§fn clone(&self) -> BorrowedProcess<'a>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<'a> Copy for BorrowedProcess<'a>
Source§impl<'a> Debug for BorrowedProcess<'a>
impl<'a> Debug for BorrowedProcess<'a>
impl Eq for BorrowedProcess<'_>
Source§impl<'a> From<&'a OwnedProcess> for BorrowedProcess<'a>
impl<'a> From<&'a OwnedProcess> for BorrowedProcess<'a>
Source§fn from(process: &'a OwnedProcess) -> Self
fn from(process: &'a OwnedProcess) -> Self
Converts to this type from the input type.
Source§impl Hash for BorrowedProcess<'_>
impl Hash for BorrowedProcess<'_>
Source§impl PartialEq<BorrowedProcess<'_>> for OwnedProcess
impl PartialEq<BorrowedProcess<'_>> for OwnedProcess
Source§fn eq(&self, other: &BorrowedProcess<'_>) -> bool
fn eq(&self, other: &BorrowedProcess<'_>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<'a, 'b> PartialEq<BorrowedProcess<'a>> for BorrowedProcess<'b>
impl<'a, 'b> PartialEq<BorrowedProcess<'a>> for BorrowedProcess<'b>
Source§fn eq(&self, other: &BorrowedProcess<'a>) -> bool
fn eq(&self, other: &BorrowedProcess<'a>) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialEq<OwnedProcess> for BorrowedProcess<'_>
impl PartialEq<OwnedProcess> for BorrowedProcess<'_>
Source§fn eq(&self, other: &OwnedProcess) -> bool
fn eq(&self, other: &OwnedProcess) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<'a> Process for BorrowedProcess<'a>
impl<'a> Process for BorrowedProcess<'a>
Source§type Handle = BorrowedHandle<'a>
type Handle = BorrowedHandle<'a>
The underlying handle type.
Source§fn borrowed(&self) -> BorrowedProcess<'a>
fn borrowed(&self) -> BorrowedProcess<'a>
Returns a borrowed instance of this process.
Source§fn into_handle(self) -> Self::Handle
fn into_handle(self) -> Self::Handle
Returns the underlying process handle.
Source§unsafe fn from_handle_unchecked(handle: Self::Handle) -> Self
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
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>
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 moreSource§fn find_module_by_path(
&self,
module_path: impl AsRef<Path>,
) -> Result<Option<ProcessModule<BorrowedProcess<'a>>>, Error>
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 moreSource§fn wait_for_module_by_name(
&self,
module_name: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<BorrowedProcess<'a>>>, Error>
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>
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
fn raw_current_handle() -> ProcessHandle
Returns the raw pseudo handle representing the current process.
Source§fn is_current(&self) -> bool
fn is_current(&self) -> bool
Returns whether this instance represents the current process.
Source§fn base_name(&self) -> Result<OsString, Error>
fn base_name(&self) -> Result<OsString, Error>
Returns the file name of the executable of this process.
Source§fn kill_with_exit_code(&self, exit_code: u32) -> Result<(), Error>
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>
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>
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.
impl Send for BorrowedProcess<'_>
impl Sync for BorrowedProcess<'_>
Source§impl TryFrom<BorrowedProcess<'_>> for OwnedProcess
impl TryFrom<BorrowedProcess<'_>> for OwnedProcess
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> 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