Search in sources :

Example 6 with View

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

the class PathFinderTest method testRegularFunction.

@Test
public void testRegularFunction() throws CouldntLoadDataException, PartialLoadException {
    // Tests pathfinding between two simple functions
    // 0x1004565
    // 0x1003CD7
    final Function startFunction = findFunction(m_notepad, 0x1004565);
    final BasicBlock startBlock = findBlock(startFunction, 0x1004629);
    final Function endFunction = findFunction(m_notepad, 0x1003C92);
    final BasicBlock endBlock = findBlock(endFunction, 0x1003CD7);
    final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
    assertEquals(7, view.getGraph().nodeCount());
    assertEquals(8, 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 7 with View

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

the class PathFinderTest method testInsideFunctionPartial.

@Test
public void testInsideFunctionPartial() throws CouldntLoadDataException, PartialLoadException {
    // Tests path finding somewhere inside a function
    final Function startFunction = findFunction(m_notepad, 0x01002452);
    final BasicBlock startBlock = findBlock(startFunction, 0x10024C2);
    final BasicBlock endBlock = findBlock(startFunction, 0x10026FB);
    final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
    assertEquals(9, view.getGraph().nodeCount());
    assertEquals(11, view.getGraph().edgeCount());
    final List<ViewEdge> edges = view.getGraph().getEdges();
    final List<ViewNode> nodes = view.getGraph().getNodes();
    assertEquals(EdgeType.JumpConditionalFalse, findEdge(edges, 0x10024C2, 0x1002523).getType());
    assertEquals(EdgeType.JumpConditionalTrue, findEdge(edges, 0x10024C2, 0x1002539).getType());
    assertEquals(EdgeType.JumpUnconditional, findEdge(edges, 0x100253F, 0x10026F9).getType());
    assertEquals(Color.GREEN, findNode(nodes, 0x10024C2).getColor());
    assertEquals(Color.YELLOW, findNode(nodes, 0x10026FB).getColor());
}
Also used : Function(com.google.security.zynamics.binnavi.API.disassembly.Function) BasicBlock(com.google.security.zynamics.binnavi.API.disassembly.BasicBlock) ViewEdge(com.google.security.zynamics.binnavi.API.disassembly.ViewEdge) ViewNode(com.google.security.zynamics.binnavi.API.disassembly.ViewNode) View(com.google.security.zynamics.binnavi.API.disassembly.View) Test(org.junit.Test)

Example 8 with View

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

the class View2D method findView.

/**
   * Searches for the API view that wraps a given internal view.
   *
   * @param database Database to search for.
   * @param internalView Internal view to search for.
   * @param databases Databases to search through.
   *
   * @return The API view that wraps the given internal view.
   */
private static View findView(final IDatabase database, final INaviView internalView, final List<Database> databases) {
    final Database apiDatabase = ObjectFinders.getObject(database, databases);
    View view = null;
    for (final Module m : apiDatabase.getModules()) {
        if (!m.isLoaded()) {
            continue;
        }
        view = ObjectFinders.getObject(internalView, m.getViews());
        if (view != null) {
            return view;
        }
    }
    for (final Project project : apiDatabase.getProjects()) {
        if (!project.isLoaded()) {
            continue;
        }
        view = ObjectFinders.getObject(internalView, project.getViews());
        if (view != null) {
            return view;
        }
    }
    throw new IllegalStateException("Error: Unknown view");
}
Also used : Project(com.google.security.zynamics.binnavi.API.disassembly.Project) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) View(com.google.security.zynamics.binnavi.API.disassembly.View) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView)

Example 9 with View

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

the class PathFinderTest method testRecursivePath.

@Test
public void testRecursivePath() throws CouldntLoadDataException, PartialLoadException {
    // Tests pathfinding from a simple function to a simple function through
    // a recursive path
    // GetVolumePathNameA
    final Function startFunction = findFunction(m_kernel32, 0x7C82E8B2);
    final BasicBlock startBlock = findBlock(startFunction, 0x7C82E8B2);
    final Function endFunction = findFunction(m_kernel32, 0x7C8092B0);
    final BasicBlock endBlock = findBlock(endFunction, 0x7C8092B0);
    final View view = PathFinder.createPath(m_kernel32, startBlock, endBlock, null, null);
    assertEquals(1247, view.getGraph().nodeCount());
    assertEquals(1988, 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 10 with View

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

the class PathFinderTest method testRecursiveTarget.

@Test
public void testRecursiveTarget() throws CouldntLoadDataException, PartialLoadException {
    // Tests pathfinding from a simple function to a self-recursive function
    // SetCommConfig
    final Function startFunction = findFunction(m_kernel32, 0x7C866E7B);
    final BasicBlock startBlock = findBlock(startFunction, 0x7C866EF3);
    // SetCommState
    final Function endFunction = findFunction(m_kernel32, 0x7C865E16);
    final BasicBlock endBlock = findBlock(endFunction, 0x7C866106);
    final View view = PathFinder.createPath(m_kernel32, startBlock, endBlock, null, null);
    assertEquals(2 + /** calling function **/
    66 + /** called function **/
    3, /** split blocks **/
    view.getGraph().nodeCount());
    assertEquals(99 + /** called function **/
    1 + /** calling target function **/
    3 + 3, /** recursive calls and returns **/
    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