pub trait Process: AsHandle + AsRawHandle {
type Handle;
Show 24 methods
// Required methods
fn borrowed(&self) -> BorrowedProcess<'_>;
fn try_clone(&self) -> Result<Self, Error>
where Self: Sized;
fn into_handle(self) -> Self::Handle;
unsafe fn from_handle_unchecked(handle: Self::Handle) -> Self;
fn current_handle() -> Self::Handle;
fn find_module_by_name(
&self,
module_name: impl AsRef<Path>,
) -> Result<Option<ProcessModule<Self>>, Error>
where Self: Sized;
fn find_module_by_path(
&self,
module_path: impl AsRef<Path>,
) -> Result<Option<ProcessModule<Self>>, Error>
where Self: Sized;
fn wait_for_module_by_name(
&self,
module_name: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<Self>>, Error>
where Self: Sized;
fn wait_for_module_by_path(
&self,
module_path: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<Self>>, Error>
where Self: Sized;
// Provided methods
fn raw_current_handle() -> ProcessHandle { ... }
fn current() -> Self
where Self: Sized { ... }
fn is_current(&self) -> bool { ... }
fn is_alive(&self) -> bool { ... }
fn pid(&self) -> Result<NonZeroU32, Error> { ... }
fn runs_under_wow64(&self) -> Result<bool, Error> { ... }
fn is_x64(&self) -> Result<bool, Error> { ... }
fn is_x86(&self) -> Result<bool, Error> { ... }
fn path(&self) -> Result<PathBuf, Error> { ... }
fn base_name(&self) -> Result<OsString, Error> { ... }
fn kill(&self) -> Result<(), Error> { ... }
fn kill_with_exit_code(&self, exit_code: u32) -> Result<(), Error> { ... }
fn run_remote_thread<T>(
&self,
remote_fn: extern "system" fn(*mut T) -> u32,
parameter: *mut T,
) -> Result<u32, Error> { ... }
fn start_remote_thread<T>(
&self,
remote_fn: unsafe extern "system" fn(*mut T) -> u32,
parameter: *mut T,
) -> Result<OwnedHandle, Error> { ... }
fn modules(&self) -> Result<Vec<ProcessModule<Self>>, Error>
where Self: Sized { ... }
}Expand description
A trait representing a running process.
§Note
The underlying handle has the following privileges:
PROCESS_CREATE_THREADPROCESS_QUERY_INFORMATIONPROCESS_VM_OPERATIONPROCESS_VM_WRITEPROCESS_VM_READ
Required Associated Types§
Required Methods§
Sourcefn borrowed(&self) -> BorrowedProcess<'_>
fn borrowed(&self) -> BorrowedProcess<'_>
Returns a borrowed instance of this process.
Sourcefn try_clone(&self) -> Result<Self, Error>where
Self: Sized,
fn try_clone(&self) -> Result<Self, Error>where
Self: Sized,
Tries to clone this process into a new instance.
Sourcefn into_handle(self) -> Self::Handle
fn into_handle(self) -> Self::Handle
Returns the underlying process handle.
Sourceunsafe 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.
§Safety
The caller must ensure that the handle is a valid process handle and has the required priviledges.
Sourcefn current_handle() -> Self::Handle
fn current_handle() -> Self::Handle
Returns the pseudo handle representing the current process.
Sourcefn find_module_by_name(
&self,
module_name: impl AsRef<Path>,
) -> Result<Option<ProcessModule<Self>>, Error>where
Self: Sized,
fn find_module_by_name(
&self,
module_name: impl AsRef<Path>,
) -> Result<Option<ProcessModule<Self>>, Error>where
Self: Sized,
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.
Sourcefn find_module_by_path(
&self,
module_path: impl AsRef<Path>,
) -> Result<Option<ProcessModule<Self>>, Error>where
Self: Sized,
fn find_module_by_path(
&self,
module_path: impl AsRef<Path>,
) -> Result<Option<ProcessModule<Self>>, Error>where
Self: Sized,
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.
Sourcefn wait_for_module_by_name(
&self,
module_name: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<Self>>, Error>where
Self: Sized,
fn wait_for_module_by_name(
&self,
module_name: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<Self>>, Error>where
Self: Sized,
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.
Sourcefn wait_for_module_by_path(
&self,
module_path: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<Self>>, Error>where
Self: Sized,
fn wait_for_module_by_path(
&self,
module_path: impl AsRef<Path>,
timeout: Duration,
) -> Result<Option<ProcessModule<Self>>, Error>where
Self: Sized,
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.
Provided Methods§
Sourcefn raw_current_handle() -> ProcessHandle
fn raw_current_handle() -> ProcessHandle
Returns the raw pseudo handle representing the current process.
Sourcefn is_current(&self) -> bool
fn is_current(&self) -> bool
Returns whether this instance represents the current process.
Sourcefn is_alive(&self) -> bool
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.
Sourcefn pid(&self) -> Result<NonZeroU32, Error>
fn pid(&self) -> Result<NonZeroU32, Error>
Returns the id of this process.
Sourcefn runs_under_wow64(&self) -> Result<bool, Error>
fn runs_under_wow64(&self) -> Result<bool, Error>
Sourcefn base_name(&self) -> Result<OsString, Error>
fn base_name(&self) -> Result<OsString, Error>
Returns the file name of the executable of this process.
Sourcefn 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.
Sourcefn 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.
Sourcefn 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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".