use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CViewPruner method convertEdges.
/**
* Converts edges of the original view to the pruned view.
*
* @param view The original view.
* @param prunedView The pruned view.
* @param nodeMap A mapping between nodes of the original view and nodes of the pruned view.
*/
private static void convertEdges(final INaviView view, final INaviView prunedView, final Map<INaviViewNode, INaviViewNode> nodeMap) {
final Set<Pair<INaviViewNode, INaviViewNode>> createdEdges = new HashSet<Pair<INaviViewNode, INaviViewNode>>();
for (final INaviEdge edge : view.getGraph().getEdges()) {
final Set<EdgeResult> sources = getSources(edge, nodeMap, new HashSet<INaviEdge>());
final Set<EdgeResult> targets = getTargets(edge, nodeMap, new HashSet<INaviEdge>());
for (final EdgeResult source : sources) {
for (final EdgeResult target : targets) {
final Pair<INaviViewNode, INaviViewNode> edgePair = new Pair<INaviViewNode, INaviViewNode>(source.m_node, target.m_node);
if (createdEdges.contains(edgePair)) {
continue;
}
prunedView.getContent().createEdge(source.m_node, target.m_node, source.m_type);
createdEdges.add(edgePair);
}
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CViewPruner method getTargets.
/**
* Collects edge information about incoming edges.
*
* @param edge The edge whose information is collected.
* @param nodeMap Maps between nodes of the old view and nodes of the new view.
* @param visited Already visited edges.
*
* @return The collected edge information.
*/
private static Set<EdgeResult> getTargets(final INaviEdge edge, final Map<INaviViewNode, INaviViewNode> nodeMap, final Set<INaviEdge> visited) {
final INaviViewNode target = edge.getTarget();
visited.add(edge);
final Set<EdgeResult> targets = new HashSet<EdgeResult>();
if (nodeMap.containsKey(target)) {
targets.add(new EdgeResult(nodeMap.get(target), edge.getType()));
} else {
for (final INaviEdge outgoingEdge : target.getOutgoingEdges()) {
if (!visited.contains(outgoingEdge)) {
targets.addAll(getTargets(outgoingEdge, nodeMap, visited));
}
}
}
return targets;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CViewPruner method convertNodes.
/**
* Converts the nodes from the original view to the pruned view.
*
* @param view The original view.
* @param prunedView The pruned view.
* @param keptInstructions Instructions to add to the new view.
*
* @return A mapping between nodes of the original view and nodes of the pruned view.
*/
private static Map<INaviViewNode, INaviViewNode> convertNodes(final INaviView view, final INaviView prunedView, final List<INaviInstruction> keptInstructions) {
final Map<INaviViewNode, INaviViewNode> nodeMap = new HashMap<INaviViewNode, INaviViewNode>();
for (final INaviViewNode node : view.getGraph().getNodes()) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode cnode = (INaviCodeNode) node;
final ArrayList<INaviInstruction> newInstructions = Lists.newArrayList(cnode.getInstructions());
newInstructions.retainAll(keptInstructions);
if (!newInstructions.isEmpty()) {
CCodeNode newNode;
try {
newNode = prunedView.getContent().createCodeNode(cnode.getParentFunction(), newInstructions);
} catch (final MaybeNullException e) {
newNode = prunedView.getContent().createCodeNode(null, newInstructions);
}
newNode.setBorderColor(node.getBorderColor());
newNode.setColor(node.getColor());
nodeMap.put(node, newNode);
}
} else if (node instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) node).getFunction();
final CFunctionNode newNode = prunedView.getContent().createFunctionNode(function);
nodeMap.put(node, newNode);
}
}
return nodeMap;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CViewPruner method prune.
/**
* Creates a new view from the results of an operand tracking operation.
*
* @param container Container where the new view is created.
* @param view Input view that provides the data.
* @param keptInstructions Instructions to add to the new view.
*
* @return The new view.
*/
public static INaviView prune(final IViewContainer container, final INaviView view, final List<INaviInstruction> keptInstructions) {
final INaviView prunedView = container.createView("Pruned View", "");
final Map<INaviViewNode, INaviViewNode> nodeMap = convertNodes(view, prunedView, keptInstructions);
convertEdges(view, prunedView, nodeMap);
return prunedView;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CCrossReferencesPanel method visit.
@Override
public void visit(final CGraphModel model, final IGraphPanelExtender extender) {
m_parent = model.getParent();
m_viewContainer = model.getViewContainer();
for (final INaviViewNode node : model.getGraph().getRawView().getGraph().getNodes()) {
processNewNode(node);
}
m_tableModel.setCrossReferences(m_crossReferences);
extender.addTab("Calling Functions", this);
model.getGraph().getRawView().addListener(m_internalListener);
}
Aggregations