use of com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode in project binnavi by google.
the class View method createNode.
// ! Clones an existing node.
/**
* Creates a new view node by cloning an existing view node.
*
* @param node The node to clone.
*
* @return The cloned node.
*/
public ViewNode createNode(final ViewNode node) {
Preconditions.checkNotNull(node, "Error: Node argument can not be null");
if (node instanceof CodeNode) {
final List<INaviInstruction> instructionsList = new ArrayList<INaviInstruction>();
for (final Instruction instruction : ((CodeNode) node).getInstructions()) {
Preconditions.checkNotNull(instruction, "Error: Instruction list contains a null-element");
instructionsList.add(instruction.getNative());
}
CCodeNode newNode;
try {
newNode = naviView.getContent().createCodeNode(((INaviCodeNode) node.getNative()).getParentFunction(), instructionsList);
} catch (final MaybeNullException e) {
newNode = naviView.getContent().createCodeNode(null, instructionsList);
}
adjustAttributes(node, newNode);
return cachedNodes.get(newNode);
} else if (node instanceof FunctionNode) {
final CFunctionNode newNode = naviView.getContent().createFunctionNode(((INaviFunctionNode) node.getNative()).getFunction());
adjustAttributes(node, newNode);
return cachedNodes.get(newNode);
} else if (node instanceof TextNode) {
final CTextNode newNode = naviView.getContent().createTextNode(((TextNode) node).getComments());
adjustAttributes(node, newNode);
return cachedNodes.get(newNode);
} else if (node instanceof GroupNode) {
throw new IllegalStateException("Group nodes can not be cloned");
} else {
throw new IllegalStateException("Error: Unknown node type");
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode in project binnavi by google.
the class CMenuBuilder method addSelectionMenus.
/**
* Adds menus related to node selection to a given node context menu.
*
* @param menu The node context menu to extend.
* @param graph The graph the clicked node belongs to.
* @param node The clicked node.
*/
public static void addSelectionMenus(final JPopupMenu menu, final ZyGraph graph, final NaviNode node) {
Preconditions.checkNotNull(menu, "IE02144: Menu argument can not be null");
Preconditions.checkNotNull(graph, "IE02145: Graph argument can not be null");
Preconditions.checkNotNull(node, "IE02146: Node argument can not be null");
final JMenu selectionMenu = new JMenu("Selection");
selectionMenu.add(CActionProxy.proxy(new CActionSelectNodePredecessors(graph, node)));
selectionMenu.add(CActionProxy.proxy(new CActionSelectNodeSuccessors(graph, node)));
if (graph.getSelectedNodes().size() > 0) {
selectionMenu.add(CActionProxy.proxy(new CGroupAction(graph)));
}
if (node.getRawNode() instanceof INaviCodeNode) {
try {
final INaviFunction parentFunction = ((INaviCodeNode) node.getRawNode()).getParentFunction();
selectionMenu.add(CActionProxy.proxy(new CActionSelectSameParentFunction(graph, parentFunction)));
} catch (final MaybeNullException exception) {
// Obviously we can not select nodes of the same parent function if there
// is no parent function.
}
} else if (node.getRawNode() instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) node.getRawNode()).getFunction();
selectionMenu.add(CActionProxy.proxy(new CActionSelectSameFunctionType(graph, function.getType())));
}
menu.add(selectionMenu);
menu.addSeparator();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode in project binnavi by google.
the class CDebuggerPainter method updateSingleNodeDebuggerHighlighting.
/**
* Updates the debugger highlighting for a single node
*
* @param graph The graph in which the node is located
* @param address The address of the breakpoint
* @param node The node in which the breakpoint is located.
*/
public static void updateSingleNodeDebuggerHighlighting(final ZyGraph graph, final UnrelocatedAddress address, final NaviNode node) {
Preconditions.checkNotNull(graph, "IE01192: Graph argument can not be null");
Preconditions.checkNotNull(address, "IE01216: Address argument can not be null");
final INaviViewNode rawNode = node.getRawNode();
if (rawNode instanceof ICodeNode) {
final INaviCodeNode codeNode = (INaviCodeNode) rawNode;
updateDebuggerHighlighting(graph, address, node, codeNode);
} else if (rawNode instanceof INaviFunctionNode) {
final INaviFunctionNode functionNode = (INaviFunctionNode) rawNode;
updateDebuggerHighlighting(address, node, functionNode);
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode 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);
}
}
}
Aggregations