Search in sources :

Example 11 with INaviViewNode

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

the class CView method save.

@Override
public void save() throws CouldntSaveDataException {
    Preconditions.checkArgument(getType() == ViewType.NonNative, "IE00314: Native views can not be saved");
    Preconditions.checkState(isLoaded(), "IE00315: View must be loaded before it can be saved");
    if (m_configuration.isStored()) {
        m_provider.save(this);
    } else {
        CView newView;
        final INaviModule naviModule = m_configuration.getModule();
        if (naviModule == null) {
            newView = m_provider.createView(m_configuration.getProject(), this, getName(), m_configuration.getDescription());
        } else {
            newView = m_provider.createView(naviModule, this, getName(), m_configuration.getDescription());
        }
        m_configuration.setId(newView.getConfiguration().getId());
    }
    final IDirectedGraph<INaviViewNode, INaviEdge> graph = m_content.getGraph();
    m_bbcount = graph.nodeCount();
    m_edgecount = graph.edgeCount();
    for (final INaviViewListener listener : m_listeners) {
        listener.savedView(this);
    }
    m_configuration.updateModificationDate();
    m_content.save();
    m_lastGraphType = m_content.getGraphType();
    // Update caches.
    NodeCache.get(m_provider).addNodes(graph.getNodes());
    EdgeCache.get(m_provider).addEdges(graph.getEdges());
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge)

Example 12 with INaviViewNode

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

the class CViewContent method updateGraphType.

/**
   * Calculates the new graph type of the view from the current state of the view graph.
   */
private void updateGraphType() {
    boolean hasCodeNode = false;
    boolean hasFunctionNode = false;
    for (final INaviViewNode node : graph.getNodes()) {
        if (node instanceof INaviFunctionNode) {
            hasFunctionNode = true;
            if (hasCodeNode) {
                setGraphType(GraphType.MIXED_GRAPH);
                return;
            }
        } else if (node instanceof INaviCodeNode) {
            hasCodeNode = true;
            if (hasFunctionNode) {
                setGraphType(GraphType.MIXED_GRAPH);
                return;
            }
        }
    }
    if (hasCodeNode) {
        setGraphType(GraphType.FLOWGRAPH);
    } else if (hasFunctionNode) {
        setGraphType(GraphType.CALLGRAPH);
    } else {
        setGraphType(GraphType.MIXED_GRAPH);
    }
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)

Example 13 with INaviViewNode

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

the class CUnInliner method getInlinedNodes.

/**
   * Determines inlining information starting with a given node.
   * TODO(thomasdullien): This code is pretty thoroughly broken for any form of
   * nested inlining and needs to be rewritten.
   *
   * @param node The start node.
   *
   * @return Information about the inlining boundaries.
   */
public static CInlinedNodes getInlinedNodes(final INaviCodeNode node) {
    Preconditions.checkNotNull(node, "IE02750: node argument can not be null");
    // Performs a recursive backward search upward in the graph until it finds
    // an 'enter inlined function' edge, then returns it's source node. This
    // will usually be "a function layer up" from the function that is about to
    // be uninlined. Please note that if, while searching up, it enters a
    // different inlined subfunction, this function will return a wrong node.
    final INaviCodeNode startNode = searchForSourceNodeOfEnterInlinedEdge(node);
    // Performs a recursive forward search downward in the graph until it finds
    // a 'leave inlined function' edge whose source node is in the same function
    // as 'node'. Returns the target of this edge. Please note that if, while
    // searching down a second nested inlined version of the current function is
    // found, this code will return the wrong node.
    final INaviCodeNode endNode = getEndNode(node);
    if (startNode == null || endNode == null) {
        return null;
    }
    // to simply carry on for now until the above functions can be fixed.
    if (hasDifferentParentFunctions(startNode, endNode)) {
        NaviLogger.info("Uninlining yielded almost certainly incorrect results.");
    }
    final Set<INaviViewNode> preds = GraphAlgorithms.getPredecessorsUpToNode(endNode, startNode);
    final Set<INaviViewNode> succs = GraphAlgorithms.getSuccessorsDownToNode(startNode, endNode);
    preds.retainAll(succs);
    return new CInlinedNodes(startNode, endNode, ImmutableList.copyOf(preds));
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode)

Example 14 with INaviViewNode

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

the class CViewInserter method createNodes.

/**
   * Clones a node of the source view and inserts it into the target view.
   *
   * @param target The target view where the cloned view is inserted.
   * @param sourceNode The source node that is cloned and inserted into the target view.
   * @param nodeMap Maps nodes of the source view to their cloned counterparts.
   */
private static void createNodes(final INaviView target, final INaviViewNode sourceNode, final Map<INaviViewNode, INaviViewNode> nodeMap) {
    final INaviViewNode newNode = CNodeTypeSwitcher.switchNode(sourceNode, new INodeTypeCallback<INaviViewNode>() {

        @Override
        public INaviViewNode handle(final INaviCodeNode node) {
            return insertCodeNode(target, node);
        }

        @Override
        public INaviViewNode handle(final INaviFunctionNode node) {
            return insertFunctionNode(target, node);
        }

        @Override
        public INaviViewNode handle(final INaviGroupNode node) {
            // Skip now, create later
            return null;
        }

        @Override
        public INaviViewNode handle(final INaviTextNode node) {
            return insertTextNode(target, node);
        }
    });
    if (newNode != null) {
        newNode.setBorderColor(sourceNode.getBorderColor());
        newNode.setColor(sourceNode.getColor());
        newNode.setHeight(sourceNode.getHeight());
        newNode.setSelected(sourceNode.isSelected());
        newNode.setVisible(sourceNode.isVisible());
        newNode.setWidth(sourceNode.getWidth());
        newNode.setX(sourceNode.getX());
        newNode.setY(sourceNode.getY());
        nodeMap.put(sourceNode, newNode);
    }
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviTextNode(com.google.security.zynamics.binnavi.disassembly.INaviTextNode) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)

Example 15 with INaviViewNode

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

the class CViewInserter method createEdges.

/**
   * Clones the edges of the source view and inserts them into the target view.
   *
   * @param target The target view where the cloned edges are inserted.
   * @param edges The source edges that are cloned.
   * @param nodeMap Maps between the source nodes and their cloned counterparts.
   */
private static void createEdges(final INaviView target, final List<INaviEdge> edges, final Map<INaviViewNode, INaviViewNode> nodeMap) {
    for (final INaviEdge edge : edges) {
        final INaviViewNode sourceNode = nodeMap.get(edge.getSource());
        final INaviViewNode targetNode = nodeMap.get(edge.getTarget());
        final CNaviViewEdge newEdge = target.getContent().createEdge(sourceNode, targetNode, edge.getType());
        newEdge.setColor(edge.getColor());
        newEdge.setX1(edge.getX1());
        newEdge.setY1(edge.getY1());
        newEdge.setX2(edge.getX2());
        newEdge.setY2(edge.getY2());
        for (final CBend bend : edge.getBends()) {
            newEdge.addBend(bend.getX(), bend.getY());
        }
    }
}
Also used : CNaviViewEdge(com.google.security.zynamics.binnavi.disassembly.CNaviViewEdge) CBend(com.google.security.zynamics.zylib.gui.zygraph.edges.CBend) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge)

Aggregations

INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)73 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)22 INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)21 Test (org.junit.Test)16 INaviGroupNode (com.google.security.zynamics.binnavi.disassembly.INaviGroupNode)14 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)13 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)12 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)12 INaviFunctionNode (com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode)11 ArrayList (java.util.ArrayList)10 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)9 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)9 CNaviViewEdge (com.google.security.zynamics.binnavi.disassembly.CNaviViewEdge)9 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)9 CGroupNode (com.google.security.zynamics.binnavi.disassembly.CGroupNode)8 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)8 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)8 INaviTextNode (com.google.security.zynamics.binnavi.disassembly.INaviTextNode)7 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)7 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)7