use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CDebuggerFunctions method stepOver.
/**
* Lets the debugger step over the next instruction.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that steps over the next instruction.
* @param graph The graph where the step operation happens.
*/
public static void stepOver(final JFrame parent, final IDebugger debugger, final ZyGraph graph) {
checkArguments(parent, debugger, graph);
if (!debugger.isConnected()) {
return;
}
final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
if (activeThread == null) {
return;
}
final RelocatedAddress currentAddress = activeThread.getCurrentAddress();
if (currentAddress == null) {
CMessageBox.showError(parent, "Could not step because the selected thread is not suspended");
return;
}
final UnrelocatedAddress oldAddress = debugger.memoryToFile(currentAddress);
final Set<BreakpointAddress> relocatedAddresses = CStepOverHelper.getNextInstructions(graph, oldAddress);
if (relocatedAddresses.isEmpty()) {
CMessageBox.showError(parent, "Couldn't step over the current instruction");
return;
} else {
debugger.getProcessManager().setActiveThread(null);
debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedAddresses);
try {
debugger.resume();
} catch (final DebugExceptionWrapper e) {
// TODO: Step breakpoints should be removed at this point
debugger.getProcessManager().setActiveThread(activeThread);
CUtilityFunctions.logException(e);
final String innerMessage = "E00087: " + "Could not send step over command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step over command to the debug client.", new String[] { "There was a problem with the connection to the debug client." }, new String[] { "The state of the debugged process remains unchanged." });
NaviErrorDialog.show(parent, innerMessage, innerDescription, e);
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress 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.RelocatedAddress in project binnavi by google.
the class CRegisterMenuProvider method getRegisterMenu.
@Override
public JPopupMenu getRegisterMenu(final int registerNumber) {
final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
if (debugger == null) {
return null;
}
final JPopupMenu menu = new JPopupMenu();
final BigInteger value = m_dataProvider.getRegisterInformation(registerNumber).getValue();
menu.add(CActionProxy.proxy(new CCopyRegisterValueAction(value.toString(16).toUpperCase())));
final MemorySection section = ProcessHelpers.getSectionWith(debugger.getProcessManager().getMemoryMap(), new CAddress(value));
final JMenuItem gotoAddress = menu.add(CActionProxy.proxy(new CGotoOffsetAction(m_debugPerspectiveModel, new CAddress(value))));
gotoAddress.setEnabled(section != null);
if (containsAddress(m_debugPerspectiveModel.getGraphModel().getGraph().getRawView(), value.longValue())) {
menu.add(CActionProxy.proxy(new CZoomToAddressAction(m_debugPerspectiveModel.getGraphModel().getGraph(), new CAddress(value), debugger.getModule(new RelocatedAddress(new CAddress(value))))));
} else {
final IViewContainer container = m_debugPerspectiveModel.getGraphModel().getViewContainer();
menu.add(CActionProxy.proxy(new CSearchAction(m_debugPerspectiveModel.getGraphModel().getParent(), container, new CAddress(value))));
}
return menu;
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CThreadEventSynchronizer method paintProgramCounter.
/**
* Paints the program counter of a given thread into the graph.
*
* @param thread The graph whose PC is painted into the graph.
*/
private void paintProgramCounter(final TargetProcessThread thread) {
if (thread == null) {
CDebuggerPainter.clearDebuggerHighlighting(m_graph);
} else {
final RelocatedAddress address = thread.getCurrentAddress();
if (address == null) {
return;
}
CDebuggerPainter.updateDebuggerHighlighting(m_graph, m_debugger.memoryToFile(address), m_debugger.getModule(address));
}
}
Aggregations