> module
std::re::proc
read, write and inject into running processes
std::re::proc lists running processes and opens handles to them. Through a Handle a script reads and writes memory by address, walks the loaded modules and mapped regions, and loads code into the target.
Addresses are plain integers. Process and Handle are opaque OS objects; modules and regions come back as records (Module has name, path, base and size; Region has base, size, protection, kind and path).
Access says what a handle may do: Access::Read (query and read memory), Access::ReadWrite (also write) or Access::All (everything the OS allows). Where an access is taken, the strings "read", "readwrite" (or "write") and "all" work too, in any case.
Backed by procodile, on Linux and Windows. Methods that touch the target return Err with the OS error when it fails, for example without permission to trace it.
> functions
The processes whose executable file name is exactly name, such as "game.exe".
Open process pid with the given access.
> types
An opaque value; see the functions that return it.
An open handle to a process's memory, likewise shared.
Run the code at address in the target with arg as its first argument, wait for it to return, and give its return value. Windows uses a remote thread; Linux uses ptrace (x86-64 only).
Start a new thread in the target at address with arg and return without waiting for it.
Allocate executable memory in the target, copy bytes into it, and return its address.
handle.is_alive() -> boolWhether the process is still running (a zombie counts as exited).
handle.load_library(path: str, method: LoadMethod) -> Result<Module, str>Load the shared library at path (as the target sees its filesystem) into the target, and return it. LoadMethod::Loader uses the OS loader (LoadLibraryW on Windows, dlopen via ptrace on Linux x86-64), so the library shows in modules(); LoadMethod::ManualMap maps it without the loader. Needs ReadWrite or All access.
Manually map a library held in memory into the target, without the OS loader; it does not appear in modules(). x86-64 only.
Like module(), but searching mapped_images().
Every file-backed ELF or PE image in the address space, including ones the OS module list doesn't show, such as .NET assemblies that CoreCLR maps itself.
The loaded module with file name name. An exact match wins; otherwise case is ignored.
The loaded module containing address, if any.
The loaded modules (executable and shared libraries), in address order.
The size of a pointer in the target: 4 for a 32-bit process, 8 for 64-bit.
Read exactly len bytes at address. Reading fewer (an unmapped page part way through) is an Err.
Read a pointer of width bytes (4 or 8; see pointer_width()) at address.
The region containing address, if any.
Every committed memory region, in address order, including inaccessible ones.
Follow a Cheat Engine style pointer path: starting at base, each step reads the pointer at the current address and adds the next offset. With no offsets the result is base.
Let a suspended process run again. On Linux this sends SIGCONT.
Stop all of the process's threads, for example to take a consistent snapshot. On Linux this sends SIGSTOP.
How a shared library is loaded into the target process.
| LoadMethod::Loader | Use the target's OS loader. Windows: `LoadLibraryW` via `CreateRemoteThread`. Linux: `dlopen` via ptrace (x86-64 only). The loaded library appears in the OS module list and is returned by [`ProcessHandle::modules`]. |
| LoadMethod::ManualMap | Map the image directly into the target without involving the OS loader. Requires the `inject` feature. Handles cases where [`LoadMethod::Loader`] cannot be used: static/musl targets with no usable `dlopen`, stripped symbols, ptrace-blocked environments, or when the image only exists in memory. x86-64 only in the current implementation. |
A Process is a snapshot from the process list; it doesn't keep the process alive or give access to its memory.
A process snapshot. `Process` is an opaque OS object; it is held behind an `Arc` so the wrapper is cheap to clone, and lives in Xur as a native value.
Open a handle to this process, like proc::open(pid,\access).
The type of value a scan looks for. Values are read in the target's native byte order, which is assumed to match ours.
| ValueType::I8 | |
| ValueType::U8 | |
| ValueType::I16 | |
| ValueType::U16 | |
| ValueType::I32 | |
| ValueType::U32 | |
| ValueType::I64 | |
| ValueType::U64 | |
| ValueType::F32 | |
| ValueType::F64 |
> examples
use std::io;
use std::re::proc;
fn main() -> Result<(), str> {
let handle = proc::open_current()?;
for module in handle.modules()? {
io::println("{} {} {}", module.base, module.size, module.name);
}
let first = handle.modules()?[0];
let magic = handle.read(first.base, 4)?;
io::println("{}", magic.to_hex());
Ok(())
}