Struct Process

Source
pub struct Process { /* private fields */ }
Expand description

A handle to a running process.

Implementations§

Source§

impl Process

Source

pub fn from_id(id: u32) -> WinResult<Process>

Creates a process handle from a PID. Requests all access permissions.

Source

pub fn from_id_with_access(id: u32, access: Access) -> WinResult<Process>

Creates a process handle from a PID. Requests the specified access permissions.

Source

pub fn from_name(name: &str) -> WinResult<Process>

Creates a process handle from a name. Requests all access.

Source

pub fn from_name_with_access(name: &str, access: Access) -> WinResult<Process>

Creates a process handle from a name.

Source

pub fn from_handle(handle: Handle) -> Process

Creates a process handle from a handle.

Source

pub fn current() -> Process

Returns a handle to the current process.

Source

pub fn handle(&self) -> &Handle

Returns a reference to the inner handle.

Source

pub fn all() -> WinResult<impl Iterator<Item = Process>>

Enumerates all running processes. Requests all access.

Source

pub fn all_with_access( access: Access, ) -> WinResult<impl Iterator<Item = Process>>

Enumerates all running processes.

Source

pub fn id(&self) -> u32

Returns the process’s id.

Source

pub fn is_running(&self) -> bool

Returns true if the process is running.

Source

pub fn path(&self) -> WinResult<PathBuf>

Returns the path of the executable of the process.

Source

pub fn name(&self) -> WinResult<String>

Returns the unqualified name of the executable of the process.

Source

pub fn priority(&self) -> WinResult<PriorityClass>

Returns the priority class of the process.

The handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right.

Source

pub fn set_priority(&mut self, priority: PriorityClass) -> WinResult

Sets the priority class of the process.

The handle must have the PROCESS_SET_INFORMATION access right.

Source

pub fn start_background_mode(&mut self) -> WinResult

Begins background processing mode.

This can be initiated only if the handle refers to the current process.

The system lowers the resource scheduling priorities of the process (and its threads) so that it can perform background work without significantly affecting activity in the foreground.

The function fails if the process is already in background processing mode.

The handle must have the PROCESS_SET_INFORMATION access right.

Source

pub fn end_background_mode(&mut self) -> WinResult

Ends background processing mode.

This can be initiated only if the handle refers to the current process.

The system restores the resource scheduling priorities of the process (and its threads) as they were before the process entered background processing mode.

The function fails if the process is not in background processing mode.

The handle must have the PROCESS_SET_INFORMATION access right.

Source

pub fn terminate(&mut self, exit_code: u32) -> WinResult

Terminates the process.

The handle must have the PROCESS_TERMINATE access right.

Source

pub fn affinity_mask(&self) -> WinResult<usize>

Returns the affinity mask of the process.

Source

pub fn set_affinity_mask(&mut self, mask: u32) -> WinResult

Sets the affinity mask of the process.

A process affinity mask is a bit vector in which each bit represents a logical processor that a process is allowed to run on.

Setting an affinity mask for a process or thread can result in threads receiving less processor time, as the system is restricted from running the threads on certain processors. In most cases, it is better to let the system select an available processor.

If the new process affinity mask does not specify the processor that is currently running the process, the process is rescheduled on one of the allowable processors.

Source

pub fn threads<'a>(&'a self) -> WinResult<impl Iterator<Item = Thread> + 'a>

Returns an iterator over the threads of the process.

Source

pub fn thread_ids<'a>(&'a self) -> WinResult<impl Iterator<Item = u32> + 'a>

Returns an iterator over the ids of threads of the process.

Source

pub fn module<N: AsRef<OsStr>>(&self, name: N) -> WinResult<Module<'_>>

Returns the loaded module with the specified name/path.

Source

pub fn module_list(&self) -> WinResult<Vec<Module<'_>>>

Returns a list of the modules of the process.

Source

pub fn module_entries<'a>( &'a self, ) -> WinResult<impl Iterator<Item = ModuleEntry> + 'a>

Returns an iterator over the modules of the process.

Trait Implementations§

Source§

impl AsRawHandle for Process

Source§

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle. Read more
Source§

impl Debug for Process

Source§

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

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

impl Deref for Process

Source§

type Target = *mut c_void

The resulting type after dereferencing.
Source§

fn deref(&self) -> &HANDLE

Dereferences the value.
Source§

impl FromRawHandle for Process

Source§

unsafe fn from_raw_handle(handle: RawHandle) -> Process

Constructs a new I/O object from the specified raw handle. Read more
Source§

impl IntoRawHandle for Process

Source§

fn into_raw_handle(self) -> RawHandle

Consumes this object, returning the raw underlying handle. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.