Search in sources :

Example 6 with DebugExceptionWrapper

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);
    }
}
Also used : DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 7 with DebugExceptionWrapper

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());
        }
    }
}
Also used : DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)

Example 8 with DebugExceptionWrapper

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);
        }
    }
}
Also used : DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 9 with DebugExceptionWrapper

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());
        }
    }
}
Also used : ProcessDescription(com.google.security.zynamics.binnavi.debug.models.processlist.ProcessDescription) DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) CRemoteSelectionDialog(com.google.security.zynamics.binnavi.Gui.Debug.RemoteBrowser.CRemoteSelectionDialog) File(java.io.File)

Example 10 with DebugExceptionWrapper

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);
        }
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) DebugExceptionWrapper(com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) HashSet(java.util.HashSet)

Aggregations

DebugExceptionWrapper (com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper)13 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)5 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)3 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)3 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)2 ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)2 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)2 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)2 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)2 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)1 CRemoteSelectionDialog (com.google.security.zynamics.binnavi.Gui.Debug.RemoteBrowser.CRemoteSelectionDialog)1 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)1 ProcessDescription (com.google.security.zynamics.binnavi.debug.models.processlist.ProcessDescription)1 DebuggerEventSettingsStorage (com.google.security.zynamics.binnavi.debug.models.storage.DebuggerEventSettingsStorage)1 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)1 File (java.io.File)1 HashSet (java.util.HashSet)1