Пример #1
0
        public void TrfPropagateToProcedureSummary()
        {
            Procedure proc = new Procedure("proc", prog.Architecture.CreateFrame());

            prog.CallGraph.AddProcedure(proc);
            Identifier eax = proc.Frame.EnsureRegister(Registers.eax);
            Identifier ebx = proc.Frame.EnsureRegister(Registers.ebx);
            Identifier ecx = proc.Frame.EnsureRegister(Registers.ecx);
            Identifier esi = proc.Frame.EnsureRegister(Registers.esi);

            flow[proc] = new ProcedureFlow(proc, prog.Architecture);

            trf = CreateTrashedRegisterFinder();
            CreateBlockFlow(proc.ExitBlock, proc.Frame);
            trf.StartProcessingBlock(proc.ExitBlock);

            trf.RegisterSymbolicValues[(RegisterStorage)eax.Storage] = eax;                     // preserved
            trf.RegisterSymbolicValues[(RegisterStorage)ebx.Storage] = ecx;                     // trashed
            trf.RegisterSymbolicValues[(RegisterStorage)esi.Storage] = Constant.Invalid;        // trashed
            trf.PropagateToProcedureSummary(proc);
            ProcedureFlow pf = flow[proc];

            Assert.AreEqual(" ebx esi", pf.EmitRegisters(prog.Architecture, "", pf.TrashedRegisters));
            Assert.AreEqual(" eax", pf.EmitRegisters(prog.Architecture, "", pf.PreservedRegisters));
        }
Пример #2
0
        public void Simple()
        {
            var reg = arch.GetRegister(1);

            ctx.RegisterState[reg] = Constant.Word32(1);
            trs.PropagateToProcedureSummary();

            Assert.AreEqual(" r1", flow.EmitRegisters(arch, "", flow.TrashedRegisters));
            Assert.AreEqual("0x00000001", flow.ConstantRegisters[reg].ToString());
        }
Пример #3
0
        public void TrfPreserveEbp()
        {
            Identifier esp = m.Frame.EnsureRegister(Registers.esp);
            Identifier ebp = m.Frame.EnsureRegister(Registers.ebp);

            m.Store(esp, ebp);
            m.Assign(ebp, m.LoadDw(m.Int32(0x12345678)));
            m.Assign(ebp, m.LoadDw(esp));
            m.Return();

            Procedure proc = m.Procedure;

            prog.Procedures.Add(Address.Ptr32(0x10000), proc);
            prog.CallGraph.AddProcedure(proc);
            flow = new ProgramDataFlow(prog);

            trf = CreateTrashedRegisterFinder(prog);
            trf.Compute();
            ProcedureFlow pf = flow[proc];

            Assert.AreEqual(" esp ebp", pf.EmitRegisters(prog.Architecture, "", pf.PreservedRegisters), "ebp should have been preserved");
        }