TheLeftExit.Memory 4.0.0

dotnet add package TheLeftExit.Memory --version 4.0.0
NuGet\Install-Package TheLeftExit.Memory -Version 4.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="TheLeftExit.Memory" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TheLeftExit.Memory --version 4.0.0
#r "nuget: TheLeftExit.Memory, 4.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.
// Install TheLeftExit.Memory as a Cake Addin
#addin nuget:?package=TheLeftExit.Memory&version=4.0.0

// Install TheLeftExit.Memory as a Cake Tool
#tool nuget:?package=TheLeftExit.Memory&version=4.0.0

TheLeftExit.Memory

One of the many libraries focused on reading process memory.

TheLeftExit.Memory is designed to be compact, fast and extremely memory-efficient by means of unsafe context.

Available as a NuGet package targeting .NET Standard 2.0.

Main features

MemorySource

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

public abstract class MemorySource {
    public abstract bool TryRead(nuint address, nuint count, void* buffer);
    public abstract bool TryWrite(nuint address, nuint count, void* buffer);

    public bool TryWrite<T>(nuint address, Span<T> buffer) where T : unmanaged;
    public bool TryRead<T>(nuint address, Span<T> buffer) where T : unmanaged;

    public bool TryRead<T>(nuint address, out T result) where T : unmanaged;
    public T Read<T>(nuint address) where T : unmanaged;

    public bool TryWrite<T>(nuint address, T value) where T : unmanaged;
    public void Write<T>(nuint address, T value) where T : unmanaged;

    public bool TryWrite<T>(nuint address, in T value) where T : unmanaged;
    public void Write<T>(nuint address, in T value) where T : unmanaged;
}
ProcessMemory

A MemorySource over a process that allows you to read its memory using ReadProcessMemory/WriteProcessMemory API.

The HANDLE structure encapsulates a process handle represented by an IntPtr value and exposes certain native API methods.

public class ProcessMemory : MemorySource {
    public HANDLE Handle { get; }
    public ProcessMemory(HANDLE handle);
}

public readonly struct HANDLE {
    public readonly IntPtr Value;

    public HANDLE(IntPtr value);
    public static implicit operator IntPtr(HANDLE handle);
    public static implicit operator HANDLE(IntPtr value);

    public static HANDLE OpenProcess(uint dwProcessId);
    public static HANDLE OpenProcess(PROCESS_ACCESS_RIGHTS dwDesiredAccess, bool bInheritHandle, uint dwProcessId);

    public bool ReadProcessMemory(void* lpBaseAddress, void* lpBuffer, nuint nSize, out nuint lpNumberOfBytesRead);
    public bool WriteProcessMemory(void* lpBaseAddress, void* lpBuffer, nuint nSize, out nuint lpNumberOfBytesWritten);

    public bool? IsWow64Process();
    public bool CloseHandle();
    public uint GetProcessId();
    public nuint GetBaseAddress();
}
RttiExtensions

Methods that can be used to retrieve RTTI class names in MSVC application memory.

public static class RttiExtensions {
    public static string GetClassName64(this MemorySource source, nuint address, PointerDepth depth);
    public static string GetClassName32(this MemorySource source, nuint address, PointerDepth depth);
}

public enum PointerDepth {
    VTable = 0,
    Instance = 1,
    Reference = 2
}

Implementing more robust or fluent structures based on those primitives is up to end-user, as the implementation and API may differ greatly depending on the usage scenario.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
4.0.0 444 1/21/2022
3.5.0 396 10/25/2021
3.4.0 267 10/23/2021
3.3.2 348 10/17/2021
3.3.1 317 10/16/2021
3.3.0 292 10/14/2021
3.2.0 348 10/10/2021
3.1.0 473 10/7/2021
3.0.1 315 9/25/2021
3.0.0 316 9/25/2021
2.0.0 445 7/27/2021
1.0.0 461 6/13/2021