Search in sources :

Example 11 with NaviEdge

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge 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 12 with NaviEdge

use of com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge 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)

Example 13 with NaviEdge

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

the class CSearchResultComparator method compare.

@Override
public // NO_UCD
int compare(// NO_UCD
final SearchResult first, // NO_UCD
final SearchResult second) {
    IAddress firstAddress = null;
    IAddress secondAddress = null;
    if (first.getObject() instanceof NaviEdge) {
        firstAddress = getAddress((NaviEdge) first.getObject());
    } else if (first.getObject() instanceof NaviNode) {
        firstAddress = getAddress(((NaviNode) first.getObject()).getRawNode());
    }
    if (second.getObject() instanceof NaviEdge) {
        secondAddress = getAddress((NaviEdge) second.getObject());
    } else if (second.getObject() instanceof NaviNode) {
        secondAddress = getAddress(((NaviNode) second.getObject()).getRawNode());
    }
    if ((firstAddress == null) || (secondAddress == null)) {
        throw new IllegalStateException("IE01155: Address can't be null.");
    }
    return firstAddress.toBigInteger().compareTo(secondAddress.toBigInteger());
}
Also used : NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) IAddress(com.google.security.zynamics.zylib.disassembly.IAddress) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)

Example 14 with NaviEdge

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

the class CBreakpointTableTest method testAddedDebugger.

/**
   * This test is making sure that listeners are correctly attached to new debuggers.
   *
   * @throws CouldntSaveDataException
   * @throws FileReadException
   */
@Test
public void testAddedDebugger() throws CouldntSaveDataException, FileReadException {
    ConfigManager.instance().read();
    final INaviModule mockModule = new MockModule();
    final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
    final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
    final ZyGraphViewSettings settings = new ZyGraphViewSettings(new FlowGraphSettingsConfigItem());
    settings.getLayoutSettings().setDefaultGraphLayout(LayoutStyle.CIRCULAR);
    final ZyGraph graph = new ZyGraph(new MockView(), new LinkedHashMap<Node, NaviNode>(), new LinkedHashMap<Edge, NaviEdge>(), settings, new ZyGraph2DView());
    final IViewContainer viewContainer = new MockViewContainer();
    final CBreakpointTable table = new CBreakpointTable(debuggerProvider, graph, viewContainer);
    final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
    final MockModule module = new MockModule();
    debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(module, new UnrelocatedAddress(new CAddress(0)))));
    debuggerProvider.addDebugger(debugger);
    table.dispose();
}
Also used : FlowGraphSettingsConfigItem(com.google.security.zynamics.binnavi.config.FlowGraphSettingsConfigItem) IViewContainer(com.google.security.zynamics.binnavi.disassembly.views.IViewContainer) MockViewContainer(com.google.security.zynamics.binnavi.disassembly.MockViewContainer) ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) Node(y.base.Node) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) DebugTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) ZyGraph2DView(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Edge(y.base.Edge) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Test(org.junit.Test)

Example 15 with NaviEdge

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

the class GraphSearcherTest method testSearchSelected.

@Test
public void testSearchSelected() {
    final ZyNodeRealizer<NaviNode> r = new ZyNormalNodeRealizer<NaviNode>(m_content);
    final NaviNode m_node1 = new NaviNode(m_ynode, r, m_codeNode1);
    final GraphSearcher searcher = new GraphSearcher();
    searcher.getSettings().setOnlySelected(true);
    m_content.addLineContent(new ZyLineContent("Hello my Test", null));
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my");
    assertNull(searcher.getCursor().current());
    m_node1.getRawNode().setSelected(true);
    searcher.search(Lists.newArrayList(m_node1), new ArrayList<NaviEdge>(), "my");
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
    // TEST: Do not move beyond the last result
    searcher.getCursor().next();
    assertEquals(m_node1, searcher.getCursor().current().getObject());
    assertEquals(0, searcher.getCursor().current().getLine());
    assertEquals(6, searcher.getCursor().current().getPosition());
    assertEquals(2, searcher.getCursor().current().getLength());
}
Also used : ZyNormalNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) GraphSearcher(com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) NaviEdge(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge) Test(org.junit.Test)

Aggregations

NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)20 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)19 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)10 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)9 Test (org.junit.Test)9 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)8 SearchResult (com.google.security.zynamics.binnavi.Gui.GraphWindows.Searchers.Text.Model.SearchResult)5 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)5 Edge (y.base.Edge)5 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)4 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)3 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)3 ZyGraph (com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph)3 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)3 ZyGraph2DView (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView)3 ZyEdgeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyEdgeRealizer)3 Node (y.base.Node)3 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)2 ZyGraphViewSettings (com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings)2 CallGraphSettingsConfigItem (com.google.security.zynamics.binnavi.config.CallGraphSettingsConfigItem)2