use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class OpenInLastWindowAndZoomToAddressAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent event) {
final FutureCallback<Boolean> callBack = new FutureCallback<Boolean>() {
@Override
public void onFailure(final Throwable t) {
CUtilityFunctions.logException(t);
}
@Override
public void onSuccess(final Boolean result) {
ZyGraph graph = null;
final List<CGraphWindow> windows = CWindowManager.instance().getOpenWindows();
for (final CGraphWindow graphContainer : windows) {
for (final IGraphPanel window : graphContainer) {
if (reference.getView().equals(window.getModel().getGraph().getRawView())) {
graph = window.getModel().getGraph();
}
}
}
for (final NaviNode node : graph.getNodes()) {
if (node.getRawNode() instanceof INaviCodeNode) {
final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
for (final INaviInstruction instruction : codeNode.getInstructions()) {
if (instruction.getAddress().equals(reference.getAddress())) {
ZyZoomHelpers.zoomToAddress(graph, reference.getAddress());
CrossReferencePainter.paintCrossReference(node, codeNode, reference, instruction);
}
}
}
}
}
};
CShowViewFunctions.showViewsAndPerformCallBack(m_parent, m_container, m_views, CWindowManager.instance().getLastWindow(), callBack);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CDataflowViewCreator method create.
/**
* Creates a new dataflow view.
*
* @param container The container in which the dataflow view is created.
* @param view The normal view that provides the control-flow information.
*
* @return The created dataflow view.
*
* @throws InternalTranslationException Thrown if the input view could not be translated to REIL.
*/
public static INaviView create(final IViewContainer container, final INaviView view) throws InternalTranslationException {
Preconditions.checkNotNull(container, "IE00411: Module argument can not be null");
Preconditions.checkNotNull(view, "IE00414: View argument can not be null");
final Map<IAddress, INaviInstruction> instructions = new HashMap<IAddress, INaviInstruction>();
for (final CCodeNode codeNode : view.getBasicBlocks()) {
for (final INaviInstruction instruction : codeNode.getInstructions()) {
instructions.put(instruction.getAddress(), instruction);
}
}
final ReilFunction function = view.getContent().getReilCode();
final OperandGraph operandGraph = OperandGraph.create(function.getGraph());
final INaviView dfView = container.createView(String.format("Data flow view of '%s'", view.getName()), "");
final Map<OperandGraphNode, INaviCodeNode> nodeMap = new HashMap<OperandGraphNode, INaviCodeNode>();
final Map<INaviInstruction, CCodeNode> instructionMap = new HashMap<INaviInstruction, CCodeNode>();
for (final OperandGraphNode operandGraphNode : operandGraph) {
final ReilInstruction reilInstruction = operandGraphNode.getInstruction();
final INaviInstruction instruction = instructions.get(ReilHelpers.toNativeAddress(reilInstruction.getAddress()));
if (instructionMap.containsKey(instruction)) {
nodeMap.put(operandGraphNode, instructionMap.get(instruction));
continue;
}
final CCodeNode codeNode = dfView.getContent().createCodeNode(null, Lists.newArrayList(instruction));
codeNode.setColor(ConfigManager.instance().getColorSettings().getBasicBlocksColor());
nodeMap.put(operandGraphNode, codeNode);
instructionMap.put(instruction, codeNode);
}
for (final OperandGraphEdge edge : operandGraph.getEdges()) {
final INaviCodeNode source = nodeMap.get(edge.getSource());
final INaviCodeNode target = nodeMap.get(edge.getTarget());
if (source.equals(target)) {
continue;
}
dfView.getContent().createEdge(source, target, EdgeType.JUMP_UNCONDITIONAL);
}
return dfView;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CViewInserter method insertCodeNode.
/**
* Clones a source node and inserts the cloned node into the target view.
*
* @param target The target view where the node is inserted.
* @param node Node from the source view that is cloned.
*
* @return The cloned code node.
*/
private static INaviCodeNode insertCodeNode(final INaviView target, final INaviCodeNode node) {
// TODO: cloning the node is a bad solution since this just fixes the symptoms: instructions are
// closed two times
final INaviCodeNode sourceNode = (INaviCodeNode) node.cloneNode();
final Iterable<INaviInstruction> instructions = sourceNode.getInstructions();
final ArrayList<INaviInstruction> instructionList = Lists.newArrayList(instructions);
CCodeNode codeNode;
try {
codeNode = target.getContent().createCodeNode(sourceNode.getParentFunction(), instructionList);
} catch (final MaybeNullException e) {
codeNode = target.getContent().createCodeNode(null, instructionList);
}
if (sourceNode.getComments().getGlobalCodeNodeComment() != null) {
codeNode.getComments().initializeGlobalCodeNodeComment(sourceNode.getComments().getGlobalCodeNodeComment());
}
if (sourceNode.getComments().getLocalCodeNodeComment() != null) {
codeNode.getComments().initializeLocalCodeNodeComment(sourceNode.getComments().getLocalCodeNodeComment());
}
final Iterable<INaviInstruction> newInstructions = codeNode.getInstructions();
for (int i = 0; i < Iterables.size(instructions); i++) {
codeNode.getComments().initializeLocalInstructionComment(Iterables.get(newInstructions, i), sourceNode.getComments().getLocalInstructionComment(Iterables.get(instructions, i)));
}
return codeNode;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class View method createCodeNode.
// ! Creates a new code node.
/**
* Creates a code node in the view.
*
* @param function The parent function of the code node. This argument is optional can can be
* null.
* @param instructions The instructions that should be displayed in the code node.
*
* @return The created code node.
*/
public CodeNode createCodeNode(final Function function, final List<Instruction> instructions) {
Preconditions.checkNotNull(instructions, "Error: Instructions argument can't be null");
final List<INaviInstruction> instructionsList = new ArrayList<INaviInstruction>();
for (final Instruction instruction : instructions) {
Preconditions.checkNotNull(instruction, "Error: Instruction list contains a null-element");
instructionsList.add(instruction.getNative());
}
assert !instructions.isEmpty();
final CCodeNode newCodenode = naviView.getContent().createCodeNode(function == null ? null : function.getNative(), instructionsList);
newCodenode.setColor(ConfigManager.instance().getColorSettings().getBasicBlocksColor());
return (CodeNode) cachedNodes.get(newCodenode);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CSteppingHelper method getAddress.
/**
* Determines the start address of a node.
*
* @param node Node whose address is determined.
*
* @return The start address of the given node or null if the node does not have an address.
*/
private static BreakpointAddress getAddress(final INaviViewNode node) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode ccnode = (INaviCodeNode) node;
final INaviInstruction instruction = Iterables.getFirst(ccnode.getInstructions(), null);
return new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress()));
} else if (node instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) node).getFunction();
final INaviModule module = function.getModule();
return new BreakpointAddress(module, new UnrelocatedAddress(function.getAddress()));
} else {
// Node types we can not step to
return null;
}
}
Aggregations