Class ObjectMapMemory
- Namespace
- Echo.Platforms.AsmResolver.Emulation.Heap
- Assembly
- Echo.Platforms.AsmResolver.dll
Provides a memory space for hosting managed objects within memory of a virtual machine.
public class ObjectMapMemory : IMemorySpace
- Inheritance
-
ObjectMapMemory
- Implements
- Inherited Members
Constructors
ObjectMapMemory(CilVirtualMachine, long)
Creates a new object mapping host memory space.
public ObjectMapMemory(CilVirtualMachine machine, long size)
Parameters
machineCilVirtualMachineThe machine the memory is associated with.
sizelongThe maximum size of the memory.
Properties
AddressRange
Gets the range that this memory space spans.
public AddressRange AddressRange { get; }
Property Value
Methods
Clear()
Unmaps all registered objects from the host memory.
public void Clear()
GetOrCreateMapping(object?)
Gets or creates a new address mapping for the provided object.
public MappedObject? GetOrCreateMapping(object? value)
Parameters
valueobjectThe object to embed into the machine.
Returns
- MappedObject
The mapped object.
IsValidAddress(long)
Gets a value indicating whether the provided address is a valid address, and can be used to read and/or write to.
public bool IsValidAddress(long address)
Parameters
addresslongThe address to query.
Returns
- bool
trueif the address was valid,falseotherwise.
Read(long, BitVectorSpan)
Copies data at the provided address into the provided buffer.
public void Read(long address, BitVectorSpan buffer)
Parameters
addresslongThe address to start reading at.
bufferBitVectorSpanThe buffer to write into.
Rebase(long)
Relocates the memory to a new base address.
public void Rebase(long baseAddress)
Parameters
baseAddresslongThe new base address.
TryGetObject(long, out MappedObject?)
Attempts to obtain the managed object mapping by its address.
public bool TryGetObject(long address, out MappedObject? map)
Parameters
addresslongThe address of the mapped object.
mapMappedObjectThe obtained mapped object.
Returns
- bool
trueif the object was found,falseotherwise.
Unmap(object)
Unmaps a registered object from the host memory.
public void Unmap(object value)
Parameters
valueobjectThe object to unmap.
Write(long, BitVectorSpan)
Writes the provided buffer of data at the provided address.
public void Write(long address, BitVectorSpan buffer)
Parameters
addresslongThe address to start writing at.
bufferBitVectorSpanThe data to write.
Write(long, ReadOnlySpan<byte>)
Writes the provided buffer of data at the provided address.
public void Write(long address, ReadOnlySpan<byte> buffer)
Parameters
addresslongThe address to start writing at.
bufferReadOnlySpan<byte>The data to write.