use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class CStepEndHelper method getEndAddresses.
/**
* Returns the addresses of all final instructions of a graph.
*
* @param graph The graph whose final addresses are returned.
*
* @return The final addresses of the graph.
*/
public static Set<BreakpointAddress> getEndAddresses(final ZyGraph graph) {
final Set<BreakpointAddress> instructions = new HashSet<BreakpointAddress>();
graph.iterate(new INodeCallback<NaviNode>() {
@Override
public IterationMode next(final NaviNode node) {
if ((node.getRawNode() instanceof INaviCodeNode) && node.getChildren().isEmpty()) {
final INaviCodeNode cnode = (INaviCodeNode) node.getRawNode();
final INaviInstruction lastInstruction = Iterables.getLast(cnode.getInstructions());
instructions.add(new BreakpointAddress(lastInstruction.getModule(), new UnrelocatedAddress(lastInstruction.getAddress())));
}
return IterationMode.CONTINUE;
}
});
return instructions;
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress 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.UnrelocatedAddress in project binnavi by google.
the class CRelocationNotifier method collectWronglyPlacedModules.
/**
* Finds wrongly relocated modules by comparing a snapshot of the modules in an address space
* being reported by the debug client with those configured in
* com.google.security.zynamics.binnavi.
*
* @param debugger The active debugger.
* @param viewContainer The view container that is being debugged.
* @param memoryModules The modules whose base addresses are checked.
*
* @return A list of wrongly relocated modules.
*/
private static List<Pair<INaviModule, MemoryModule>> collectWronglyPlacedModules(final IDebugger debugger, final IViewContainer viewContainer, final List<MemoryModule> memoryModules) {
final List<Pair<INaviModule, MemoryModule>> wronglyPlacedModules = new ArrayList<Pair<INaviModule, MemoryModule>>();
final List<INaviModule> modules = viewContainer.getModules();
for (final INaviModule module : modules) {
for (final MemoryModule memoryModule : memoryModules) {
if (module.getConfiguration().getName().equalsIgnoreCase(memoryModule.getName())) {
final RelocatedAddress assumedAddress = debugger.fileToMemory(module, new UnrelocatedAddress(module.getConfiguration().getFileBase()));
final IAddress memoryAddress = memoryModule.getBaseAddress().getAddress();
if (!assumedAddress.getAddress().equals(memoryAddress)) {
wronglyPlacedModules.add(new Pair<INaviModule, MemoryModule>(module, memoryModule));
}
}
}
}
return wronglyPlacedModules;
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class CInstructionGenerator method createExpression.
@Override
public IFilterExpression<CViewWrapper> createExpression(final String text) {
final Pattern pattern = Pattern.compile(RULE_REGEX);
final Matcher matcher = pattern.matcher(text);
matcher.matches();
final String value = matcher.group(2);
try {
final List<INaviView> views = m_container.getViewsWithAddresses(Lists.newArrayList(new UnrelocatedAddress(new CAddress(new BigInteger(value, 16)))), true);
return new CInstructionFilterExpression(views);
} catch (final CouldntLoadDataException e) {
return null;
}
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class CTracesNodeComponent method showRelevantViews.
/**
* Shows the views that belong to a trace in the table in the lower half of the component.
*
* @param trace The trace list.
*
* @throws CouldntLoadDataException
*/
private void showRelevantViews(final TraceList trace) throws CouldntLoadDataException {
final IFilledList<UnrelocatedAddress> addresses = new FilledList<UnrelocatedAddress>();
for (final ITraceEvent traceEvent : trace) {
addresses.add(traceEvent.getOffset().getAddress());
}
final List<INaviView> views = m_container.getViewsWithAddresses(addresses, false);
if (m_container instanceof CProjectContainer) {
for (final INaviModule module : m_container.getModules()) {
if (module.isLoaded()) {
views.addAll(module.getViewsWithAddresses(addresses, false));
}
}
}
m_model.setViews(views);
}
Aggregations