Skip to main content
This guide will help you get started with libmem quickly. Choose your preferred language and follow along.

Your First Program

libmem provides powerful memory manipulation capabilities for both internal (same process) and external (different process) operations. Let’s start with a simple example.
This example disassembles the main function until a ret instruction is found.
/* C++20 or higher */
#include <libmem/libmem.hpp>
#include <iostream>

using namespace libmem;

int main()
{
    Address disas_addr = reinterpret_cast<Address>(main);

    // Disassemble function 'main' until a 'ret' is found
    for (;;) {
        auto inst = Disassemble(disas_addr).value();
        std::cout << inst.to_string() << std::endl;
        if (inst.mnemonic == "ret")
            break;
        disas_addr += inst.bytes.size();
    }

    return 0;
}

/*
Output:
0x55b1a3259275: push rbp -> [ 55 ]
0x55b1a3259276: mov rbp, rsp -> [ 48 89 e5 ]
...
0x55b1a325941a: leave  -> [ c9 ]
0x55b1a325941b: ret  -> [ c3 ]
*/
Compile and link:
g++ -std=c++20 main.cpp -llibmem -o myprogram

Common Operations

Here are some common operations you’ll perform with libmem:

Finding Processes and Modules

#include <libmem/libmem.hpp>
using namespace libmem;

// Find a process by name
auto proc = FindProcess("game.exe");

// Find a module in the current process
auto mod = FindModule("client.dll");

// Find a module in a remote process
auto remote_mod = FindModule(&proc.value(), "engine.dll");

Reading and Writing Memory

// Read memory
int value = ReadMemory<int>(address);

// Write memory
WriteMemory(address, 1337);

// Read from remote process
auto remote_value = ReadMemory<int>(&process, address);

// Write to remote process
WriteMemory(&process, address, 9001);

Scanning for Patterns

// Signature scan
auto result = SigScan("DE AD ?? BE EF", start_addr, scan_size);

// Signature scan in remote process
auto remote_result = SigScan(&process, "48 89 5C 24 ?? 57", start_addr, scan_size);

Usage Guidelines

C/C++ Projects

Include the appropriate header:
#include <libmem/libmem.h>   /* C/C++ */
#include <libmem/libmem.hpp> /* Modern C++ (C++20+) */
Link against libmem:
  • GCC-like compilers: Add -llibmem to your compiler flags
  • Windows: Link libmem.lib (static) or libmem.dll (dynamic)
  • Unix-like: Link liblibmem.so (shared) or liblibmem.a (static)

Python Projects

Simply import libmem:
from libmem import *

Rust Projects

Add to Cargo.toml and import:
[dependencies]
libmem = "5"
use libmem::*;

What’s Next?

Now that you have libmem set up and running, explore the full capabilities:
  • Process & Thread APIs - Enumerate and manage processes and threads
  • Module APIs - Load, unload, and enumerate modules
  • Memory APIs - Read, write, allocate, and protect memory
  • Scanning APIs - Pattern scanning and signature matching
  • Hooking APIs - Function hooking and VMT hooking
  • Assembly APIs - Assemble and disassemble code on-the-fly
Check out the API Reference for detailed documentation of all available functions.

Build docs developers (and LLMs) love