A rust library that makes reading and writing memory of the Dolphin emulator easier.

Overview

dolphin-memory-rs

A crate for reading from and writing to the emulated memory of Dolphin in rust. A lot of internals here are directly based on aldelaro5's Dolphin Memory Engine.

Currently the only platform supported is Windows, though it should be possible to port it to other platforms.

Examples

Reading from Memory

A simplified example of reading the Game ID, using the GCM format.

use dolphin_memory::Dolphin;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Searches for the dolphin process on loop. Dolphin::new will error
    // when the process isn't found, so you could choose to handle that however.
    let dolphin = loop {
        if let Ok(dolphin) = Dolphin::new() {
            break dolphin;
        }
    };

    // Reads the value at 0x80000000, which is the gcm header address.
    let header_address = 0x80000000;
    // The first 6 bytes of the header include the Game ID, which is a string.
    let game_id = dolphin.read_string(6, header_address, None)?;

    println!("Game ID: {}", game_id);

    Ok(())
}

Bytes

Sometimes you want to read a specific number of bytes. All the convenience functions actually just wrap a call to read with a set number of bytes.

use dolphin_memory::Dolphin;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let dolphin = loop {
        if let Ok(dolphin) = Dolphin::new() {
            break dolphin;
        }
    };

    // The crate provides convenience functions for most common types, but you can also
    // use it to read raw bytes yourself. Note that when reading raw bytes it's up
    // to you to determine how to parse them (eg. if you're dealing with BigEndian data).
    let header_address = 0x80000000;
    let game_id_bytes = dolphin.read(6, header_address, None)?;

    println!(
        "Game ID: {}",
        String::from_utf8(game_id_bytes)
            .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?
    );

    Ok(())
}

Pointers

It's not uncommon to have to deal with pointers in memory. Thankfully this crate makes that process easy.

use dolphin_memory::Dolphin;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let dolphin = loop {
        if let Ok(dolphin) = Dolphin::new() {
            break dolphin;
        }
    };

    // Every call can also optionally follow a chain of pointer addresses.
    // To specify a list of pointers, supply a list of addresses in the
    // order that they need to be chained. The last address will read the actual
    // value at the end of the pointer chain.
    let some_ptr_addr = 0x81234567;
    let some_value_offset = 0xA4;
    let game_id_bytes = dolphin.read(6, some_ptr_addr, Some(&[some_value_offset]))?;

    Ok(())
}
You might also like...
Translate C++/Rust type into C type with the same memory layout

clayout, translate C++/Rust type into C type with the same memory layout. Generally, clayout is used together with bpftrace. clayout is developed on d

A memory visualizer in Rust (ptrace + userfaultfd)

mevi A memory visualizer for Linux 5.7+ Made for this video: https://www.youtube.com/watch?v=DpnXaNkM9_M Prerequisite The vm.unprivileged_userfaultfd

A memory efficient immutable string type that can store up to 24* bytes on the stack

compact_str A memory efficient immutable string type that can store up to 24* bytes on the stack. * 12 bytes for 32-bit architectures About A CompactS

bustd is a lightweight process killer daemon for out-of-memory scenarios for Linux!

bustd: Available memory or bust! bustd is a lightweight process killer daemon for out-of-memory scenarios for Linux! Features Small memory usage! bust

A memory profiler for Linux.
A memory profiler for Linux.

Bytehound - a memory profiler for Linux Features Can be used to analyze memory leaks, see where exactly the memory is being consumed, identify tempora

messloc is a drop in replacement for malloc that can transparently recover from memory fragmentation without any changes to application code.
messloc is a drop in replacement for malloc that can transparently recover from memory fragmentation without any changes to application code.

messloc is a drop in replacement for malloc that can transparently recover from memory fragmentation without any changes to application code. Goals Al

Allocscope  -  a memory tracking tool
Allocscope - a memory tracking tool

allocscope a memory tracking tool allocscope is a tool for tracking down where the most egregiously large allocations are occurring in a C, C++ or Rus

A library to compile USDT probes into a Rust library
A library to compile USDT probes into a Rust library

sonde sonde is a library to compile USDT probes into a Rust library, and to generate a friendly Rust idiomatic API around it. Userland Statically Defi

A Diablo II library for core and simple client functionality, written in Rust for performance, safety and re-usability

A Diablo II library for core and simple client functionality, written in Rust for performance, safety and re-usability

Releases(v0.2.3)
Owner
Madison Barry
Greater Vancouver area web developer. Video games enthusiast. Looking to build something fantastic together.
Madison Barry
This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to the arrow format.

Arrow2-derive - derive for Arrow2 This crate allows writing a struct in Rust and have it derive a struct of arrays layed out in memory according to th

Jorge Leitao 29 Dec 27, 2022
A Rust utility library, making easier by taking the hassle out of working. :octocat:

reddish A Rust utility library, making easier by taking the hassle out of working. Usage Add this to your Cargo.toml: [dependencies] reddish = "0.2.0"

Rogério Araújo 12 Jan 21, 2023
A simple wrapper for the detour-rs library that makes making hooks much more concise

A simple wrapper for the detour-rs library that makes making hooks much more concise

Khangaroo 6 Jun 21, 2022
Bolt is a desktop application that is designed to make the process of developing and testing APIs easier and more efficient.

Bolt ⚡ Bolt is a desktop application that is designed to make the process of developing and testing APIs easier and more efficient. Quick start ??‍??

0xHiro 6 Mar 26, 2023
Rust crate for reading SER files used in astrophotography

Rust crate for reading SER files used in astrophotography.

Andy Grove 2 Oct 4, 2021
A low-ish level tool for easily writing and hosting WASM based plugins.

A low-ish level tool for easily writing and hosting WASM based plugins. The goal of wasm_plugin is to make communicating across the host-plugin bounda

Alec Deason 62 Sep 20, 2022
A Rust macro for writing regex pattern matching.

regexm A Rust macro for writing regex pattern matching.

Takayuki Maeda 46 Oct 24, 2022
hado-rshado — A little macro for writing haskell-like do expressions without too much ceremony

hado Monadic haskell-like expressions brought to rust via the hado! macro What? A little macro for writing haskell-like do expressions without too muc

Lucas David Traverso 44 Jul 31, 2022
High-performance QEMU memory and instruction tracing

Cannoli Cannoli is a high-performance tracing engine for qemu-user. It can record a trace of both PCs executed, as well as memory operations. It consi

Margin Research 412 Oct 18, 2023
Rust binding of fortran Limited memory LBFGS subroutine

lbfgs-sys Rust binding of fortran L-BFGS-B subroutine. The orginal fortran subroutine is distributed under BSD-3 license. To know more about the condi

Naushad Karim 10 Sep 23, 2022