use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CStepOverHelper method stepInCodeNode.
/**
* Adds the addresses of a instructions that follow another instruction to a list when
* single-stepping in a code node.
*
* @param node The code node where the step over operation happens.
* @param address The address in question.
* @param instructions List to extend with the successor instructions.
*/
private static void stepInCodeNode(final INaviCodeNode node, final UnrelocatedAddress address, final Set<BreakpointAddress> instructions) {
final int instructionIndex = CCodeNodeHelpers.getInstruction(node, address.getAddress());
if (instructionIndex != -1) {
if (instructionIndex < node.instructionCount() - 1) {
// ... and the basic block is large enough that the following
// instruction is also part of the basic block.
final INaviInstruction instruction = Iterables.get(node.getInstructions(), instructionIndex + 1);
instructions.add(new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress())));
} else {
// ... but the instruction is the last instruction of the basic block,
// so we have to look into the child nodes of the basic block.
instructions.addAll(CSteppingHelper.getSuccessors(node));
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CReilViewCreator method create.
/**
* Creates a REIL view from a view.
*
* @param container The container in which the new REIL view is created.
* @param view The view to be translated to REIL code.
*
* @return The created REIL code view.
*
* @throws InternalTranslationException Thrown if the view could not be translated to REIL code.
* @throws CouldntLoadDataException
*/
public static INaviView create(final INaviModule container, final INaviView view) throws InternalTranslationException, CouldntLoadDataException {
Preconditions.checkNotNull(container, "IE01768: Container argument can not be null");
Preconditions.checkNotNull(view, "IE01769: View argument can not be null");
final Map<IAddress, String> textMap = new HashMap<IAddress, String>();
for (final CCodeNode node : view.getBasicBlocks()) {
for (final INaviInstruction instruction : node.getInstructions()) {
textMap.put(instruction.getAddress(), instruction.toString());
}
}
final INaviView reilView = CReilViewCreator.create(container, view.getContent().getReilCode().getGraph());
for (final CCodeNode node : reilView.getBasicBlocks()) {
for (final INaviInstruction reilInstruction : node.getInstructions()) {
if ((reilInstruction.getAddress().toLong() & 0xFF) == 0) {
try {
node.getComments().appendLocalInstructionComment(reilInstruction, textMap.get(ReilHelpers.toNativeAddress(reilInstruction.getAddress())));
} catch (final CouldntSaveDataException e) {
// Not possible for unsaved views.
CUtilityFunctions.logException(e);
}
}
}
}
return reilView;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CViewContent method createCodeNode.
@Override
public CCodeNode createCodeNode(final INaviFunction parentFunction, final List<? extends INaviInstruction> instructions) {
Preconditions.checkNotNull(instructions, "IE00286: Instructions argument can not be null");
if ((parentFunction != null) && !parentFunction.inSameDatabase(provider)) {
throw new IllegalArgumentException("IE00287: Parent function and view are not in the same database");
}
for (final INaviInstruction instruction : instructions) {
Preconditions.checkNotNull(instruction, "IE00288: Instruction list contains a null-instruction");
Preconditions.checkArgument(instruction.inSameDatabase(provider), "IE00289: Instruction and view are not in the same database");
}
final CCodeNode codeNode = new CCodeNode(-1, 0, 0, 0, 0, Color.WHITE, Color.BLACK, false, true, null, parentFunction, new HashSet<CTag>(), provider);
for (final INaviInstruction instruction : instructions) {
codeNode.addInstruction(instruction, null);
}
addNode(codeNode);
updateGraphType(codeNode);
codeNode.addListener(m_internalNodeListener);
m_reilFunction = null;
return codeNode;
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CCodeNodeUpdater method removeListeners.
/**
* Removes all listeners this class has attached.
*/
private void removeListeners() {
try {
codeNode.getParentFunction().removeListener(functionUpdater);
codeNode.getParentFunction().getModule().removeListener(moduleUpdater);
} catch (final MaybeNullException exception) {
// The code nodes does not have a parent function, therefore the information
// about the parent function is not shown in the code and does not have to
// be processed when updating.
}
codeNode.removeListener(codeNodeListener);
for (final INaviInstruction instruction : codeNode.getInstructions()) {
instruction.removeListener(instructionUpdater);
}
final Iterator<CTag> it = codeNode.getTagsIterator();
while (it.hasNext()) {
it.next().removeListener(tagUpdater);
}
for (final IDebugger debugger : provider.getDebuggers()) {
debugger.getProcessManager().removeListener(debuggerUpdater);
}
provider.removeListener(debuggerProviderListener);
graph.getSettings().getDisplaySettings().removeListener(settingsUpdater);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviInstruction in project binnavi by google.
the class CCodeNodeUpdater method generateContent.
@Override
public void generateContent(final IZyNodeRealizer realizer, final ZyLabelContent content) {
ZyCodeNodeBuilder.buildContent(content, codeNode, graph.getSettings(), nodeModifier);
for (final INaviInstruction instruction : codeNode.getInstructions()) {
final INaviModule module = instruction.getModule();
if ((provider != null) && (provider.getDebugger(module) != null) && graph.getSettings().getDisplaySettings().getShowMemoryAddresses(provider.getDebugger(module))) {
final int line = CCodeNodeHelpers.instructionToLine(codeNode, instruction);
if (line != -1) {
final ZyLineContent lineContent = this.realizer.getNodeContent().getLineContent(line);
// TODO(timkornau) x64
lineContent.setTextColor(0, 8, Color.RED);
}
}
}
// Set highlighting for breakpoints and the instruction pointer.
final INaviInstruction instruction = codeNode.getInstructions().iterator().next();
if (instruction != null) {
final INaviModule module = instruction.getModule();
final IDebugger debugger = provider.getDebugger(module);
if (debugger == null) {
return;
}
final BreakpointManager manager = debugger.getBreakpointManager();
CBreakpointPainter.paintBreakpoints(manager, node, codeNode);
if (debugger.getProcessManager().getActiveThread() != null) {
final RelocatedAddress instructionPointer = debugger.getProcessManager().getActiveThread().getCurrentAddress();
final MemoryModule memoryModule = debugger.getProcessManager().getModule(instructionPointer);
final UnrelocatedAddress unrelocatedIP = new DefaultAddressConverter(memoryModule.getBaseAddress().getAddress(), module.getConfiguration().getFileBase()).memoryToFile(instructionPointer);
CDebuggerPainter.updateSingleNodeDebuggerHighlighting(graph, unrelocatedIP, node);
}
}
}
Aggregations