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());
}
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);
}
}
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());
}
}
}
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");
}
}
}
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);
}
}
Aggregations