Class VirtualMemory
Represents an addressable region of memory that maps a collection of memory spaces to virtual addresses.
public class VirtualMemory : IMemorySpace
- Inheritance
-
VirtualMemory
- Implements
- Inherited Members
Remarks
This class can be compared to the entire memory space of a running process.
Constructors
VirtualMemory()
Creates new uninitialized virtual memory.
public VirtualMemory()
VirtualMemory(long)
Creates new uninitialized virtual memory with the provided size.
public VirtualMemory(long size)
Parameters
sizelong
Properties
AddressRange
Gets the range that this memory space spans.
public AddressRange AddressRange { get; }
Property Value
Methods
GetMappedRanges()
Gets a collection of all ranges that were mapped into this virtual memory.
public IEnumerable<AddressRange> GetMappedRanges()
Returns
- IEnumerable<AddressRange>
The address ranges within the memory.
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.
Map(long, IMemorySpace)
Maps a memory space at the provided virtual memory address.
public void Map(long address, IMemorySpace space)
Parameters
addresslongThe address to map the data at.
spaceIMemorySpaceThe data to map.
Exceptions
- ArgumentException
Occurs when the address was already in use.
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.
Unmap(long)
Unmaps a memory space that was mapped at the provided address.
public void Unmap(long address)
Parameters
addresslongThe address of the memory space 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.