SimpleMem 1.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleMem --version 1.2.0
NuGet\Install-Package SimpleMem -Version 1.2.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleMem" Version="1.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleMem --version 1.2.0
#r "nuget: SimpleMem, 1.2.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SimpleMem as a Cake Addin
#addin nuget:?package=SimpleMem&version=1.2.0

// Install SimpleMem as a Cake Tool
#tool nuget:?package=SimpleMem&version=1.2.0

SimpleMem

<img src="logo.png"></img>

The best general-purpose memory reader/writer for C#

<img src="https://img.shields.io/nuget/v/SimpleMem"> <img src="https://img.shields.io/github/license/hburn7/SimpleMem">

Prerequisites

Getting Started

📌 Note: Manipulating memory in 64-bit applications requires your source to be compiled in x64.

If not known, find the name of the process you wish to hook into. The name found in this list that matches your target application is what we will refer to as the process name.

using SimpleMem;

// Prints all process names on your system.
Memory.PrintProcessList();

Find the name of the base module, if not known. This is typically the name of the process name and its extension, such as MyApplication.exe. This can also be a .dll .dll support is untested as of v1.1.0.

Reading and Writing Memory

📌 For all memory examples we will use a made-up game, MyGame.

Open the application, in this case MyGame.exe.

Reading Memory

Create a new Memory object.

var mem = new Memory("MyGame"); // Your process name here

To read the value located at a memory address, create a pointer to the address and call ReadMemory... on it (... changes depending on the desired return type).

const int ADDRESS = 0xABCD123; // Your address here

// Example. Assumes "points" are located at ADDRESS and are stored as an int.
int points = mem.ReadMemory<int>(new IntPtr(ADDRESS));

Writing Memory

Using the same example above, say we want to overwrite the value.

const int ADDRESS = 0xABCD123; // Your address here
const int NEW_VALUE = 500;

var mem = new Memory("MyGame"); // Your process name here
int bytesRead = mem.WriteMemory(new IntPtr(ADDRESS), NEW_VALUE); // Replaces value at ADDRESS with NEW_VALUE

It's that easy!

Multi-Level Pointers

SimpleMem provides full support for reading addresses and values from base addresses and offsets.

First, find the module name - this can easily be found via Cheat Engine. This is almost always a .exe or .dll and is known as the ModuleBaseAddress. By default, it is your application's executable.

To identify pointer chains, Cheat Engine's pointer scanner feature can be used. More info can be found here. For this example, our desired value will rest at MyGame.exe+0x74DF02 -> 0x04 -> 0x28 where -> represents a pointer from one address to the next. The value read at the end of the pointer chain (...0x28) contains our desired value.

Pointer chain example

static class Offsets
{
    // For this example, "PlayerBase" refers to some arbitrary player in a video game.
    public const int PlayerBase = 0x74DF02;

    // Offsets to locate desired value
    public static int[] PlayerHealthOffsets = new int[] { PlayerBase, 0x04, 0x28 };
}

public class Main
{
    private readonly Memory _mem;

    public Main()
    {
        // If your module is different than "MyGame.exe", specify
        _mem = new MemoryModule("MyGame");
    }

    // Reads value from the address resulting from the pointer chain
    void ReadValueFromPointerChain()
    {
        var mlPtr = new MultiLevelPtr(_mem.ModuleBaseAddress, PlayerHealthOffsets);
        int desiredValue = _mem.GetValFromMlPtr<int>(mlPtr);
        // etc...
    }

    // Writes value to the address resulting from the pointer chain
    void WriteValueToPointerChain()
    {
        // Assumes address at the end of the pointer chain is int.
        // This should be known by the programmer already.
        int newValue = 500;
        
        var mlPtr = new MultiLevelPtr(_mem.ModuleBaseAddress, PlayerHealthOffsets);
        int address = _mem.GetAddressFromMlPtr(mlPtr);
        
        _mem.WriteMemory(address, newValue);
    }
}

Remarks

  • The library does not handle any errors arising from:
    • Inability to find the process
    • Inability to read memory from the given address or offsets
    • Bad memory writes (writing to wrong address, writing bad values, etc.)
  • Strings are not currently supported
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.5 488 5/7/2022
1.3.4 387 5/6/2022
1.3.3 392 5/5/2022
1.3.2 389 5/4/2022
1.3.1 383 5/4/2022
1.3.0 392 5/4/2022
1.2.1 421 3/12/2022
1.2.0 403 3/12/2022
1.1.1 397 3/11/2022
1.1.0 391 3/11/2022
1.0.1 395 3/8/2022
1.0.0 384 3/8/2022

Memory now has support for all of MemoryModule's funcitons (MemoryModule has been removed). String support for MultiLevelPointers, generic MultiLevelPointers