Struct read_process_memory::ProcessHandle
source · pub struct ProcessHandle(_);
Expand description
A handle to a running process. This is not a process ID on all platforms.
For convenience, this crate implements TryFrom
-backed conversions from
Pid
to ProcessHandle
.
Examples
use read_process_memory::*;
use std::convert::TryInto;
use std::io;
fn pid_to_handle(pid: Pid) -> io::Result<ProcessHandle> {
Ok(pid.try_into()?)
}
This operation is not guaranteed to succeed. Specifically, on Windows
OpenProcess
may fail. On macOS task_for_pid
will generally fail
unless run as root, and even then it may fail when called on certain
programs; it may however run without root on the current process.
On macOS a ProcessHandle
is a mach port.
Trait Implementations§
source§impl Clone for ProcessHandle
impl Clone for ProcessHandle
source§fn clone(&self) -> ProcessHandle
fn clone(&self) -> ProcessHandle
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl CopyAddress for ProcessHandle
impl CopyAddress for ProcessHandle
Use vm_read
to read memory from another process on macOS.
source§impl TryFrom<&Child> for ProcessHandle
impl TryFrom<&Child> for ProcessHandle
This TryFrom
impl simply calls the TryFrom
impl for Pid
.
Unfortunately spawning a process on macOS does not hand back a mach
port by default (you have to jump through several hoops to get at it),
so there’s no simple implementation of TryFrom
Child
for::Child
. This implementation is just provided for symmetry
with other platforms to make writing cross-platform code easier.
Ideally we would provide an implementation of
std::process::Command::spawn
that jumped through those hoops and
provided the task port.
source§impl TryFrom<i32> for ProcessHandle
impl TryFrom<i32> for ProcessHandle
A Pid
can be turned into a ProcessHandle
with task_for_pid
.