Example #1
0
 /// <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;
 }
Example #2
0
        /// <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;
        }