Search in sources :

Example 1 with IterationMode

use of com.google.security.zynamics.zylib.types.common.IterationMode 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 2 with IterationMode

use of com.google.security.zynamics.zylib.types.common.IterationMode 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 3 with IterationMode

use of com.google.security.zynamics.zylib.types.common.IterationMode in project binnavi by google.

the class CStepEndHelper method getEndAddresses.

/**
   * Returns the addresses of all final instructions of a graph.
   *
   * @param graph The graph whose final addresses are returned.
   *
   * @return The final addresses of the graph.
   */
public static Set<BreakpointAddress> getEndAddresses(final ZyGraph graph) {
    final Set<BreakpointAddress> instructions = new HashSet<BreakpointAddress>();
    graph.iterate(new INodeCallback<NaviNode>() {

        @Override
        public IterationMode next(final NaviNode node) {
            if ((node.getRawNode() instanceof INaviCodeNode) && node.getChildren().isEmpty()) {
                final INaviCodeNode cnode = (INaviCodeNode) node.getRawNode();
                final INaviInstruction lastInstruction = Iterables.getLast(cnode.getInstructions());
                instructions.add(new BreakpointAddress(lastInstruction.getModule(), new UnrelocatedAddress(lastInstruction.getAddress())));
            }
            return IterationMode.CONTINUE;
        }
    });
    return instructions;
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) NaviNode(com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) IterationMode(com.google.security.zynamics.zylib.types.common.IterationMode) HashSet(java.util.HashSet) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Aggregations

INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)3 IterationMode (com.google.security.zynamics.zylib.types.common.IterationMode)3 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)2 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)2 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)1 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)1 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)1 ICodeNode (com.google.security.zynamics.zylib.gui.zygraph.nodes.ICodeNode)1 HashSet (java.util.HashSet)1