use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CRegisterTrackingHelper method getInstructionMap.
/**
* Creates an address -> instruction mapping for all instructions in a graph.
*
* @param view The input graph.
* @return The created mapping.
*/
public static Map<IAddress, INaviInstruction> getInstructionMap(final INaviView view) {
final Map<IAddress, INaviInstruction> instructionMap = new HashMap<IAddress, INaviInstruction>();
final List<INaviViewNode> nodes = view.getGraph().getNodes();
for (final INaviViewNode node : nodes) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode cnode = (INaviCodeNode) node;
for (final INaviInstruction instruction : cnode.getInstructions()) {
instructionMap.put(instruction.getAddress(), instruction);
}
}
}
return instructionMap;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CViewPruner method getSources.
/**
* Collects edge information about outgoing 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> getSources(final INaviEdge edge, final Map<INaviViewNode, INaviViewNode> nodeMap, final Set<INaviEdge> visited) {
final INaviViewNode source = edge.getSource();
visited.add(edge);
final Set<EdgeResult> sources = new HashSet<EdgeResult>();
if (nodeMap.containsKey(source)) {
sources.add(new EdgeResult(nodeMap.get(source), edge.getType()));
} else {
for (final INaviEdge incomingEdge : source.getIncomingEdges()) {
if (!visited.contains(incomingEdge)) {
sources.addAll(getSources(incomingEdge, nodeMap, visited));
}
}
}
return sources;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CNodeClickHandler method nodeClicked.
/**
* Handles clicks on nodes.
*
* @param node The clicked node.
* @param event The click event.
* @param x The x-coordinate of the click.
* @param y The y-coordinate of the click.
* @param extensions List of objects that extend code node context menus.
*/
public void nodeClicked(final NaviNode node, final MouseEvent event, final double x, final double y, final List<ICodeNodeExtension> extensions) {
if (event.getButton() == MouseEvent.BUTTON3) {
handleRightClick(node, event, x, y, extensions);
} else if ((event.getButton() == MouseEvent.BUTTON1) && (event.getClickCount() == 2) && event.isControlDown()) {
final INaviViewNode rawNode = node.getRawNode();
if (rawNode instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) rawNode).getFunction();
CGraphOpener.showFunction(m_model.getParent(), m_model.getViewContainer(), function);
} else if (rawNode instanceof INaviCodeNode) {
final INaviCodeNode cnode = (INaviCodeNode) rawNode;
final int row = node.positionToRow(y - node.getY());
final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(cnode, row);
if (instruction == null) {
return;
}
final Set<IAddress> references = new HashSet<IAddress>();
for (final INaviOperandTree operand : instruction.getOperands()) {
collectReferences(operand.getRootNode(), references);
}
final List<INaviFunction> functions = m_model.getViewContainer().getFunctions();
for (final INaviFunction function : functions) {
for (final IAddress address : references) {
if (function.getAddress().equals(address)) {
CGraphOpener.showFunction(m_model.getParent(), m_model.getViewContainer(), function);
}
}
}
}
} else if (!m_model.getGraph().getEditMode().getLabelEventHandler().isActive() && (event.getButton() == MouseEvent.BUTTON1) && (event.getClickCount() == 2)) {
if ((node.getRawNode() instanceof INaviGroupNode) && event.isShiftDown()) {
final INaviGroupNode gnode = (INaviGroupNode) node.getRawNode();
gnode.setCollapsed(!gnode.isCollapsed());
} else {
CGraphZoomer.zoomNode(m_model.getGraph(), node);
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CViewContent method deleteNodes.
@Override
public void deleteNodes(final Collection<INaviViewNode> nodes) {
Preconditions.checkNotNull(nodes, "IE00305: Nodes argument can not be null");
// Make defensive copy in order to evade the concurrent modification exception
final Collection<INaviViewNode> nodesCopy = new ArrayList<INaviViewNode>(nodes);
final List<INaviViewNode> gnodes = graph.getNodes();
for (final INaviViewNode naviViewNode : nodesCopy) {
Preconditions.checkNotNull(naviViewNode, "IE00307: Node list contains a null-node");
Preconditions.checkArgument(gnodes.contains(naviViewNode), "IE00308: Node list contains at least one node that is not part of this view");
}
final List<INaviGroupNode> parentsToDelete = new ArrayList<INaviGroupNode>();
for (final INaviViewNode node : nodesCopy) {
if (node instanceof INaviGroupNode) {
if (((INaviGroupNode) node).getNumberOfElements() != 0) {
deleteGroupNode((INaviGroupNode) node);
}
continue;
}
removeEdges(node);
graph.removeNode(node);
node.removeListener(m_internalNodeListener);
final INaviGroupNode parent = node.getParentGroup();
if (parent != null) {
parent.removeElement(node);
if (parent.getParentGroup() != null) {
parent.getParentGroup().addElement(node);
}
if (parent.getNumberOfElements() == 0) {
parentsToDelete.add(parent);
}
}
}
// We remove group nodes from the list of nodes that are put into the listener notification
// because deletedNode notifications were already sent for group nodes when they lost their last
// member.
final Collection<INaviViewNode> filteredNodes = filterGroupNodes(nodesCopy);
for (final INaviViewListener listener : listeners) {
try {
listener.deletedNodes(view, filteredNodes);
} catch (final Exception exception) {
CUtilityFunctions.logException(exception);
}
}
updateGraphType();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviViewNode in project binnavi by google.
the class CUnInliner method removeTextNodes.
/**
* Removes text nodes from the deleted nodes.
*
* @param view The view from which the nodes are deleted.
* @param nodes The nodes whose attached text nodes are removed from.
*/
private static void removeTextNodes(final INaviView view, final ImmutableList<INaviViewNode> nodes) {
final Set<INaviViewNode> toDelete = new HashSet<INaviViewNode>();
for (final INaviViewNode node : nodes) {
for (final INaviViewNode parent : node.getParents()) {
if (parent instanceof INaviTextNode) {
toDelete.add(parent);
}
}
}
view.getContent().deleteNodes(toDelete);
}
Aggregations