use of com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper in project binnavi by google.
the class Debugger method writeMemory.
// ! Writes target process memory.
/**
* Writes to the memory of the target process.
*
* @param address Start address of the memory write operation.
* @param data Data to be written to the target memory.
*
* @throws DebugException Thrown if the message could not be sent to the debug client.
*/
public void writeMemory(final Address address, final byte[] data) throws DebugException {
Preconditions.checkNotNull(address, "Error: Address argument can not be null");
Preconditions.checkNotNull(data, "Error: Data argument can not be null");
try {
m_debugger.writeMemory(new CAddress(address.toLong()), data);
} catch (final DebugExceptionWrapper e) {
throw new DebugException(e);
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper in project binnavi by google.
the class ModuleLoadedSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final ModuleLoadedReply reply) {
getDebugger().getProcessManager().addModule(reply.getModule());
CRelocationNotifier.relocateModule(getDebugger(), reply.getModule());
CBreakpointModuleSynchronizer.enableRegularBreakpoints(getDebugger(), reply.getModule());
CBreakpointModuleSynchronizer.enableEchoBreakpoints(getDebugger(), reply.getModule());
final TargetInformation targetInformation = getDebugger().getProcessManager().getTargetInformation();
if ((targetInformation != null) && targetInformation.getDebuggerOptions().canBreakOnModuleLoad()) {
if (needsResume()) {
try {
getDebugger().resume();
} catch (final DebugExceptionWrapper e) {
NaviLogger.severe("Error: Could not resume debugger. Exception: %s", e);
}
} else {
refreshRegisters();
setActiveThreadById(getDebugger().getProcessManager(), reply.getThread().getThreadId());
}
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper in project binnavi by google.
the class CMemoryProvider method setData.
@Override
public void setData(final long offset, final byte[] data) {
if (m_debugger != null) {
try {
m_debugger.writeMemory(new CAddress(offset), data);
m_debugger.getProcessManager().getMemory().store(offset, data);
} catch (final DebugExceptionWrapper exception) {
CUtilityFunctions.logException(exception);
}
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper in project binnavi by google.
the class CRemoteFileBrowserLoader method showRemoteBrowser.
/**
* Shows the remote browsing dialog.
*/
private void showRemoteBrowser() {
final CRemoteSelectionDialog dlg = CRemoteSelectionDialog.show(m_parent, m_debugger, m_fileSystem, m_processList);
final File selectedFile = dlg.getSelectedFile();
final ProcessDescription selectedProcess = dlg.getSelectedProcess();
if (selectedFile != null) {
try {
m_debugger.selectFile(selectedFile.getAbsolutePath());
m_selectedTarget = true;
} catch (final DebugExceptionWrapper e) {
CUtilityFunctions.logException(m_loaderThread.getException());
final String message = "E00039: " + "Could not send target file request";
final String description = CUtilityFunctions.createDescription("BinNavi could not send the target file request to the debug client.", new String[] { "The connection to the debug client was closed before" + " the request could be sent." }, new String[] { "There is still no debug target selected." });
NaviErrorDialog.show(m_parent, message, description, m_loaderThread.getException());
}
} else if (selectedProcess != null) {
try {
m_debugger.selectProcess(selectedProcess.getPID());
m_selectedTarget = true;
} catch (final DebugExceptionWrapper e) {
CUtilityFunctions.logException(m_loaderThread.getException());
final String message = "E00040: " + "Could not send target process request";
final String description = CUtilityFunctions.createDescription("BinNavi could not send the target process request to the debug client.", new String[] { "The connection to the debug client was closed before the" + "request could be sent." }, new String[] { "There is still not debug target selected." });
NaviErrorDialog.show(m_parent, message, description, m_loaderThread.getException());
}
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper in project binnavi by google.
the class CDebuggerFunctions method stepBlock.
/**
* Lets the debugger step to the next block.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that steps to the next block.
* @param graph The graph where the step operation happens.
*/
public static void stepBlock(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> relocatedBlockAddresses = CStepBlockHelper.getNextBlocks(graph, oldAddress);
if (relocatedBlockAddresses.isEmpty()) {
CMessageBox.showError(parent, "Couldn't step to the next block");
return;
} else {
debugger.getProcessManager().setActiveThread(null);
final Set<BreakpointAddress> setBreakpoints = new HashSet<BreakpointAddress>();
debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
setBreakpoints.addAll(relocatedBlockAddresses);
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 = "E00045: " + "Could not send step block command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step block 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);
}
}
}
Aggregations