Search in sources :

Example 11 with ReilBlock

use of com.google.security.zynamics.reil.ReilBlock in project binnavi by google.

the class OperandGraph method findDefinitions.

private static Set<OperandGraphNode> findDefinitions(final List<ReilBlock> parents, final OperandGraphNode node, final Map<ReilBlock, Pair<List<OperandGraphNode>, List<OperandGraphEdge>>> graphMap, final HashSet<ReilBlock> visited) {
    final Set<OperandGraphNode> definitions = new HashSet<OperandGraphNode>();
    for (final ReilBlock reilBlock : parents) {
        if (visited.contains(reilBlock)) {
            continue;
        }
        visited.add(reilBlock);
        final OperandGraphNode definition = findDefinition(node, reilBlock, graphMap, true);
        if (definition != null) {
            definitions.add(definition);
        } else {
            definitions.addAll(findDefinitions(getParents(reilBlock), node, graphMap, visited));
        }
    }
    return definitions;
}
Also used : ReilBlock(com.google.security.zynamics.reil.ReilBlock) HashSet(java.util.HashSet)

Example 12 with ReilBlock

use of com.google.security.zynamics.reil.ReilBlock in project binnavi by google.

the class InstructionGraphTest method testEmpty.

@Test
public void testEmpty() {
    final ReilGraph rg = new ReilGraph(new ArrayList<ReilBlock>(), new ArrayList<ReilEdge>());
    final InstructionGraph g = InstructionGraph.create(rg);
    assertEquals(0, g.nodeCount());
    assertEquals(0, g.edgeCount());
}
Also used : ReilGraph(com.google.security.zynamics.reil.ReilGraph) ReilEdge(com.google.security.zynamics.reil.ReilEdge) ReilBlock(com.google.security.zynamics.reil.ReilBlock) InstructionGraph(com.google.security.zynamics.reil.algorithms.mono.InstructionGraph) Test(org.junit.Test)

Example 13 with ReilBlock

use of com.google.security.zynamics.reil.ReilBlock in project binnavi by google.

the class InstructionGraphTest method testTwoNodes.

@Test
public void testTwoNodes() {
    final ReilBlock block1 = new ReilBlock(Lists.newArrayList(ReilHelpers.createNop(0)));
    final ReilBlock block2 = new ReilBlock(Lists.newArrayList(ReilHelpers.createUndef(1, OperandSize.DWORD, "eax")));
    final ReilEdge edge1 = new ReilEdge(block1, block2, EdgeType.JUMP_CONDITIONAL_FALSE);
    ReilBlock.link(block1, block2, edge1);
    final List<ReilBlock> blocks = Lists.newArrayList(block1, block2);
    final List<ReilEdge> edges = Lists.newArrayList(edge1);
    final ReilGraph rg = new ReilGraph(blocks, edges);
    final InstructionGraph g = InstructionGraph.create(rg);
    assertEquals(2, g.nodeCount());
    assertEquals(1, g.edgeCount());
    assertEquals(0, g.getNodes().get(0).getInstruction().getAddress().toLong());
    assertEquals(1, g.getNodes().get(1).getInstruction().getAddress().toLong());
}
Also used : ReilGraph(com.google.security.zynamics.reil.ReilGraph) ReilEdge(com.google.security.zynamics.reil.ReilEdge) ReilBlock(com.google.security.zynamics.reil.ReilBlock) InstructionGraph(com.google.security.zynamics.reil.algorithms.mono.InstructionGraph) Test(org.junit.Test)

Example 14 with ReilBlock

use of com.google.security.zynamics.reil.ReilBlock in project binnavi by google.

the class OperandGraphTest method testOneNode.

@Test
public void testOneNode() {
    final Collection<ReilInstruction> instructions = new ArrayList<ReilInstruction>();
    instructions.add(ReilHelpers.createAdd(0, OperandSize.DWORD, "eax", OperandSize.DWORD, "123", OperandSize.QWORD, "t0"));
    instructions.add(ReilHelpers.createAnd(1, OperandSize.QWORD, "t0", OperandSize.DWORD, String.valueOf(0xFFFFFFFF), OperandSize.DWORD, "t1"));
    final ReilBlock block1 = new ReilBlock(instructions);
    final List<ReilBlock> blocks = Lists.<ReilBlock>newArrayList(block1);
    final ReilGraph rg = new ReilGraph(blocks, new ArrayList<ReilEdge>());
    final OperandGraph g = OperandGraph.create(rg);
    assertEquals(6, g.nodeCount());
    assertEquals(5, g.edgeCount());
}
Also used : OperandGraph(com.google.security.zynamics.reil.algorithms.mono.OperandGraph) ReilGraph(com.google.security.zynamics.reil.ReilGraph) ReilInstruction(com.google.security.zynamics.reil.ReilInstruction) ReilEdge(com.google.security.zynamics.reil.ReilEdge) ReilBlock(com.google.security.zynamics.reil.ReilBlock) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 15 with ReilBlock

use of com.google.security.zynamics.reil.ReilBlock in project binnavi by google.

the class OperandGraphTest method testEmpty.

@Test
public void testEmpty() {
    final ReilGraph rg = new ReilGraph(new ArrayList<ReilBlock>(), new ArrayList<ReilEdge>());
    final OperandGraph g = OperandGraph.create(rg);
    assertEquals(0, g.nodeCount());
    assertEquals(0, g.edgeCount());
}
Also used : OperandGraph(com.google.security.zynamics.reil.algorithms.mono.OperandGraph) ReilGraph(com.google.security.zynamics.reil.ReilGraph) ReilEdge(com.google.security.zynamics.reil.ReilEdge) ReilBlock(com.google.security.zynamics.reil.ReilBlock) Test(org.junit.Test)

Aggregations

ReilBlock (com.google.security.zynamics.reil.ReilBlock)23 ReilEdge (com.google.security.zynamics.reil.ReilEdge)16 ReilInstruction (com.google.security.zynamics.reil.ReilInstruction)16 ArrayList (java.util.ArrayList)12 ReilGraph (com.google.security.zynamics.reil.ReilGraph)10 Test (org.junit.Test)8 HashMap (java.util.HashMap)5 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)4 EdgeType (com.google.security.zynamics.zylib.gui.zygraph.edges.EdgeType)4 HashSet (java.util.HashSet)4 ReilFunction (com.google.security.zynamics.reil.ReilFunction)3 InstructionGraph (com.google.security.zynamics.reil.algorithms.mono.InstructionGraph)3 OperandGraph (com.google.security.zynamics.reil.algorithms.mono.OperandGraph)3 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)3 Pair (com.google.security.zynamics.zylib.general.Pair)3 List (java.util.List)3 InstructionGraphNode (com.google.security.zynamics.reil.algorithms.mono.InstructionGraphNode)2 ValueTrackerElement (com.google.security.zynamics.reil.algorithms.mono.valuetracking.ValueTrackerElement)2 Triple (com.google.security.zynamics.zylib.general.Triple)2 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)1