示例#1
0
        public Emulator(MethodDef method)
        {
            OpCodeDebugger.Instance.AddBrakpoint(Code.Newobj);

            CurrentCall = new EmulatedCall(null, method);
            MemoryStack.NewFrame();

            sandboxDomain = AppDomain.CreateDomain("sandboxDomain");


            #region Instructions #

            AddInstructions(new FacelessInstruction[] {
                new Instruction_ldnull(),
                new Instruction_nop(),
                new Instruction_ld(Code.Ldc_I4),
                new Instruction_ld(Code.Ldc_I8),
                new Instruction_ld(Code.Ldc_R4),
                new Instruction_ld(Code.Ldc_R8),
                new Instruction_ld(Code.Ldstr),
                new Instruction_dup(),
                new Instruction_pop(),
                new Instruction_call(Code.Call),
                new Instruction_call(Code.Callvirt),
                new Instruction_ret(),
                new Instruction_stloc(),
                new Instruction_ldloc(),
                new Instruction_newobj(),
                new Instruction_br(),
                new Instruction_ldarg(),
                new Instruction_clt(),
                new Instruction_brtrue(),
                new Instruction_add(),
                new Instruction_sub(),
                new Instruction_xor(),
                new Instruction_mul(),
                new Instruction_starg(),
                new Instruction_ceq(),
                new Instruction_brfalse(),
                new Instruction_stfld(),
                new Instruction_ldfld(),
                new Instruction_ldftn(),
                new Instruction_ldtoken(),
            });

            #endregion
        }
        public EmulatedCall(EmulatedCall _parent, MethodDef __method, FacelessValue[] args)
        {
            ParentCall       = _parent;
            MethodDefinition = __method;
            Parameters       = args;

            if (__method.HasBody)
            {
                Locals = new object[Body.Variables.Count];

                Body.SimplifyMacros(MethodDefinition.Parameters);
                Body.SimplifyBranches();
            }
            else
            {
                Locals = new object[0];
            }
        }
 public EmulatedCall(EmulatedCall _parent, MethodDef __method) : this(_parent, __method, new FacelessValue[0])
 {
 }