Table of Contents

Class CallFrame

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

Represents a single frame in a virtual stack.

public class CallFrame : IMemorySpace
Inheritance
CallFrame
Implements
Inherited Members

Constructors

CallFrame(IMethodDescriptor, ValueFactory)

Constructs a new call stack frame.

public CallFrame(IMethodDescriptor method, ValueFactory factory)

Parameters

method IMethodDescriptor

The method that this frame is associated with.

factory ValueFactory

A factory used for measuring the size of the frame.

Exceptions

ArgumentException

Occurs when the provided method is invalid or contains invalid metadata that could not be dealt with.

Properties

AddressRange

Gets the range that this memory space spans.

public AddressRange AddressRange { get; }

Property Value

AddressRange

Body

Gets the managed body of the method that this frame is associated with (if available).

public CilMethodBody? Body { get; }

Property Value

CilMethodBody

CanAllocateMemory

Gets a value indicating whether the frame can be extended with extra stack memory.

public bool CanAllocateMemory { get; }

Property Value

bool

ConstrainedType

Gets or sets the current type that the following call instruction is constrained by, if any.

public ITypeDescriptor? ConstrainedType { get; set; }

Property Value

ITypeDescriptor

EvaluationStack

Gets a virtual evaluation stack associated stored the frame.

public EvaluationStack EvaluationStack { get; }

Property Value

EvaluationStack

ExceptionHandlerStack

Gets the stack of currently active exception handler frames in the method.

public ExceptionHandlerStack ExceptionHandlerStack { get; }

Property Value

ExceptionHandlerStack

ExceptionHandlers

Gets a collection of exception handler frames present in the method body.

public IReadOnlyList<ExceptionHandlerFrame> ExceptionHandlers { get; }

Property Value

IReadOnlyList<ExceptionHandlerFrame>

IsRoot

Gets a value indicating the frame is the root frame of the call stack.

public bool IsRoot { get; }

Property Value

bool

IsTrampoline

Gets a value indicating that the frame is a trampoline, and that it immediately returns the value of the next method on the stack

public bool IsTrampoline { get; set; }

Property Value

bool

LocalsCount

Gets the number of locals stored in the frame.

public int LocalsCount { get; }

Property Value

int

Method

Gets the method which this frame was associated with.

public IMethodDescriptor Method { get; }

Property Value

IMethodDescriptor

ProgramCounter

Gets the offset within the method body of the next instruction to evaluate.

public int ProgramCounter { get; set; }

Property Value

int

Size

Gets the number of bytes (excluding the evaluation stack) the stack frame spans.

public int Size { get; }

Property Value

int

Methods

Allocate(int)

Allocates local stack memory in the stack frame.

public long Allocate(int size)

Parameters

size int

Returns

long

GetArgumentAddress(int)

Gets the address (relative to the start of the frame) to an argument in the frame.

public long GetArgumentAddress(int index)

Parameters

index int

The index of the argument to get the address for.

Returns

long

The address

Exceptions

ArgumentOutOfRangeException

Occurs when the argument index is invalid.

GetLocalAddress(int)

Gets the address (relative to the start of the frame) to a local variable in the frame.

public long GetLocalAddress(int index)

Parameters

index int

The index of the local variable to get the address for.

Returns

long

The address

Exceptions

ArgumentOutOfRangeException

Occurs when the local index is invalid.

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.

ReadArgument(int)

Reads the value of a local variable into a buffer.

public BitVector ReadArgument(int index)

Parameters

index int

The index of the variable.

Returns

BitVector

A bit vector with the current data of the argument.

ReadArgument(int, BitVectorSpan)

Reads the value of an argument into a buffer.

public void ReadArgument(int index, BitVectorSpan buffer)

Parameters

index int

The index of the argument to read.

buffer BitVectorSpan

The buffer to write the data into.

ReadLocal(int)

Reads the value of a local variable into a buffer.

public BitVector ReadLocal(int index)

Parameters

index int

The index of the variable.

Returns

BitVector

A bit vector with the current data of the local variable.

ReadLocal(int, BitVectorSpan)

Reads the value of a local variable into a buffer.

public void ReadLocal(int index, BitVectorSpan buffer)

Parameters

index int

The index of the variable.

buffer BitVectorSpan

The buffer to write the data into.

Rebase(long)

Relocates the memory to a new base address.

public void Rebase(long baseAddress)

Parameters

baseAddress long

The new base address.

ToString()

public override string ToString()

Returns

string

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.

WriteArgument(int, BitVectorSpan)

Assigns a new value to an argument.

public void WriteArgument(int index, BitVectorSpan buffer)

Parameters

index int

The index of the argument.

buffer BitVectorSpan

The buffer containing the new data.

WriteLocal(int, BitVectorSpan)

Assigns a new value to a local variable.

public void WriteLocal(int index, BitVectorSpan buffer)

Parameters

index int

The index of the variable.

buffer BitVectorSpan

The buffer containing the new data.