Struct windows_win::Process

source ·
pub struct Process { /* private fields */ }
Expand description

Windows process representation

Implementations§

source§

impl Process

source

pub fn open(pid: u32, access_rights: u32) -> Result<Process>

Creates handle to a new process by opening it through pid.

Note:

See information about access rights: https://msdn.microsoft.com/en-us/library/windows/desktop/ms684880%28v=vs.85%29.aspx

Parameters:
  • pid - Pid of the process.
  • access_rights - Bit mask that specifies desired access rights.
Return:
  • Ok - Process struct.
  • Err - Error reason.
source

pub fn from_raw(handle: HANDLE) -> Self

Creates instance from existing handle

source

pub fn inner(&self) -> HANDLE

Retrieves underlying handle.

source

pub fn into_inner(self) -> HANDLE

Retrieves underlying handle and consumes self.

Basically you’re responsible to close handle now.

source

pub fn exe_path(&self) -> Result<String>

Gets full path to process’s exectuable.

Note

The process MUST be opened with either PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION flag.

Return
  • Ok - Success.
  • Err - Error reason.
source

pub fn window(&self) -> Result<Option<HWND>>

Retrieves handle to process’s window

Note

It can return None if process hasn’t created window.

source

pub fn read_memory(&self, base_addr: usize, storage: &mut [u8]) -> Result<()>

Reads memory from process.

Parameters:
  • base_addr - Address from where to start reading.
  • storage - Storage to hold memory. Its len determines amount of bytes to read.
source

pub fn write_memory(&self, base_addr: usize, data: &[u8]) -> Result<()>

Writes into process memory.

Parameters:
  • base_addr - Address from where to start writing.
  • data - Slice with write data.
Return:
  • Ok - Success.
  • Err - Error reason.
source

pub fn close(&mut self)

Closes process

Note:

There is no need to explicitly close the process.

It shall be closed automatically when being dropped.

source

pub fn terminate(self, exit_code: c_uint) -> Result<()>

Forces termination of process and consumes itself.

For details see raw::process::terminate().

Trait Implementations§

source§

impl Drop for Process

source§

fn drop(&mut self)

Executes the destructor for this type. 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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.