Exemplo n.º 1
0
        public void Setup()
        {
            var mem = new MemoryArea(Address.Ptr32(0x10000), new byte[4]);

            program = new Program
            {
                SegmentMap = new SegmentMap(
                    mem.BaseAddress,
                    new ImageSegment(".text", mem, AccessMode.ReadExecute))
            };
            var procAddress = Address.Ptr32(0x10000000);

            instr = new X86Instruction(Opcode.nop, InstrClass.Linear, PrimitiveType.Word32, PrimitiveType.Word32)
            {
                Address = procAddress,
            };
            proc  = Procedure.Create(arch, procAddress, arch.CreateFrame());
            state = (X86State)arch.CreateProcessorState();
            orw   = new OperandRewriter32(arch, new ExpressionEmitter(), proc.Frame, new FakeRewriterHost(program));
        }
Exemplo n.º 2
0
        public void Setup()
        {
            arch = new IntelArchitecture(ProcessorMode.Real);
            var image = new LoadedImage(Address.Ptr32(0x10000), new byte[4]);
            var prog  = new Program(
                image,
                image.CreateImageMap(),
                arch,
                null);
            var procAddress = Address.Ptr32(0x10000000);

            instr = new X86Instruction(Opcode.nop, PrimitiveType.Word16, PrimitiveType.Word16)
            {
                Address = procAddress,
            };

            proc  = Procedure.Create(procAddress, arch.CreateFrame());
            orw   = new OperandRewriter16(arch, proc.Frame, new FakeRewriterHost(prog));
            state = (X86State)arch.CreateProcessorState();
        }
Exemplo n.º 3
0
        public void StackUnderflow_ReportError()
        {
            var    arch          = new IntelArchitecture(ProcessorMode.Protected32);
            string reportedError = null;
            var    state         = new X86State(arch)
            {
                ErrorListener = (err) => { reportedError = err; }
            };

            state.OnProcedureEntered();
            state.SetRegister(Registers.esp, Constant.Word32(-4)); // Push only 4 bytes
            var esp  = CreateId(Registers.esp);
            var site = state.OnBeforeCall(esp, 4);

            state.OnAfterCall(esp, new ProcedureSignature
            {
                StackDelta = 16,                                                // ...but pop 16 bytes
            },
                              new Reko.Evaluation.ExpressionSimplifier(state)); //$TODO: hm. Move simplification out of state.
            Assert.IsNotNull(reportedError);
        }
        public void Setup()
        {
            arch = new X86ArchitectureReal("x86-real-16");
            var mem     = new MemoryArea(Address.Ptr32(0x10000), new byte[4]);
            var program = new Program(
                new SegmentMap(
                    mem.BaseAddress,
                    new ImageSegment(
                        "code", mem, AccessMode.ReadWriteExecute)),
                arch,
                new DefaultPlatform(null, arch));
            var procAddress = Address.Ptr32(0x10000000);

            instr = new X86Instruction(Mnemonic.nop, InstrClass.Linear, PrimitiveType.Word16, PrimitiveType.Word16)
            {
                Address = procAddress,
            };

            proc  = Procedure.Create(arch, procAddress, arch.CreateFrame());
            orw   = new OperandRewriter16(arch, new ExpressionEmitter(), proc.Frame, new FakeRewriterHost(program));
            state = (X86State)arch.CreateProcessorState();
        }
Exemplo n.º 5
0
 private X86Rewriter CreateRewriter64(byte[] bytes)
 {
     state = new X86State(arch64);
     return(new X86Rewriter(arch64, host, state, new LeImageReader(image, 0), new Frame(arch64.WordWidth)));
 }
Exemplo n.º 6
0
 private X86Rewriter CreateRewriter32(X86Assembler m)
 {
     state = new X86State(arch32);
     return(new X86Rewriter(arch32, host, state, m.GetImage().Image.CreateLeReader(0), new Frame(arch32.WordWidth)));
 }