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
machineCilVirtualMachineThe machine the address is valid in.
addresslongThe address.
Properties
Address
Gets the address to the beginning of the object.
public long Address { get; }
Property Value
Contents
Gets the address to the beginning of the object's data.
public StructHandle Contents { get; }
Property Value
IsNull
Gets a value indicating whether this handle represents the null reference.
public bool IsNull { get; }
Property Value
Machine
Gets the machine the object lives in.
public CilVirtualMachine? Machine { get; }
Property Value
Methods
Equals(ObjectHandle)
public bool Equals(ObjectHandle other)
Parameters
otherObjectHandle
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
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
elementTypeTypeSignatureThe type of elements the array stores.
indexlongThe 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
fieldIFieldDescriptorThe field to obtain the address for.
Returns
- long
The address.
GetHashCode()
public override int GetHashCode()
Returns
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
bufferBitVectorSpanThe 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
bufferBitVectorSpanThe buffer to copy the array data into.
startIndexintThe 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
bufferBitVectorSpanThe buffer to copy the array data into.
startIndexintThe start index to read from.
elementTypeTypeSignatureThe 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
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
elementTypeTypeSignatureThe type of elements the array stores.
indexlongThe 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
elementTypeTypeSignatureThe type of elements the array stores.
indexlongThe index of the element.
bufferBitVectorSpanThe 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
bufferBitVectorSpanThe 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
fieldIFieldDescriptorThe 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
fieldIFieldDescriptorThe field to obtain the value for.
bufferBitVectorSpanThe 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
typeTypeSignatureThe 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
bufferBitVectorSpanThe 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
bufferBitVectorSpanThe buffer to copy the length bits into.
ToString()
public override string ToString()
Returns
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
bufferBitVectorSpanThe 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
bufferReadOnlySpan<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
elementTypeTypeSignatureThe type of elements the array stores.
indexlongThe index of the element.
bufferBitVectorSpanThe 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
fieldIFieldDescriptorThe field to write to.
bufferBitVectorSpanThe bits to write.