Table of Contents

Class ManagedObjectHeap

Namespace
Echo.Platforms.AsmResolver.Emulation.Heap
Assembly
Echo.Platforms.AsmResolver.dll

Represents a heap of managed objects.

public class ManagedObjectHeap : IMemorySpace
Inheritance
ManagedObjectHeap
Implements
Inherited Members

Constructors

ManagedObjectHeap(IHeap, ValueFactory)

Creates a new empty heap for managed objects.

public ManagedObjectHeap(IHeap backingHeap, ValueFactory factory)

Parameters

backingHeap IHeap

The backing heap to use for allocating raw memory.

factory ValueFactory

The object responsible for managing type information.

ManagedObjectHeap(int, ValueFactory)

Creates a new empty heap for managed objects.

public ManagedObjectHeap(int size, ValueFactory factory)

Parameters

size int

The maximum size the heap can grow.

factory ValueFactory

The object responsible for managing type information.

Properties

AddressRange

Gets the range that this memory space spans.

public AddressRange AddressRange { get; }

Property Value

AddressRange

Methods

AllocateFlat(uint, bool)

Allocates flat unmanaged memory in the heap (i.e., without any object header).

public long AllocateFlat(uint size, bool initialize)

Parameters

size uint

The size in bytes of the memory region to allocate.

initialize bool

A value indicating whether the object should be initialized with zeroes.

Returns

long

The address of the memory that was allocated.

AllocateObject(ITypeDescriptor, bool)

Allocates a managed object of the provided type in the heap.

public long AllocateObject(ITypeDescriptor type, bool initialize)

Parameters

type ITypeDescriptor

The type of object to allocate.

initialize bool

A value indicating whether the object should be initialized with zeroes.

Returns

long

The address of the object that was allocated.

Exceptions

InvalidOperationException

Occurs when the provided type's size is unknown (e.g. when the type is an array or string type).

AllocateString(BitVector)

Allocates a string into the virtual managed heap.

public long AllocateString(BitVector contents)

Parameters

contents BitVector

The string data.

Returns

long

The address of the string that was allocated.

AllocateString(int, bool)

Allocates a string into the virtual managed heap.

public long AllocateString(int length, bool initialize)

Parameters

length int

The number of characters in the string.

initialize bool

A value indicating whether all characters should be initialized with zeroes.

Returns

long

The address of the string that was allocated.

AllocateString(string)

Allocates a string into the virtual managed heap.

public long AllocateString(string value)

Parameters

value string

The string literal.

Returns

long

The address of the string that was allocated.

AllocateSzArray(TypeSignature, int, bool)

Allocates a single dimension, zero-based array on the heap.

public long AllocateSzArray(TypeSignature elementType, int elementCount, bool initialize)

Parameters

elementType TypeSignature

The type of elements the array stores.

elementCount int

The number of elements in the array.

initialize bool

A value indicating whether the elements should be initialized with zeroes.

Returns

long

The address of the array that was allocated.

Free(long)

Releases an object from the heap.

public void Free(long address)

Parameters

address long

The address of the object.

GetInternedString(string)

Gets the address to an interned string in the virtual managed heap.

public long GetInternedString(string value)

Parameters

value string

The string.

Returns

long

The address of the interned string.

GetObjectRanges()

Obtains a collection of address ranges of all managed objects currently in the heap.

public IEnumerable<AddressRange> GetObjectRanges()

Returns

IEnumerable<AddressRange>

The ranges.

GetObjectSize(long)

Gets the size of the object at the provided address.

public uint GetObjectSize(long address)

Parameters

address long

The address of the object.

Returns

uint

The size in bytes.

GetObjectSpan(BitVectorSpan)

Gets a bit vector slice that spans the contents of the object at the provided address.

public BitVectorSpan GetObjectSpan(BitVectorSpan address)

Parameters

address BitVectorSpan

The address of the object.

Returns

BitVectorSpan

The object slice.

GetObjectSpan(long)

Gets a bit vector slice that spans the contents of the object at the provided address.

public BitVectorSpan GetObjectSpan(long address)

Parameters

address long

The address of the object.

Returns

BitVectorSpan

The object slice.

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

address long

The address to query.

Returns

bool

true if the address was valid, false otherwise.

Read(long, BitVectorSpan)

Copies data at the provided address into the provided buffer.

public void Read(long address, BitVectorSpan buffer)

Parameters

address long

The address to start reading at.

buffer BitVectorSpan

The buffer to write into.

Rebase(long)

Relocates the memory to a new base address.

public void Rebase(long baseAddress)

Parameters

baseAddress long

The new base address.

Write(long, BitVectorSpan)

Writes the provided buffer of data at the provided address.

public void Write(long address, BitVectorSpan buffer)

Parameters

address long

The address to start writing at.

buffer BitVectorSpan

The 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

address long

The address to start writing at.

buffer ReadOnlySpan<byte>

The data to write.