pub struct OwnedProcess(/* private fields */);inject-dll only.Expand description
A struct representing a running process.
This struct owns the underlying process handle (see also BorrowedProcess for a borrowed version).
§Note
The underlying handle has the following privileges:
PROCESS_CREATE_THREADPROCESS_QUERY_INFORMATIONPROCESS_VM_OPERATIONPROCESS_VM_WRITEPROCESS_VM_READ
Implementations§
Source§impl OwnedProcess
impl OwnedProcess
Sourcepub fn from_pid(pid: u32) -> Result<OwnedProcess, Error>
pub fn from_pid(pid: u32) -> Result<OwnedProcess, Error>
Creates a new instance from the given pid.
Sourcepub fn all() -> Vec<OwnedProcess>
pub fn all() -> Vec<OwnedProcess>
Returns a list of all currently running processes.
Sourcepub fn find_all_by_name(name: impl AsRef<str>) -> Vec<OwnedProcess>
pub fn find_all_by_name(name: impl AsRef<str>) -> Vec<OwnedProcess>
Finds all processes whose name contains the given string.
Sourcepub fn find_first_by_name(name: impl AsRef<str>) -> Option<OwnedProcess>
pub fn find_first_by_name(name: impl AsRef<str>) -> Option<OwnedProcess>
Finds the first process whose name contains the given string.
Sourcepub fn from_child(child: Child) -> OwnedProcess
pub fn from_child(child: Child) -> OwnedProcess
Creates a new instance from the given child process.
Sourcepub unsafe fn borrowed_static(&self) -> BorrowedProcess<'static>
pub unsafe fn borrowed_static(&self) -> BorrowedProcess<'static>
Returns a borrowed instance of this process that lives for 'static.
§Safety
- This method is unsafe as the returned instance can outlive the owned instance, thus the caller must guarantee that the owned instance outlives the returned instance.
Sourcepub fn try_clone(&self) -> Result<OwnedProcess, Error>
pub fn try_clone(&self) -> Result<OwnedProcess, Error>
Creates a new owning Process instance for this process by duplicating the underlying handle.
Sourcepub fn leak(self) -> BorrowedProcess<'static>
pub fn leak(self) -> BorrowedProcess<'static>
Leaks the underlying handle and return it as a non-owning BorrowedProcess instance.
Sourcepub const fn kill_on_drop(self) -> ProcessKillGuard
pub const fn kill_on_drop(self) -> ProcessKillGuard
Returns a ProcessKillGuard wrapping this process that will automatically kill this process when dropped.
Trait Implementations§
Source§impl AsHandle for OwnedProcess
impl AsHandle for OwnedProcess
Source§fn as_handle(&self) -> BorrowedHandle<'_>
fn as_handle(&self) -> BorrowedHandle<'_>
Source§impl AsRawHandle for OwnedProcess
impl AsRawHandle for OwnedProcess
Source§impl Debug for OwnedProcess
impl Debug for OwnedProcess
Source§impl From<Child> for OwnedProcess
impl From<Child> for OwnedProcess
Source§fn from(child: Child) -> OwnedProcess
fn from(child: Child) -> OwnedProcess
Source§impl FromRawHandle for OwnedProcess
impl FromRawHandle for OwnedProcess
Source§unsafe fn from_raw_handle(handle: *mut c_void) -> OwnedProcess
unsafe fn from_raw_handle(handle: *mut c_void) -> OwnedProcess
Source§impl Hash for OwnedProcess
impl Hash for OwnedProcess
Source§impl IntoRawHandle for OwnedProcess
impl IntoRawHandle for OwnedProcess
Source§impl PartialEq<BorrowedProcess<'_>> for OwnedProcess
impl PartialEq<BorrowedProcess<'_>> for OwnedProcess
Source§impl PartialEq for OwnedProcess
impl PartialEq for OwnedProcess
Source§impl Process for OwnedProcess
impl Process for OwnedProcess
Source§type Handle = OwnedHandle
type Handle = OwnedHandle
Source§fn borrowed(&self) -> BorrowedProcess<'_>
fn borrowed(&self) -> BorrowedProcess<'_>
Source§fn try_clone(&self) -> Result<OwnedProcess, Error>
fn try_clone(&self) -> Result<OwnedProcess, Error>
Source§fn into_handle(self) -> <OwnedProcess as Process>::Handle
fn into_handle(self) -> <OwnedProcess as Process>::Handle
Source§unsafe fn from_handle_unchecked(
handle: <OwnedProcess as Process>::Handle,
) -> OwnedProcess
unsafe fn from_handle_unchecked( handle: <OwnedProcess as Process>::Handle, ) -> OwnedProcess
Source§fn current_handle() -> <OwnedProcess as Process>::Handle
fn current_handle() -> <OwnedProcess as Process>::Handle
Source§fn find_module_by_name(
&self,
module_name: impl AsRef<Path>,
) -> Result<Option<ProcessModule<OwnedProcess>>, Error>
fn find_module_by_name( &self, module_name: impl AsRef<Path>, ) -> Result<Option<ProcessModule<OwnedProcess>>, Error>
.dll is appended. Read moreSource§fn find_module_by_path(
&self,
module_path: impl AsRef<Path>,
) -> Result<Option<ProcessModule<OwnedProcess>>, Error>
fn find_module_by_path( &self, module_path: impl AsRef<Path>, ) -> Result<Option<ProcessModule<OwnedProcess>>, Error>
.dll is appended. Read moreSource§fn wait_for_module_by_name(
&self,
module_name: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<OwnedProcess>>, Error>
fn wait_for_module_by_name( &self, module_name: impl AsRef<Path>, timeout: Duration, ) -> Result<Option<ProcessModule<OwnedProcess>>, Error>
.dll is appended.Source§fn wait_for_module_by_path(
&self,
module_path: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<OwnedProcess>>, Error>
fn wait_for_module_by_path( &self, module_path: impl AsRef<Path>, timeout: Duration, ) -> Result<Option<ProcessModule<OwnedProcess>>, Error>
.dll is appended.