SimpleMem 1.3.5
dotnet add package SimpleMem --version 1.3.5
NuGet\Install-Package SimpleMem -Version 1.3.5
<PackageReference Include="SimpleMem" Version="1.3.5" />
paket add SimpleMem --version 1.3.5
#r "nuget: SimpleMem, 1.3.5"
// Install SimpleMem as a Cake Addin #addin nuget:?package=SimpleMem&version=1.3.5 // Install SimpleMem as a Cake Tool #tool nuget:?package=SimpleMem&version=1.3.5
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
- ⚠️ SimpleMem only runs on Windows.
- Install the NuGet package
- Install the .NET 6 SDK (if needed)
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
module, if present in the Process.Modules
list. Unity games do not
work with SimpleMem due to mono.dll
being external to the process.
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
// Or, specify a module too. This module must exist within
// the process's "Modules" property (a ProcessModuleCollection object).
// See https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processmodulecollection?view=net-6.0
var mem = new Memory("MyGame", "mydll.dll");
To read the value located at a pointer in memory, create a pointer to the address and call ReadMemory()
or ReadMemory<T>()
.
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
- make sure this is specified upon construction of Memory
.
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,
as seen in Cheat Engine. 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" data structure base address.
public const int PlayerBase = 0x74DF02;
// Offsets to locate desired value - "health" which is a float (in this example).
// PlayerBase and 0x4 are both pointers in memory.
// 0xC is the offset at which our health float lays from the previous pointer.
public static readonly MultiLevelPtr<float> PlayerHealth = new MultiLevelPtr<int>(PlayerBase, 0x4, 0xC);
}
public class Main
{
private readonly Memory _mem;
public Main()
{
// Don't specify .exe here
_mem = new Memory("MyGame");
}
void ReadValueFromPointerChain()
{
// Traditional read
int desiredValue = _mem.ReadValueFromMlPtr<int>(Offsets.PlayerHealth);
// Using extensions
int desiredValue = Offsets.PlayerHealth.Value(_mem);
// Work with the value below...
}
void WriteValueToPointerChain()
{
// Assumes address at the end of the pointer chain is int.
// This should be known by the programmer already.
int newValue = 500;
// Traditional write
int address = _mem.ReadAddressFromMlPtr(Offsets.PlayerHealth);
_mem.WriteMemory(address, newValue);
// Using extensions
Offsets.PlayerHealth.WriteValue(_mem, newValue);
}
}
Product | Versions 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. |
-
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.
Memory extensions, MultiLevelPtr write extensions