Search in sources :

Example 41 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CGraphSynchonizerTest method test1Simple.

// TODO this test is very artificial as it does not test a real work flow.
@Test
public void test1Simple() throws FileReadException, CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
    final ZyGraph graph = ZyGraphFactory.generateTestGraph();
    final CSpecialInstructionsModel model = new CSpecialInstructionsModel();
    final List<CSpecialInstruction> instructions = new ArrayList<CSpecialInstruction>();
    final ITypeDescription callsDescription = model.getDescriptions().get(0);
    callsDescription.setEnabled(true);
    final CSpecialInstruction instruction = new CSpecialInstruction(callsDescription, Iterables.getFirst(graph.getRawView().getBasicBlocks().get(2).getInstructions(), null));
    final CCodeNode node = graph.getRawView().getBasicBlocks().get(2);
    final NaviNode naviNode = graph.getNode(node);
    final BackEndDebuggerProvider provider = new MockDebuggerProvider();
    new CCodeNodeUpdater(graph, naviNode, node, provider);
    instructions.add(instruction);
    model.setInstructions(instructions);
    assertFalse(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.SPECIAL_INSTRUCTION_LAYER));
    final CGraphSynchronizer synchronizer = new CGraphSynchronizer(graph, model);
    CTypeResultsHighlighter.updateHighlighting(graph, Lists.newArrayList(instruction));
    assertTrue(naviNode.getRealizer().getNodeContent().getLineContent(0).hasHighlighting(CHighlightLayers.SPECIAL_INSTRUCTION_LAYER));
    synchronizer.dispose();
}
Also used : ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) CCodeNodeUpdater(com.google.security.zynamics.binnavi.ZyGraph.Updaters.CodeNodes.CCodeNodeUpdater) ArrayList(java.util.ArrayList) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) BackEndDebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.BackEndDebuggerProvider) MockDebuggerProvider(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebuggerProvider) Test(org.junit.Test)

Example 42 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CGraphFunctions method selectNodesWithString.

/**
   * Selects all nodes of a graph that contain a given search string.
   *
   * @param graph The graph to search through and select.
   * @param searchString The search string to search for.
   */
public static void selectNodesWithString(final ZyGraph graph, final String searchString) {
    Preconditions.checkNotNull(graph, "IE02117: Graph argument can not be null");
    Preconditions.checkNotNull(searchString, "IE02118: Search string argument can not be null");
    final GraphSearcher searcher = new GraphSearcher();
    searcher.search(GraphHelpers.getNodes(graph), new ArrayList<NaviEdge>(), searchString);
    final List<SearchResult> results = searcher.getResults();
    final List<NaviNode> resultNodes = new ArrayList<NaviNode>();
    for (final SearchResult searchResult : results) {
        resultNodes.add((NaviNode) searchResult.getObject());
    }
    graph.selectNodes(resultNodes, true);
    searcher.dispose();
}
Also used : ArrayList(java.util.ArrayList) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) GraphSearcher(com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher) SearchResult(com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)

Example 43 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class CGraphSearchField method jumpTo.

/**
   * Jumps to a search result of the given index.
   *
   * @param index The index of the search result to jump to.
   */
public void jumpTo(final int index) {
    m_searcher.getCursor().jumpTo(index);
    final SearchResult result = m_searcher.getCursor().current();
    if (result == null) {
        return;
    }
    if (result.getObject() instanceof NaviNode) {
        ZyGraphHelpers.centerNode(m_graph, (NaviNode) result.getObject(), false);
    } else if (result.getObject() instanceof NaviEdge) {
        ZyGraphHelpers.centerEdgeLabel(m_graph, (NaviEdge) result.getObject(), false);
    }
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) SearchResult(com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)

Example 44 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class GraphSearcher method clearResults.

/**
   * Clears the results list.
   */
public void clearResults() {
    for (final SearchResult result : m_results) {
        if (result.getObject() instanceof NaviNode) {
            ((NaviNode) result.getObject()).setBackgroundColor(result.getLine(), result.getPosition(), result.getLength(), null);
        } else if (result.getObject() instanceof NaviEdge) {
            final NaviEdge edge = (NaviEdge) result.getObject();
            final ZyLabelContent content = edge.getLabelContent();
            content.getLineContent(result.getLine()).setBackgroundColor(result.getPosition(), result.getLength(), null);
        }
    }
    m_results.clear();
    m_cursor.clear();
    m_changed = false;
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) SearchResult(com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)

Example 45 with NaviNode

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode in project binnavi by google.

the class ZyGraphBuilder method convertEdges.

/**
   * Converts the edges of a view into Graph2D edges.
   *
   * @param edges The edges to convert.
   * @param graph2D The graph where the edges are inserted.
   * @param rawNodeToNodeMap Keeps track of view node => graph node mappings.
   * @param adjustColors
   */
private void convertEdges(final Collection<INaviEdge> edges, final Graph2D graph2D, final Map<INaviViewNode, Node> rawNodeToNodeMap, final boolean adjustColors) {
    for (final INaviEdge edge : edges) {
        // Get the nodes connected by the edge
        final NaviNode sourceNode = m_ynodeToNodeMap.get(rawNodeToNodeMap.get(edge.getSource()));
        final NaviNode targetNode = m_ynodeToNodeMap.get(rawNodeToNodeMap.get(edge.getTarget()));
        final Pair<Edge, NaviEdge> result = ZyEdgeBuilder.convertEdge(edge, sourceNode, targetNode, graph2D, adjustColors);
        m_yedgeToEdgeMap.put(result.first(), result.second());
    }
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Edge(y.base.Edge) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge)

Aggregations

NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)60 Test (org.junit.Test)29 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)19 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)11 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)9 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)9 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)8 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)7 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)6 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)6 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)6 SearchResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult)5 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)5 ArrayList (java.util.ArrayList)5 Node (y.base.Node)5 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)4 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)4 CTextNode (com.google.security.zynamics.binnavi.disassembly.CTextNode)4 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)4 Edge (y.base.Edge)4