Table of Contents

Class CallStack

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

Represents a call stack consisting of frames, representing the current state of the program.

public class CallStack : IndexableStack<CallFrame>, IReadOnlyList<CallFrame>, IReadOnlyCollection<CallFrame>, IEnumerable<CallFrame>, IEnumerable, IMemorySpace
Inheritance
CallStack
Implements
Inherited Members

Constructors

CallStack(uint, ValueFactory)

Creates a new virtual call stack.

public CallStack(uint maxSize, ValueFactory factory)

Parameters

maxSize uint

The maximum number of bytes the stack can hold.

factory ValueFactory

The service responsible for managing types.

Properties

AddressRange

Gets the range that this memory space spans.

public AddressRange AddressRange { get; }

Property Value

AddressRange

StackPointer

Gets the current value of the stack pointer.

public long StackPointer { get; }

Property Value

long

Methods

GetFrameAddress(int)

Gets the address of a single frame in the stack.

public long GetFrameAddress(int index)

Parameters

index int

The index of the stack frame.

Returns

long

The address.

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.

OnCalled(CallFrame)

Fires the Called event.

protected virtual void OnCalled(CallFrame frame)

Parameters

frame CallFrame

The frame that was pushed.

OnReturned(CallFrame)

Fires the Returned event.

protected virtual void OnReturned(CallFrame frame)

Parameters

frame CallFrame

The frame that was popped.

Pop()

Pops the top-most frame from the stack.

public override CallFrame Pop()

Returns

CallFrame

The popped frame.

Exceptions

InvalidOperationException

Occurs when the stack is empty.

Push(IMethodDescriptor)

Creates a new call stack frame for the provided method and pushes it onto the top of the call stack.

public CallFrame Push(IMethodDescriptor method)

Parameters

method IMethodDescriptor

The method to create a frame for.

Returns

CallFrame

The created call stack frame.

Push(CallFrame)

Pushes a call frame onto the stack.

public override void Push(CallFrame frame)

Parameters

frame CallFrame

The frame to push.

Exceptions

StackOverflowException

Occurs when the stack reached its maximum size.

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.

Events

Called

Occurs when a new call frame is pushed onto the stack.

public event EventHandler<CallEventArgs>? Called

Event Type

EventHandler<CallEventArgs>

Returned

Occurs when a call frame was popped from the stack.

public event EventHandler<CallEventArgs>? Returned

Event Type

EventHandler<CallEventArgs>