Search in sources :

Example 11 with NaviNode

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

the class CGraphFunctions method showNodes.

/**
   * Shows or hides nodes of a graph in one step.
   *
   * @param parent Parent used for dialogs.
   * @param graph The graph where the nodes are shown or hidden.
   * @param nodes List of nodes to show or hide.
   * @param visible True, to show the nodes. False, to hide the nodes.
   */
public static void showNodes(final Window parent, final ZyGraph graph, final Collection<NaviNode> nodes, final boolean visible) {
    Preconditions.checkNotNull(parent, "IE02123: Parent argument can not be null");
    Preconditions.checkNotNull(graph, "IE02124: Graph argument can not be null");
    Preconditions.checkNotNull(nodes, "IE02125: Nodes argument can not be null");
    if (visible) {
        final ZyGraphViewSettings settings = graph.getSettings();
        final Set<NaviNode> neighbours = ProximityRangeCalculator.getNeighbors(graph, nodes, settings.getProximitySettings().getProximityBrowsingChildren(), settings.getProximitySettings().getProximityBrowsingParents());
        neighbours.addAll(nodes);
        final int invisibleNodes = countInvisibleNodes(neighbours);
        if (userCancelsMakingVisible(parent, graph, invisibleNodes)) {
            return;
        }
    }
    graph.showNodes(nodes, visible);
}
Also used : ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)

Example 12 with NaviNode

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

the class CGraphFunctions method showNodes.

/**
   * Shows and hides nodes of a graph in one step.
   *
   * @param parent Parent used for dialogs.
   * @param graph The graph where the nodes are shown and hidden.
   * @param toShow List of nodes to show.
   * @param toHide List of nodes to hide.
   */
public static void showNodes(final JFrame parent, final ZyGraph graph, final Collection<NaviNode> toShow, final Collection<NaviNode> toHide) {
    Preconditions.checkNotNull(graph, "IE02120: Graph argument can not be null");
    Preconditions.checkNotNull(toShow, "IE02121: toShow argument can not be null");
    Preconditions.checkNotNull(toHide, "IE02122: toHide argument can not be null");
    final ZyGraphViewSettings settings = graph.getSettings();
    final Set<NaviNode> neighbours = ProximityRangeCalculator.getNeighbors(graph, toShow, settings.getProximitySettings().getProximityBrowsingChildren(), settings.getProximitySettings().getProximityBrowsingParents());
    neighbours.addAll(toShow);
    final int invisibleNodes = countInvisibleNodes(neighbours);
    if (userCancelsMakingVisible(parent, graph, invisibleNodes)) {
        return;
    }
    graph.showNodes(toShow, toHide);
}
Also used : ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)

Example 13 with NaviNode

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

the class InternalNodeCallBack method zoomToAddress.

/**
   * Zooms to the first occurrence of an address in a graph.
   *
   * @param graph The graph where the zoom operation takes place.
   * @param address The address to zoom to.
   */
public static void zoomToAddress(final ZyGraph graph, final IAddress address) {
    graph.iterate(new INodeCallback<NaviNode>() {

        @Override
        public IterationMode next(final NaviNode node) {
            if (node.getRawNode() instanceof INaviCodeNode) {
                final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
                for (final INaviInstruction instruction : codeNode.getInstructions()) {
                    if (instruction.getAddress().equals(address)) {
                        uncollapseParents(codeNode);
                        graph.showNode(node, true);
                        ZoomFunctions.zoomToNode(graph, node);
                        return IterationMode.STOP;
                    }
                }
            } else if (node.getRawNode() instanceof INaviFunctionNode) {
                final INaviFunctionNode functionNode = (INaviFunctionNode) node.getRawNode();
                if (functionNode.getFunction().getAddress().equals(address)) {
                    uncollapseParents(functionNode);
                    graph.showNode(node, true);
                    ZoomFunctions.zoomToNode(graph, node);
                    return IterationMode.STOP;
                }
            }
            return IterationMode.CONTINUE;
        }
    });
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) IterationMode(com.google.security.zynamics.zylib.types.common.IterationMode) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 14 with NaviNode

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

the class CDebuggerPainter method updateDebuggerHighlighting.

/**
   * Updates the program counter highlighting in a whole graph.
   *
   * @param graph The graph where the highlighting is updated.
   * @param address The address of the program counter to be highlighted.
   * @param module The module in which the address is located.
   */
public static void updateDebuggerHighlighting(final ZyGraph graph, final UnrelocatedAddress address, final INaviModule module) {
    Preconditions.checkNotNull(graph, "IE02187: Graph argument can not be null");
    Preconditions.checkNotNull(address, "IE02188: Address argument can not be null");
    graph.iterate(new INodeCallback<NaviNode>() {

        @Override
        public IterationMode next(final NaviNode node) {
            final INaviViewNode rawNode = node.getRawNode();
            if (rawNode instanceof ICodeNode) {
                final INaviCodeNode codeNode = (INaviCodeNode) rawNode;
                try {
                    if (module.equals(codeNode.getParentFunction().getModule())) {
                        updateDebuggerHighlighting(graph, address, node, codeNode);
                    }
                } catch (final MaybeNullException exception) {
                    CUtilityFunctions.logException(exception);
                }
            } else if (rawNode instanceof INaviFunctionNode) {
                final INaviFunctionNode functionNode = (INaviFunctionNode) rawNode;
                if (module.equals(functionNode.getFunction().getModule())) {
                    updateDebuggerHighlighting(address, node, functionNode);
                }
            }
            return IterationMode.CONTINUE;
        }
    });
    ZyZoomHelpers.zoomToAddress(graph, address.getAddress(), module, false);
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) ICodeNode(com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) IterationMode(com.google.security.zynamics.zylib.types.common.IterationMode)

Example 15 with NaviNode

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

the class OpenInLastWindowAndZoomToAddressAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent event) {
    final FutureCallback<Boolean> callBack = new FutureCallback<Boolean>() {

        @Override
        public void onFailure(final Throwable t) {
            CUtilityFunctions.logException(t);
        }

        @Override
        public void onSuccess(final Boolean result) {
            ZyGraph graph = null;
            final List<CGraphWindow> windows = CWindowManager.instance().getOpenWindows();
            for (final CGraphWindow graphContainer : windows) {
                for (final IGraphPanel window : graphContainer) {
                    if (reference.getView().equals(window.getModel().getGraph().getRawView())) {
                        graph = window.getModel().getGraph();
                    }
                }
            }
            for (final NaviNode node : graph.getNodes()) {
                if (node.getRawNode() instanceof INaviCodeNode) {
                    final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
                    for (final INaviInstruction instruction : codeNode.getInstructions()) {
                        if (instruction.getAddress().equals(reference.getAddress())) {
                            ZyZoomHelpers.zoomToAddress(graph, reference.getAddress());
                            CrossReferencePainter.paintCrossReference(node, codeNode, reference, instruction);
                        }
                    }
                }
            }
        }
    };
    CShowViewFunctions.showViewsAndPerformCallBack(m_parent, m_container, m_views, CWindowManager.instance().getLastWindow(), callBack);
}
Also used : CGraphWindow(com.google.security.zynamics.binnavi.Gui.GraphWindows.CGraphWindow) INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) ZyGraph(com.google.security.zynamics.binnavi.yfileswrap.zygraph.ZyGraph) IGraphPanel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphPanel) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) FutureCallback(com.google.common.util.concurrent.FutureCallback) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

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