/// <summary> /// Creates a new instance of the <see cref="CilExecutionContext"/> class. /// </summary> /// <param name="serviceProvider">The object providing additional services to the emulator.</param> /// <param name="programState">The current state of the program.</param> /// <param name="cancellationToken">The cancellation token to use for cancelling the execution.</param> public CilExecutionContext( IServiceProvider serviceProvider, CilProgramState programState, CancellationToken cancellationToken) { _serviceProvider = serviceProvider; ProgramState = programState ?? throw new ArgumentNullException(nameof(programState)); CancellationToken = cancellationToken; Result = new ExecutionResult(); }
/// <summary> /// Creates a new instance of the <see cref="CilVirtualMachine"/>. /// </summary> /// <param name="module">The module in which the CIL runs in.</param> /// <param name="instructions">The instructions to emulate..</param> /// <param name="is32Bit">Indicates whether the virtual machine should run in 32-bit mode or in 64-bit mode.</param> public CilVirtualMachine(ModuleDefinition module, IStaticInstructionProvider<CilInstruction> instructions, bool is32Bit) { Module = module; Instructions = instructions; Architecture = instructions.Architecture; Is32Bit = is32Bit; Status = VirtualMachineStatus.Idle; CurrentState = new CilProgramState(); Dispatcher = new DefaultCilDispatcher(); CliMarshaller = new DefaultCliMarshaller(this); MemoryAllocator = new DefaultMemoryAllocator(module, is32Bit); MethodInvoker = new ReturnUnknownMethodInvoker(new UnknownValueFactory(this)); StaticFieldFactory = new StaticFieldFactory(); _services[typeof(ICilRuntimeEnvironment)] = this; }
/// <summary> /// Creates a new instance of the <see cref="CilVirtualMachine"/>. /// </summary> /// <param name="module">The module in which the CIL runs in.</param> /// <param name="instructions">The instructions to emulate..</param> /// <param name="is32Bit">Indicates whether the virtual machine should run in 32-bit mode or in 64-bit mode.</param> public CilVirtualMachine(ModuleDefinition module, IStaticInstructionProvider <CilInstruction> instructions, bool is32Bit) { Module = module ?? throw new ArgumentNullException(nameof(module)); Instructions = instructions ?? throw new ArgumentNullException(nameof(instructions)); Architecture = instructions.Architecture; ValueFactory = new DefaultValueFactory(module, is32Bit); Is32Bit = is32Bit; Status = VirtualMachineStatus.Idle; CurrentState = new CilProgramState(ValueFactory); Dispatcher = new DefaultCilDispatcher(); CliMarshaller = new DefaultCliMarshaller(this); MethodInvoker = new ReturnUnknownMethodInvoker(ValueFactory); StaticFieldFactory = new StaticFieldFactory(ValueFactory); _services[typeof(ICilRuntimeEnvironment)] = this; }