Class CilVirtualMachine
- Namespace
- Echo.Platforms.AsmResolver.Emulation
- Assembly
- Echo.Platforms.AsmResolver.dll
Represents a machine that executes CIL instructions in a virtual environment.
public class CilVirtualMachine
- Inheritance
-
CilVirtualMachine
- Inherited Members
Constructors
CilVirtualMachine(ModuleDefinition, bool)
Creates a new CIL virtual machine.
public CilVirtualMachine(ModuleDefinition contextModule, bool is32Bit)
Parameters
contextModuleModuleDefinitionThe main module to base the context on.
is32BitboolIndicates whether the virtual machine runs in 32-bit mode or 64-bit mode.
Properties
Allocator
Gets the service that is responsible for allocating new objects.
public IObjectAllocator Allocator { get; set; }
Property Value
ContextModule
Gets the main module the emulator is executing instructions for.
public ModuleDefinition ContextModule { get; }
Property Value
Dispatcher
Gets the service that is responsible for dispatching individual instructions to their respective handlers.
public CilDispatcher Dispatcher { get; }
Property Value
EmulationFlags
Gets or sets flags that control the behavior of the virtual machine.
public CilEmulationFlags EmulationFlags { get; set; }
Property Value
Heap
Gets the heap used for storing managed objects.
public ManagedObjectHeap Heap { get; }
Property Value
Remarks
The heap is also addressable from Memory.
Invoker
Gets the service that is responsible for invoking external functions or methods.
public IMethodInvoker Invoker { get; set; }
Property Value
Is32Bit
Gets a value indicating whether the environment is a 32-bit or 64-bit system.
public bool Is32Bit { get; }
Property Value
Loader
Gets the service that is responsible for mapping executable files in memory.
public PELoader Loader { get; }
Property Value
Memory
Gets the main memory interface of the virtual machine.
public VirtualMemory Memory { get; }
Property Value
ObjectMapMemory
Gets the memory manager that embeds managed objects into virtual memory.
public ObjectMapMemory ObjectMapMemory { get; }
Property Value
ObjectMarshaller
Gets or sets the service for marshalling managed objects into bitvectors and back.
public IObjectMarshaller ObjectMarshaller { get; set; }
Property Value
StaticFields
Gets the memory chunk responsible for storing static fields.
public StaticFieldStorage StaticFields { get; }
Property Value
Threads
Gets a collection of threads that are currently active in the machine.
public IReadOnlyList<CilThread> Threads { get; }
Property Value
TypeManager
Gets the service that is responsible for the initialization and management of runtime types residing in the virtual machine.
public RuntimeTypeManager TypeManager { get; }
Property Value
UnknownResolver
Gets or sets the service that is responsible for resolving unknown values on the stack in critical moments.
public IUnknownResolver UnknownResolver { get; set; }
Property Value
ValueFactory
Gets the service that is responsible for managing types in the virtual machine.
public ValueFactory ValueFactory { get; }
Property Value
Methods
CreateThread(uint)
Creates a new thread in the machine.
public CilThread CreateThread(uint stackSize = 1048576)
Parameters
stackSizeuintThe amount of memory to allocate for the thread's stack.
Returns
- CilThread
The created thread.
DestroyThread(CilThread)
Removes a thread and its stack from the machine.
public void DestroyThread(CilThread thread)
Parameters
threadCilThreadThe thread to remove.
Remarks
This does not gracefully terminate a thread. Any code that is still running will remain executing, and may have unwanted side effects. Therefore, be sure to only call this method only when it is certain that no code is running.
Events
ThreadCreated
Fires when a new thread was created.
public event EventHandler<CilThread>? ThreadCreated
Event Type
ThreadDestroyed
Fires when a thread was destroyed.
public event EventHandler<CilThread>? ThreadDestroyed