Table of Contents

Struct ObjectHandle

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

Represents an address to an object (including its object header) within a CIL virtual machine.

public readonly struct ObjectHandle : IEquatable<ObjectHandle>
Implements
Inherited Members

Constructors

ObjectHandle(CilVirtualMachine, long)

Creates a new object handle from the provided address.

public ObjectHandle(CilVirtualMachine machine, long address)

Parameters

machine CilVirtualMachine

The machine the address is valid in.

address long

The address.

Properties

Address

Gets the address to the beginning of the object.

public long Address { get; }

Property Value

long

Contents

Gets the address to the beginning of the object's data.

public StructHandle Contents { get; }

Property Value

StructHandle

IsNull

Gets a value indicating whether this handle represents the null reference.

public bool IsNull { get; }

Property Value

bool

Machine

Gets the machine the object lives in.

public CilVirtualMachine? Machine { get; }

Property Value

CilVirtualMachine

Methods

Equals(ObjectHandle)

public bool Equals(ObjectHandle other)

Parameters

other ObjectHandle

Returns

bool

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetArrayElementAddress(TypeSignature, long)

Interprets the handle as an array reference, and obtains the address of the provided element by its index.

public long GetArrayElementAddress(TypeSignature elementType, long index)

Parameters

elementType TypeSignature

The type of elements the array stores.

index long

The index of the element.

Returns

long

The address of the element.

GetFieldAddress(IFieldDescriptor)

Obtains the absolute address of a field within the object.

public long GetFieldAddress(IFieldDescriptor field)

Parameters

field IFieldDescriptor

The field to obtain the address for.

Returns

long

The address.

GetHashCode()

public override int GetHashCode()

Returns

int

GetMemoryLayout()

Obtains the object's data memory layout.

public TypeMemoryLayout GetMemoryLayout()

Returns

TypeMemoryLayout

The memory layout.

GetObjectType()

Gets the object's type (or method table).

public ITypeDescriptor GetObjectType()

Returns

ITypeDescriptor

The type.

ReadArrayData()

Interprets the handle as an array reference, and obtains all elements of the array as one continuous buffer of bytes.

public BitVector ReadArrayData()

Returns

BitVector

The raw array data.

Exceptions

ArgumentException

Occurs when the array has an unknown length.

ReadArrayData(BitVectorSpan)

Interprets the handle as an array reference, and obtains all elements of the array as one continuous buffer of bytes.

public void ReadArrayData(BitVectorSpan buffer)

Parameters

buffer BitVectorSpan

The buffer to copy the array data into.

ReadArrayData(BitVectorSpan, int)

Interprets the handle as an array reference, and obtains all elements of the array as one continuous buffer of bytes.

public void ReadArrayData(BitVectorSpan buffer, int startIndex)

Parameters

buffer BitVectorSpan

The buffer to copy the array data into.

startIndex int

The start index to read from.

ReadArrayData(BitVectorSpan, int, TypeSignature)

Interprets the handle as an array reference, and obtains all elements of the array as one continuous buffer of bytes.

public void ReadArrayData(BitVectorSpan buffer, int startIndex, TypeSignature elementType)

Parameters

buffer BitVectorSpan

The buffer to copy the array data into.

startIndex int

The start index to read from.

elementType TypeSignature

The element type to assume.

ReadArrayData(int, int)

Interprets the handle as an array reference, and obtains all elements of the array as one continuous buffer of bytes.

public BitVector ReadArrayData(int startIndex, int length)

Parameters

startIndex int

The index to start reading from.

length int

The number of elements to read.

Returns

BitVector

The raw array data.

Exceptions

ArgumentException

Occurs when the array has an unknown length.

ReadArrayElement(TypeSignature, long)

Interprets the handle as an array reference, and reads an element by its index.

public BitVector ReadArrayElement(TypeSignature elementType, long index)

Parameters

elementType TypeSignature

The type of elements the array stores.

index long

The index of the element.

Returns

BitVector

The bits of the element.

ReadArrayElement(TypeSignature, long, BitVectorSpan)

Interprets the handle as an array reference, and reads an element by its index.

public void ReadArrayElement(TypeSignature elementType, long index, BitVectorSpan buffer)

Parameters

elementType TypeSignature

The type of elements the array stores.

index long

The index of the element.

buffer BitVectorSpan

The buffer to write the bits of the element into.

ReadArrayLength()

Interprets the handle as an array reference, and obtains the length of the contained array.

public BitVector ReadArrayLength()

Returns

BitVector

The bits representing the length of the array.

ReadArrayLength(BitVectorSpan)

Interprets the handle as an array reference, and obtains the length of the contained array.

public void ReadArrayLength(BitVectorSpan buffer)

Parameters

buffer BitVectorSpan

The buffer to copy the length bits into.

ReadField(IFieldDescriptor)

Copies the value of a field into a new bit vector.

public BitVector ReadField(IFieldDescriptor field)

Parameters

field IFieldDescriptor

The field to obtain the value for.

Returns

BitVector

The value.

ReadField(IFieldDescriptor, BitVectorSpan)

Copies the value of a field into a bit vector.

public void ReadField(IFieldDescriptor field, BitVectorSpan buffer)

Parameters

field IFieldDescriptor

The field to obtain the value for.

buffer BitVectorSpan

The buffer to copy the value into.

ReadObjectData()

Reads the data stored in the object (excluding the object header), and stores it in a bit vector.

public BitVector ReadObjectData()

Returns

BitVector

The object's data.

ReadObjectData(TypeSignature)

Reads the data stored in the object (excluding the object header), and stores it in a bit vector.

public BitVector ReadObjectData(TypeSignature type)

Parameters

type TypeSignature

The type to interpret the object as.

Returns

BitVector

The object's data.

ReadObjectData(BitVectorSpan)

Reads the data stored in the object (excluding the object header), and stores it in a bit vector.

public void ReadObjectData(BitVectorSpan buffer)

Parameters

buffer BitVectorSpan

The buffer to write the data to.

ReadStringData()

Interprets the handle as a string handle, and obtains the bits that make up the characters of the string.

public BitVector ReadStringData()

Returns

BitVector

The bit vector containing the string's characters.

Exceptions

ArgumentException

Occurs when the string has an unknown length.

ReadStringLength()

Interprets the handle as a string handle, and obtains the length of the contained string.

public BitVector ReadStringLength()

Returns

BitVector

The length.

ReadStringLength(BitVectorSpan)

Interprets the handle as a string handle, and obtains the length of the contained string.

public void ReadStringLength(BitVectorSpan buffer)

Parameters

buffer BitVectorSpan

The buffer to copy the length bits into.

ToString()

public override string ToString()

Returns

string

WriteArrayData(BitVectorSpan)

Interprets the handle as an array reference, and writes elements to the array's data as one continuous buffer of bytes.

public void WriteArrayData(BitVectorSpan buffer)

Parameters

buffer BitVectorSpan

The buffer to copy the array data from.

WriteArrayData(ReadOnlySpan<byte>)

Interprets the handle as an array reference, and writes elements to the array's data as one continuous buffer of bytes.

public void WriteArrayData(ReadOnlySpan<byte> buffer)

Parameters

buffer ReadOnlySpan<byte>

The buffer to copy the array data from.

WriteArrayElement(TypeSignature, long, BitVectorSpan)

Interprets the handle as an array reference, and writes a value to an element by its index.

public void WriteArrayElement(TypeSignature elementType, long index, BitVectorSpan buffer)

Parameters

elementType TypeSignature

The type of elements the array stores.

index long

The index of the element.

buffer BitVectorSpan

The bits of the element to write to the element.

WriteField(IFieldDescriptor, BitVectorSpan)

Copies the provided bit vector into a field of the object.

public void WriteField(IFieldDescriptor field, BitVectorSpan buffer)

Parameters

field IFieldDescriptor

The field to write to.

buffer BitVectorSpan

The bits to write.