Search in sources :

Example 1 with MockCodeEdge

use of com.google.security.zynamics.zylib.disassembly.MockCodeEdge in project binnavi by google.

the class ReilTranslatorTest method testInlinedFunctionGeneration2.

@Test
public void testInlinedFunctionGeneration2() throws InternalTranslationException {
    final MockBlockContainer container = new MockBlockContainer();
    final MockCodeContainer block1 = new MockCodeContainer();
    block1.m_instructions.add(createPush(0x1000, "eax"));
    block1.m_instructions.add(createMov(0x1001, "edx", "3"));
    block1.m_instructions.add(createCall(0x1002));
    final MockCodeContainer block2 = new MockCodeContainer();
    block2.m_instructions.add(createPush(0x2500, "ebx"));
    final MockCodeContainer block3 = new MockCodeContainer();
    block3.m_instructions.add(createPush(0x1003, "ecx"));
    container.m_blocks.add(block1);
    container.m_blocks.add(block2);
    container.m_blocks.add(block3);
    final MockCodeEdge<MockCodeContainer> edge1 = new MockCodeEdge<MockCodeContainer>(block1, block2, EdgeType.ENTER_INLINED_FUNCTION);
    final MockCodeEdge<MockCodeContainer> edge2 = new MockCodeEdge<MockCodeContainer>(block2, block3, EdgeType.LEAVE_INLINED_FUNCTION);
    block1.m_outgoingEdges.add(edge1);
    container.m_edges.add(edge1);
    container.m_edges.add(edge2);
    final ReilFunction function = m_translator.translate(new StandardEnvironment(), container);
    System.out.println(function.getGraph().getEdges());
    assertEquals(3, function.getGraph().getNodes().size());
    assertEquals(2, function.getGraph().getEdges().size());
    final MonoReilSolverResult<RegisterSetLatticeElement> result = RegisterTracker.track(function, Iterables.get(block1.getInstructions(), 0), "esp", new RegisterTrackingOptions(true, new HashSet<String>(), true, AnalysisDirection.DOWN));
    System.out.println(result);
}
Also used : MockCodeContainer(com.google.security.zynamics.zylib.disassembly.MockCodeContainer) MockCodeEdge(com.google.security.zynamics.zylib.disassembly.MockCodeEdge) RegisterTrackingOptions(com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterTrackingOptions) RegisterSetLatticeElement(com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLatticeElement) MockBlockContainer(com.google.security.zynamics.zylib.disassembly.MockBlockContainer) ReilFunction(com.google.security.zynamics.reil.ReilFunction) StandardEnvironment(com.google.security.zynamics.reil.translators.StandardEnvironment) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ReilFunction (com.google.security.zynamics.reil.ReilFunction)1 RegisterSetLatticeElement (com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterSetLatticeElement)1 RegisterTrackingOptions (com.google.security.zynamics.reil.algorithms.mono2.registertracking.RegisterTrackingOptions)1 StandardEnvironment (com.google.security.zynamics.reil.translators.StandardEnvironment)1 MockBlockContainer (com.google.security.zynamics.zylib.disassembly.MockBlockContainer)1 MockCodeContainer (com.google.security.zynamics.zylib.disassembly.MockCodeContainer)1 MockCodeEdge (com.google.security.zynamics.zylib.disassembly.MockCodeEdge)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1