Пример #1
0
        public void Bwi_CallingAllocaWithConstant()
        {
            scanner = mr.StrictMock<IScanner>();
            prog.Architecture = new IntelArchitecture(ProcessorMode.Protected32);
        
            var sig = CreateSignature(Registers.esp, Registers.eax);
            var alloca = new ExternalProcedure("alloca", sig);
            alloca.Characteristics = new ProcedureCharacteristics
            {
                IsAlloca = true
            };

            using (mr.Record())
            {
                scanner.Stub(x => x.FindContainingBlock(
                    Arg<Address>.Is.Anything)).Return(block);
                scanner.Expect(x => x.GetImportedProcedure(
                    Arg<Address>.Matches(a => a.ToLinear() == 0x2000u),
                    Arg<Address>.Is.NotNull)).Return(alloca);
                scanner.Stub(x => x.GetTrace(null, null, null)).IgnoreArguments().Return(trace);
            }
            trace.Add(m => m.Call(Address.Ptr32(0x2000), 4));
            var state = new FakeProcessorState(prog.Architecture);
            state.SetRegister(Registers.eax, Constant.Word32(0x0400));
            var wi = CreateWorkItem(Address.Ptr32(0x1000), state);
            wi.ProcessInternal();

            mr.VerifyAll();
            Assert.AreEqual(1, block.Statements.Count);
            Assert.AreEqual("esp = esp - 0x00000400", block.Statements.Last.ToString());
        }