35 lines
1 KiB
C#
35 lines
1 KiB
C#
namespace Roboto.Memory;
|
|
|
|
/// <summary>
|
|
/// Shared state for all memory reader classes. Holds the process handle, offsets, registry,
|
|
/// and resolved module/GameState base addresses.
|
|
/// </summary>
|
|
public sealed class MemoryContext
|
|
{
|
|
public ProcessMemory Memory { get; }
|
|
public GameOffsets Offsets { get; }
|
|
public ObjectRegistry Registry { get; }
|
|
public nint ModuleBase { get; set; }
|
|
public int ModuleSize { get; set; }
|
|
public nint GameStateBase { get; set; }
|
|
|
|
public MemoryContext(ProcessMemory memory, GameOffsets offsets, ObjectRegistry registry)
|
|
{
|
|
Memory = memory;
|
|
Offsets = offsets;
|
|
Registry = registry;
|
|
}
|
|
|
|
public bool IsModuleAddress(nint value)
|
|
{
|
|
return ModuleBase != 0 && ModuleSize > 0 &&
|
|
value >= ModuleBase && value < ModuleBase + ModuleSize;
|
|
}
|
|
|
|
public bool IsValidHeapPtr(nint ptr)
|
|
{
|
|
if (ptr == 0) return false;
|
|
var high = (ulong)ptr >> 32;
|
|
return high > 0 && high < 0x7FFF && (ptr & 0x3) == 0;
|
|
}
|
|
}
|