Esempio n. 1
0
        public UserIndirectJump GetResults()
        {
            var vb      = new VectorBuilder(dlg.Services, dlg.Program, new DirectedGraphImpl <object>());
            var stride  = 4; //$TODO: get from dialog
            var entries = vb.BuildTable(dlg.VectorAddress, stride * (int)dlg.EntryCount.Value, null, stride, null);
            var table   = new ImageMapVectorTable(dlg.VectorAddress, entries.ToArray(), 0);

            return(new UserIndirectJump
            {
                Address = dlg.Instruction.Address,
                Table = table,
                IndexRegister = dlg.Program.Architecture.GetRegister(dlg.IndexRegister.SelectedValue.ToString())
            });
        }
Esempio n. 2
0
        private void BuildAddressTable()
        {
            var vectorBuilder = new VectorBuilder(null, dlg.Program, null);
            var addresses     = new List <Address>();

            if (dlg.Program.Platform.TryParseAddress(dlg.JumpTableStartAddress.Text, out Address addrTable))
            {
                var stride = TableStride();
                var state  = dlg.Program.Architecture.CreateProcessorState();
                state.InstructionPointer = dlg.Instruction.Address;
                addresses = vectorBuilder.BuildTable(addrTable, stride * (int)dlg.EntryCount.Value, null, stride, state);
            }
            dlg.Entries.DataSource    = addresses;
            dlg.Entries.SelectedIndex = addresses.Count - 1;
        }
Esempio n. 3
0
        public void Vb_CreateVector_ModifiesImageMap()
        {
            Given_Program(new byte[]
            {
                0x10, 0x00, 0x01, 0x00,
                0x11, 0x00, 0x01, 0x00,
                0x12, 0x00, 0x01, 0x00,
                0xCC, 0xCC, 0xCC, 0xCC,
                0xC3, 0xC3, 0xC3, 0xCC,
            });
            var scanner = new Mock <IScanner>();

            scanner.Setup(s => s.Services).Returns(sc);
            arch.Setup(s => s.CreateImageReader(this.mem, this.program.ImageMap.BaseAddress))
            .Returns(this.mem.CreateLeReader(0));
            var state = new FakeProcessorState(arch.Object);

            var vb     = new VectorBuilder(scanner.Object.Services, program, new DirectedGraphImpl <object>());
            var vector = vb.BuildTable(this.program.ImageMap.BaseAddress, 12, null, 4, state);

            Assert.AreEqual(3, vector.Count);
        }
Esempio n. 4
0
        public void Vb_CreateVector_ModifiesImageMap()
        {
            Given_Program(new byte[]
            {
                0x10, 0x00, 0x01, 0x00,
                0x11, 0x00, 0x01, 0x00,
                0x12, 0x00, 0x01, 0x00,
                0xCC, 0xCC, 0xCC, 0xCC,
                0xC3, 0xC3, 0xC3, 0xCC,
            });
            var scanner = mr.Stub <IScanner>();

            scanner.Stub((Function <IScanner, ImageReader>)(s => s.CreateReader((Address)this.program.ImageMap.BaseAddress)))
            .Return(this.mem.CreateLeReader(0));
            var state = mr.Stub <ProcessorState>();

            mr.ReplayAll();

            var vb     = new VectorBuilder(scanner, program, new DirectedGraphImpl <object>());
            var vector = vb.BuildTable((Address)this.program.ImageMap.BaseAddress, 12, null, 4, state);

            Assert.AreEqual(3, vector.Count);
        }