TheLeftExit.Memory 3.5.0

Install-Package TheLeftExit.Memory -Version 3.5.0
dotnet add package TheLeftExit.Memory --version 3.5.0
<PackageReference Include="TheLeftExit.Memory" Version="3.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TheLeftExit.Memory --version 3.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TheLeftExit.Memory, 3.5.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install TheLeftExit.Memory as a Cake Addin
#addin nuget:?package=TheLeftExit.Memory&version=3.5.0

// Install TheLeftExit.Memory as a Cake Tool
#tool nuget:?package=TheLeftExit.Memory&version=3.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

TheLeftExit.Memory

One of the many libraries focused on reading process memory.

TheLeftExit.Memory is designed to be compact, fast and extremely memory-efficient, making extensive use of unsafe context.

Available as a NuGet package.

Main features

MemorySource

An abstract class that allows wrapping remote memory sources for generic reading and writing:

public class MemorySource {
    public T Read<T>(ulong address) where T : unmanaged;
    public bool TryRead<T>(ulong address, out T result) where T : unmanaged;
    public bool TryRead<T>(ulong address, Span<T> buffer) where T : unmanaged;
    public bool TryRead(ulong address, int count, void* buffer);
    protected abstract bool TryReadCore(ulong address, int count, void* buffer);
    public virtual bool AllowRead { get; }

    public void Write(ulong address, T value) where T : unmanaged;
    public bool TryWrite<T>(ulong address, T value) where T : unmanaged;
    public bool TryWrite<T>(ulong address, Span<T> buffer) where T : unmanaged;
    public bool TryWrite(ulong address, int count, void* buffer);
    protected abstract bool TryWriteCore(ulong address, int count, void* buffer);
    public virtual bool AllowWrite { get; }
}
ProcessMemory

A MemorySource over a process that allows you to read its memory.

public partial class ProcessMemory : MemorySource, IDisposable {
    public readonly uint Id;
    public readonly uint ProcessAccessRights;
    public readonly bool InheritHandle;


    public readonly IntPtr Handle;
    public readonly bool Is32Bit;

    public readonly ulong BaseAddress;
    public readonly uint MainModuleSize;

    public unsafe ProcessMemory(Process process, [uint rights], [bool inheritHandle]);
    public unsafe ProcessMemory(int ProcessId, [uint rights], [bool inheritHandle]);

    public RemoteStructure Root { get; }
    public Dictionary<(string, string, bool), int> Offsets { get; }
RemoteStructure

A node in a structure hierarchy of a remote process. Allows you to easily branch between structures by scanning and caching offsets based on structure names. Works on MSVC RTTI (using methods from the static RTTI class.

    public struct RemoteStructure : IRemoteStructure {
    public readonly ProcessMemory Source;
    public readonly ulong Address;
    public readonly string Name;

    public T Read<T>(int offset) where T : unmanaged;
    public void Write<T>(int offset, T value) where T : unmanaged;

    public RemoteStructure this[int offset, [bool byRef], [string name]] { get; }
    public RemoteStructure this[string className, [bool byRef]] { get; }
}

There might be more stuff, but it's mostly specific to my needs and/or too bothersome to document.

I often update this project as a I come up with more efficient ways to achieve its functionality, so expect breaking changes with most new versions.

  • net5.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
3.5.0 137 10/25/2021
3.4.0 62 10/23/2021
3.3.2 148 10/17/2021
3.3.1 129 10/16/2021
3.3.0 86 10/14/2021
3.2.0 158 10/10/2021
3.1.0 243 10/7/2021
3.0.1 120 9/25/2021
3.0.0 113 9/25/2021
2.0.0 183 7/27/2021
1.0.0 196 6/13/2021