EonaCat.MemoryManager 1.0.0

Prefix Reserved
dotnet add package EonaCat.MemoryManager --version 1.0.0
                    
NuGet\Install-Package EonaCat.MemoryManager -Version 1.0.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="EonaCat.MemoryManager" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EonaCat.MemoryManager" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="EonaCat.MemoryManager" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EonaCat.MemoryManager --version 1.0.0
                    
#r "nuget: EonaCat.MemoryManager, 1.0.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.
#:package EonaCat.MemoryManager@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EonaCat.MemoryManager&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=EonaCat.MemoryManager&version=1.0.0
                    
Install as a Cake Tool

EonaCat.MemoryManager

Process and Memory Management Library for .NET using EonaCat.MemoryManager.

Example Usage:
var procManager = new ProcessManager();

// Attach to process (e.g. "notepad")
string targetProcess = "notepad";
if (!procManager.Attach(targetProcess))
{
    Console.WriteLine($"Failed to attach to {targetProcess}.");
    return;
}
Console.WriteLine($"Attached to {targetProcess} (PID {procManager.Process.Id})");

var memManager = new MemoryManager(procManager.ProcessHandle);

IntPtr baseAddress = procManager.GetModuleBaseAddress(targetProcess + ".exe");
Console.WriteLine($"Base address: 0x{baseAddress.ToInt64():X}");

// Example offsets for pointer chaining (replace with real offsets)
int[] offsets = { 0x10, 0x20, 0x8 };
IntPtr pointerAddress = memManager.ReadPointer(baseAddress, offsets);
Console.WriteLine($"Pointer resolved to: 0x{pointerAddress.ToInt64():X}");

// --- 1. Read/Write unmanaged primitive (int) ---
int intVal = memManager.ReadValue<int>(pointerAddress);
Console.WriteLine($"Read int: {intVal}");

memManager.WriteValue(pointerAddress, 9999);
Console.WriteLine("Wrote int: 9999");

// --- 2. Read/Write managed struct ---
var vec3 = memManager.ReadStruct<Vector3>(pointerAddress);
Console.WriteLine($"Read Vector3: X={vec3.X}, Y={vec3.Y}, Z={vec3.Z}");

var newVec = new Vector3 { X = 1.1f, Y = 2.2f, Z = 3.3f };
memManager.WriteStruct(pointerAddress, newVec);
Console.WriteLine("Wrote new Vector3");

// --- 3. Read/Write strings ---
string asciiStr = memManager.ReadStringAscii(pointerAddress, 50);
Console.WriteLine($"Read ASCII string: {asciiStr}");

memManager.WriteStringAscii(pointerAddress, "Hello ASCII!");
Console.WriteLine("Wrote ASCII string: Hello ASCII!");

string unicodeStr = memManager.ReadStringUnicode(pointerAddress, 50);
Console.WriteLine($"Read Unicode string: {unicodeStr}");

memManager.WriteStringUnicode(pointerAddress, "Hello Unicode!");
Console.WriteLine("Wrote Unicode string: Hello Unicode!");

// --- 4. Read/Write array of floats ---
float[] floatArray = memManager.ReadArray<float>(pointerAddress, 5);
Console.WriteLine("Read float array:");
foreach (var f in floatArray) Console.WriteLine(f);

float[] newArray = { 9.9f, 8.8f, 7.7f, 6.6f, 5.5f };
memManager.WriteArray(pointerAddress, newArray);
Console.WriteLine("Wrote float array");

// --- 5. Non-generic Read/Write ---
object objVal = memManager.ReadValue(pointerAddress, typeof(Vector3));
Vector3 vecFromObj = (Vector3)objVal;
Console.WriteLine($"Non-generic read Vector3: X={vecFromObj.X}, Y={vecFromObj.Y}, Z={vecFromObj.Z}");

memManager.WriteValue(pointerAddress, newVec, typeof(Vector3));
Console.WriteLine("Non-generic wrote Vector3");

// Cleanup
procManager.Detach();
Console.WriteLine("Detached from process.");
}

// Example struct (must match memory layout)
[StructLayout(LayoutKind.Sequential)]
public class Vector3
{
public float X;
public float Y;
public float Z;
}
Notes:

Run your target process (e.g., Notepad).

Adjust the targetProcess variable to match your process name.

Replace the pointer offsets with valid ones for your target process.

Adjust the read/write addresses or pattern scan results accordingly.

This example covers:

Unmanaged primitive read/write (int)

Managed struct read/write (Vector3 class)

ASCII and Unicode string read/write

Array of unmanaged types (float) read/write

Non-generic object-based read/write

Product Compatible and additional computed target framework versions.
.NET net8.0-windows7.0 is compatible.  net9.0-windows was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.0.0 126 6/29/2025