Search in sources :

Example 11 with View

use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.

the class PathFinderTest method testPassingFunctionReturn.

@Test
public void testPassingFunctionReturn() throws CouldntLoadDataException, PartialLoadException {
    // Tests pathfinding from one function to another function while passing one function
    // and having a target block that is a RETURN block.
    //
    // What should happen here is that the pathfinding algorithm stops when it reaches
    // the RETURN node. That is consecutive calls to the target function should not
    // be part of the pathfinding result.
    // 0x1004565 -> 0x1003C92 -> 0x100398D
    final Function startFunction = findFunction(m_notepad, 0x1004565);
    final BasicBlock startBlock = findBlock(startFunction, 0x1004629);
    final Function endFunction = findFunction(m_notepad, 0x100398D);
    final BasicBlock endBlock = findBlock(endFunction, 0x10039D9);
    final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
    assertEquals(14, view.getGraph().nodeCount());
    assertEquals(19, view.getGraph().edgeCount());
}
Also used : Function(com.google.security.zynamics.binnavi.API.disassembly.Function) BasicBlock(com.google.security.zynamics.binnavi.API.disassembly.BasicBlock) View(com.google.security.zynamics.binnavi.API.disassembly.View) Test(org.junit.Test)

Example 12 with View

use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.

the class PathFinderTest method testInsideFunction.

// @Test
// public void testFoo() throws CouldntLoadDataException, CouldntSaveDataException
// {
// // TODO: Bring this test back in msw3prt.idb
//
// final Function startFunction = findFunction(m_foo, 0x5FEF8426);
// final BasicBlock startBlock = findBlock(startFunction, 0x5FEF8426);
//
// final Function endFunction = findFunction(m_foo, 0x5FEFF06D);
// final BasicBlock endBlock = findBlock(endFunction, 0x5FEFF0DB);
//
// final View view = PathFinder.createPath(m_foo, startBlock, endBlock, null, null);
//
// assertEquals(46, view.getGraph().nodeCount());
// assertEquals(49, view.getGraph().edgeCount());
// }
@Test
public void testInsideFunction() throws CouldntLoadDataException, PartialLoadException {
    // Tests path finding from the beginning to the end of a single function
    final Function startFunction = findFunction(m_notepad, 0x01002B87);
    final BasicBlock startBlock = findBlock(startFunction, 0x1002B87);
    final BasicBlock endBlock = findBlock(startFunction, 0x100336A);
    final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
    assertEquals(96, view.getGraph().nodeCount());
    assertEquals(150, view.getGraph().edgeCount());
}
Also used : Function(com.google.security.zynamics.binnavi.API.disassembly.Function) BasicBlock(com.google.security.zynamics.binnavi.API.disassembly.BasicBlock) View(com.google.security.zynamics.binnavi.API.disassembly.View) Test(org.junit.Test)

Example 13 with View

use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.

the class PathFinderTest method testFirstBlock.

@Test
public void testFirstBlock() throws CouldntLoadDataException, PartialLoadException {
    // Tests 100337E -> 1005179 -> 1007568 where all calls are in the first block
    // of the respective functions.
    // Tests path finding from the beginning to the end of a single function
    final Function startFunction = findFunction(m_notepad, 0x100337E);
    final BasicBlock startBlock = findBlock(startFunction, 0x10033C2);
    final Function endFunction = findFunction(m_notepad, 0x1007568);
    final BasicBlock endBlock = findBlock(endFunction, 0x1007568);
    final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
    assertEquals(3, view.getGraph().nodeCount());
    assertEquals(2, view.getGraph().edgeCount());
}
Also used : Function(com.google.security.zynamics.binnavi.API.disassembly.Function) BasicBlock(com.google.security.zynamics.binnavi.API.disassembly.BasicBlock) View(com.google.security.zynamics.binnavi.API.disassembly.View) Test(org.junit.Test)

Example 14 with View

use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.

the class PathFinderTest method testToImportedFunction.

@Test
public void testToImportedFunction() throws CouldntLoadDataException, PartialLoadException {
    // Tests from the beginning of a function to an imported function
    final Function startFunction = findFunction(m_notepad, 0x0100398D);
    final BasicBlock startBlock = findBlock(startFunction, 0x100398D);
    final Function endFunction = findFunction(m_notepad, 0x1001000);
    endFunction.load();
    final View view = PathFinder.createPath(m_notepad, startBlock, null, null, endFunction);
    assertEquals(3, view.getGraph().nodeCount());
    assertEquals(2, view.getGraph().edgeCount());
}
Also used : Function(com.google.security.zynamics.binnavi.API.disassembly.Function) BasicBlock(com.google.security.zynamics.binnavi.API.disassembly.BasicBlock) View(com.google.security.zynamics.binnavi.API.disassembly.View) Test(org.junit.Test)

Aggregations

View (com.google.security.zynamics.binnavi.API.disassembly.View)14 Function (com.google.security.zynamics.binnavi.API.disassembly.Function)13 BasicBlock (com.google.security.zynamics.binnavi.API.disassembly.BasicBlock)10 Test (org.junit.Test)9 Module (com.google.security.zynamics.binnavi.API.disassembly.Module)4 ViewEdge (com.google.security.zynamics.binnavi.API.disassembly.ViewEdge)3 HashMap (java.util.HashMap)3 MemoryModule (com.google.security.zynamics.binnavi.API.debug.MemoryModule)2 Callgraph (com.google.security.zynamics.binnavi.API.disassembly.Callgraph)2 CouldntSaveDataException (com.google.security.zynamics.binnavi.API.disassembly.CouldntSaveDataException)2 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)2 FunctionEdge (com.google.security.zynamics.binnavi.API.disassembly.FunctionEdge)2 FunctionNode (com.google.security.zynamics.binnavi.API.disassembly.FunctionNode)2 ViewNode (com.google.security.zynamics.binnavi.API.disassembly.ViewNode)2 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)2 BigInteger (java.math.BigInteger)2 Set (java.util.Set)2 CouldntLoadDataException (com.google.security.zynamics.binnavi.API.disassembly.CouldntLoadDataException)1 FunctionBlock (com.google.security.zynamics.binnavi.API.disassembly.FunctionBlock)1 Instruction (com.google.security.zynamics.binnavi.API.disassembly.Instruction)1