game_mem_utils 0.1.2

A Rust library for game memory manipulation on Linux
Documentation
  • Coverage
  • 73.33%
    22 out of 30 items documented0 out of 21 items with examples
  • Size
  • Source code size: 17.92 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 16s Average build duration of successful builds.
  • all releases: 20s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • ConeDjordjic/game-mem-utils
    1 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ConeDjordjic

GameMemUtils

A Rust library for reading and writing process memory on Linux.

Usage

Add to your Cargo.toml or use cargo add game_mem_utils:

[dependencies]
game_mem_utils = "0.1.2"

Example:

use game_mem_utils::{GameMemUtils, hex};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut mem = GameMemUtils::new("process_name")?;

    // Read a u32 value
    let gold: u32 = mem.read_at(hex!("8320b84"))?;
    println!("Current gold: {gold}");

    // Write a new value
    mem.write_at(hex!("8320b84"), 999999u32)?;

    Ok(())
}

API

Create instance

let mut mem = GameMemUtils::new("process_name")?;
let mut mem = GameMemUtils::from_pid(1234)?;

Read memory

let value: u32 = mem.read_at(0x12345678)?;          // absolute address
let value: u32 = mem.read(0x1000)?;                 // offset from base
let value: u32 = mem.read_hex("1000")?;             // hex string offset
let bytes = mem.read_bytes(0x12345678, 16)?;        // raw bytes
let text = mem.read_string(0x12345678, 64)?;        // null-terminated string

Write memory

mem.write_at(0x12345678, 42u32)?;                   // absolute address
mem.write(0x1000, 100i32)?;                         // offset from base
mem.write_hex("1000", 200u32)?;                     // hex string offset
mem.write_bytes(0x12345678, &[0x41, 0x42, 0x43])?;  // raw bytes

Utilities

let pid = mem.pid();
let base_addr = mem.base_address();
let module_base = mem.find_module_base("module.so")?;

Requirements

  • Linux
  • Appropriate permissions (may need sudo)

License

Licensed under the MIT license.