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
maxSizeuintThe maximum number of bytes the stack can hold.
factoryValueFactoryThe service responsible for managing types.
Properties
AddressRange
Gets the range that this memory space spans.
public AddressRange AddressRange { get; }
Property Value
StackPointer
Gets the current value of the stack pointer.
public long StackPointer { get; }
Property Value
Methods
GetFrameAddress(int)
Gets the address of a single frame in the stack.
public long GetFrameAddress(int index)
Parameters
indexintThe 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
addresslongThe address to query.
Returns
- bool
trueif the address was valid,falseotherwise.
OnCalled(CallFrame)
Fires the Called event.
protected virtual void OnCalled(CallFrame frame)
Parameters
frameCallFrameThe frame that was pushed.
OnReturned(CallFrame)
Fires the Returned event.
protected virtual void OnReturned(CallFrame frame)
Parameters
frameCallFrameThe 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
methodIMethodDescriptorThe 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
frameCallFrameThe 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
addresslongThe address to start reading at.
bufferBitVectorSpanThe buffer to write into.
Rebase(long)
Relocates the memory to a new base address.
public void Rebase(long baseAddress)
Parameters
baseAddresslongThe new base address.
Write(long, BitVectorSpan)
Writes the provided buffer of data at the provided address.
public void Write(long address, BitVectorSpan buffer)
Parameters
addresslongThe address to start writing at.
bufferBitVectorSpanThe 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
addresslongThe address to start writing at.
bufferReadOnlySpan<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
Returned
Occurs when a call frame was popped from the stack.
public event EventHandler<CallEventArgs>? Returned