SimpleMem 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleMem --version 1.0.1
NuGet\Install-Package SimpleMem -Version 1.0.1
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.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleMem --version 1.0.1
#r "nuget: SimpleMem, 1.0.1"
#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.0.1

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

SimpleMem

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

Prerequisites

  • ⚠️ SimpleMem only runs on Windows.
  • ⚠️ Support for manipulating memory in 64-bit processes will be coming in a later update.
  • Download the NuGet package
  • Download the .NET 6 SDK (if needed)

Getting Started

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.ListProcesses();

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.

Reading and Writing Memory

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

Open the application, in this case MyGame.exe.

Reading Memory

Create a new Memory32 or Memory64 (coming soon) object, depending on the architecture of the application. Say the address in question is 0x1234 and is an Int32. To read this value, we simply call .ReadMemoryInt32() on it.

const Int32 ADDRESS = 0x1234; // Address to write to

var mem = new Memory32("MyGame"); // Your process name here
int readValue = mem.ReadMemoryInt32(ADDRESS);

The same process can be applied for any type supported in Memory32's other methods.

Writing Memory

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

const Int32 ADDRESS = 0x1234; // Address to write to
const int NEW_VALUE = 500;

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

It's that easy!

Pointer Chains

Known more popularly as multi-level pointers, SimpleMem provides full support for reading addresses and values from base addresses and offsets - it couldn't be easier!

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.

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 (32-bit). Process is identical for 64-bit (coming soon)

static class Offsets
{
    public const Int32 Base = 0x74DF02;

    // Offsets to locate desired value
    public static Int32[] DesiredValueOffsets = new Int32[] { Base, 0x04, 0x28 };
}

public class Main
{
    private readonly Memory32Chain _mem;

    public Main()
    {
        _mem = new Memory32Chain("MyGame", "MyGame.exe");
    }

    // Reads value from the address resulting from the pointer chain
    void ReadValueFromPointerChain()
    {
        int desiredValue = _mem.GetInt32FromPointerChain(Offsets.DesiredValueOffsets);
        // etc...
    }

    // Writes value to the address resulting from the pointer chain
    void WriteValueToPointerChain()
    {
        // Assumes address at the end of the pointer chain is Int32.
        // This should be known by the programmer already.
        int newValue = 500;
        Int32 address = _mem.GetAddressFromPointerChain();
        
        _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.)
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 492 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