lots done
This commit is contained in:
parent
1ba7c39c30
commit
fbd0ba445a
59 changed files with 6074 additions and 3598 deletions
35
src/Automata.Memory/MemoryContext.cs
Normal file
35
src/Automata.Memory/MemoryContext.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
namespace Automata.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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue