#[derive(GameStruct)]
{
// Attributes available to this derive:
#[offset]
#[pointer_chain]
}
Expand description
Derives a read method that maps a remote process’s memory into a Rust struct.
Each field must have an #[offset(N)] attribute specifying its byte offset
from the base address. Fields may optionally have a #[pointer_chain(a, b, ...)]
attribute to follow a chain of pointers before reading the final value.
The generated method signature is:
ⓘ
pub fn read(process: &procmod_layout::Process, base: usize) -> procmod_layout::Result<Self>§Attributes
#[offset(N)]- byte offset from base address (required on every field)#[pointer_chain(a, b, ...)]- intermediate pointer offsets to follow before reading
§Safety requirement
All field types must be valid for any bit pattern. Numeric primitives (u8,
u32, f32, etc.), fixed-size arrays of numeric types, and #[repr(C)]
structs composed of such types are safe. Types with validity invariants
(bool, char, enums, references) must not be used - read them as their
underlying integer type instead (e.g., u8 for booleans).
§Example
ⓘ
use procmod_layout::GameStruct;
#[derive(GameStruct)]
struct Player {
#[offset(0x100)]
health: f32,
#[offset(0x200)]
#[pointer_chain(0x10, 0x8)]
damage_mult: f32,
}