Search in sources :

Example 1 with INaviEdge

use of com.google.security.zynamics.binnavi.disassembly.INaviEdge 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 2 with INaviEdge

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

the class CViewContent method removeEdges.

/**
 * Returns all incoming and outgoing edges of a node from the view.
 *
 * @param node The view whose edges are removed.
 */
private void removeEdges(final INaviViewNode node) {
    if (node instanceof INaviGroupNode) {
        // Group nodes can not have real edges attached to them
        return;
    }
    final Set<INaviEdge> toDelete = new HashSet<INaviEdge>();
    for (final INaviEdge incomingEdge : node.getIncomingEdges()) {
        incomingEdge.getSource().removeChild(node);
        incomingEdge.getSource().removeOutgoingEdge(incomingEdge);
        toDelete.add(incomingEdge);
    }
    for (final INaviEdge outgoingEdge : node.getOutgoingEdges()) {
        outgoingEdge.getTarget().removeParent(node);
        outgoingEdge.getTarget().removeIncomingEdge(outgoingEdge);
        toDelete.add(outgoingEdge);
    }
    for (final INaviEdge edge : toDelete) {
        deleteEdge(edge);
    }
}
Also used : INaviGroupNode(com.google.security.zynamics.binnavi.disassembly.INaviGroupNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) HashSet(java.util.HashSet)

Example 3 with INaviEdge

use of com.google.security.zynamics.binnavi.disassembly.INaviEdge 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)

Example 4 with INaviEdge

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

the class CGraphInliner method inlineAll.

/**
 * Inlines all function calls of a given graph.
 *
 * @param parent Parent window used for dialogs.
 * @param container Contains the functions to be inlined.
 * @param graph Graph where the inline operation takes place.
 */
public static void inlineAll(final JFrame parent, final IViewContainer container, final ZyGraph graph) {
    Preconditions.checkNotNull(parent, "IE02285: Parent argument can not be null");
    Preconditions.checkNotNull(container, "IE02286: Container argument can not be null");
    Preconditions.checkNotNull(graph, "IE02287: Graph Argument can not be null");
    final MutableDirectedGraph<INaviViewNode, INaviEdge> mutableGraph = (MutableDirectedGraph<INaviViewNode, INaviEdge>) graph.getRawView().getGraph();
    final List<INaviViewNode> nodes = mutableGraph.getNodes();
    final HashMap<INaviInstruction, INaviFunction> instructionToFunctionMap = new HashMap<INaviInstruction, INaviFunction>();
    for (final INaviViewNode iNaviViewNode : nodes) {
        if (iNaviViewNode instanceof INaviCodeNode) {
            instructionToFunctionMap.putAll(CReferenceFinder.getCodeReferenceMap((INaviCodeNode) iNaviViewNode));
        }
    }
    for (final INaviInstruction iNaviInstruction : instructionToFunctionMap.keySet()) {
        INaviCodeNode updatedNode = null;
        for (final INaviViewNode iNaviViewNode2 : graph.getRawView().getGraph().getNodes()) {
            final INaviCodeNode codeNode = (INaviCodeNode) iNaviViewNode2;
            if (codeNode.hasInstruction(iNaviInstruction)) {
                updatedNode = codeNode;
            }
        }
        if (updatedNode != null) {
            inlineFunctionSilently(parent, container, graph, updatedNode, iNaviInstruction, instructionToFunctionMap.get(iNaviInstruction));
        } else {
            throw new IllegalStateException("IE01174: Graph final has been rendered final to an final inconsitant state");
        }
    }
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) HashMap(java.util.HashMap) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) MutableDirectedGraph(com.google.security.zynamics.zylib.types.graphs.MutableDirectedGraph) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 5 with INaviEdge

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

the class PostgreSQLViewLoader method loadView.

/**
 * Loads the graph of a view from the database.
 *
 * @param provider The SQL provider that provides the connection.
 * @param view The view to load.
 * @param list A list of all modules that are part of the database.
 * @param nodeTagManager Node tag manager of the database.
 *
 * @return The graph of the view.
 *
 * @throws CouldntLoadDataException Thrown if the graph of view could not be loaded.
 * @throws CPartialLoadException Thrown if the graph could not be loaded because not all required
 *         modules are loaded.
 */
public static MutableDirectedGraph<INaviViewNode, INaviEdge> loadView(final AbstractSQLProvider provider, final INaviView view, final List<INaviModule> list, final CTagManager nodeTagManager) throws CouldntLoadDataException, CPartialLoadException {
    checkArguments(provider, view, list, nodeTagManager);
    try {
        final List<INaviViewNode> nodes = PostgreSQLNodeLoader.loadNodes(provider, view, list, nodeTagManager);
        NodeCache.get(provider).addNodes(nodes);
        final List<INaviEdge> edges = PostgreSQLEdgeLoader.loadEdges(provider, view, nodes);
        EdgeCache.get(provider).addEdges(edges);
        return new MutableDirectedGraph<INaviViewNode, INaviEdge>(nodes, edges);
    } catch (final SQLException exception) {
        throw new CouldntLoadDataException(exception);
    }
}
Also used : SQLException(java.sql.SQLException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) MutableDirectedGraph(com.google.security.zynamics.zylib.types.graphs.MutableDirectedGraph)

Aggregations

INaviEdge (com.google.security.zynamics.binnavi.disassembly.INaviEdge)47 INaviViewNode (com.google.security.zynamics.binnavi.disassembly.INaviViewNode)21 Test (org.junit.Test)17 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)9 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)9 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)8 EdgeCommentNotificationContainer (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.containers.EdgeCommentNotificationContainer)7 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)7 CCodeNode (com.google.security.zynamics.binnavi.disassembly.CCodeNode)7 CNaviViewEdge (com.google.security.zynamics.binnavi.disassembly.CNaviViewEdge)7 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)7 CBend (com.google.security.zynamics.zylib.gui.zygraph.edges.CBend)7 CommentNotification (com.google.security.zynamics.binnavi.Database.PostgreSQL.Notifications.interfaces.CommentNotification)6 MockInstruction (com.google.security.zynamics.binnavi.disassembly.MockInstruction)6 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)6 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)5 MockFunction (com.google.security.zynamics.binnavi.disassembly.MockFunction)5 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)5 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)5