Search in sources :

Example 11 with ProcessManager

use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager in project binnavi by google.

the class CDebugEventNotifier method stop.

/**
   * Stops the event notifier.
   */
public void stop() {
    m_debugger.removeListener(m_debuglistener);
    final ProcessManager processManager = m_debugger.getProcessManager();
    processManager.removeListener(m_processListener);
    for (final TargetProcessThread thread : processManager.getThreads()) {
        thread.removeListener(m_threadEventListener);
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)

Example 12 with ProcessManager

use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager in project binnavi by google.

the class CDebugEventNotifier method start.

/**
   * Starts the event notifier.
   */
public void start() {
    m_debugger.addListener(m_debuglistener);
    final ProcessManager processManager = m_debugger.getProcessManager();
    processManager.addListener(m_processListener);
    for (final TargetProcessThread thread : processManager.getThreads()) {
        thread.addListener(m_threadEventListener);
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)

Example 13 with ProcessManager

use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager in project binnavi by google.

the class ThreadCreatedSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final ThreadCreatedReply reply) {
    final ProcessManager processManager = getDebugger().getProcessManager();
    final TargetProcessThread thread = new TargetProcessThread(reply.getThreadId(), reply.getThreadState());
    processManager.addThread(thread);
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)

Example 14 with ProcessManager

use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager in project binnavi by google.

the class BreakpointHitSynchronizer method handleSuccess.

/**
   * Handles incoming Breakpoint Hit replies.
   *
   * @param reply The incoming Breakpoint Hit reply to handle.
   */
@Override
protected void handleSuccess(final BreakpointHitReply reply) {
    final ProcessManager processManager = getDebugger().getProcessManager();
    // When the debug client notifies BinNavi that a
    // breakpoint was hit, it is necessary to mark the
    // breakpoint as hit.
    // TODO: Check for success
    RelocatedAddress eventAddress = null;
    final RegisterValues registerValues = reply.getRegisterValues();
    final long tid = reply.getThreadId();
    for (final ThreadRegisters threadRegisters : registerValues) {
        if (tid == threadRegisters.getTid()) {
            for (final RegisterValue registerValue : threadRegisters) {
                if (registerValue.isPc()) {
                    eventAddress = new RelocatedAddress(new CAddress(registerValue.getValue()));
                }
            }
        }
    }
    if (eventAddress != null) {
        updateHitBreakpoints(DebuggerHelpers.getBreakpointAddress(getDebugger(), eventAddress));
    } else {
        throw new IllegalStateException("IE00173: register reply did not include program counter");
    }
    try {
        final TargetProcessThread thread = processManager.getThread(reply.getThreadId());
        // Update the thread with the new register values.
        for (final ThreadRegisters threadRegisters : registerValues) {
            if (tid == threadRegisters.getTid()) {
                thread.setRegisterValues(threadRegisters.getRegisters());
                break;
            }
        }
        processManager.setActiveThread(thread);
        thread.setCurrentAddress(eventAddress);
    } catch (final MaybeNullException exception) {
        NaviLogger.info("Error: there is no thread with the specified thread id %d Exception: %s", reply.getThreadId(), exception);
    }
}
Also used : RegisterValue(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 15 with ProcessManager

use of com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager in project binnavi by google.

the class ExceptionOccurredSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final ExceptionOccurredReply reply) {
    final ProcessManager processManager = getDebugger().getProcessManager();
    try {
        final TargetProcessThread thread = processManager.getThread(reply.getThreadId());
        processManager.setActiveThread(thread);
        thread.setCurrentAddress(reply.getAddress());
        processManager.addExceptionEvent(new DebuggerException(reply.getExceptionName(), reply.getExceptionCode(), DebuggerExceptionHandlingAction.Continue));
        refreshRegisters();
    } catch (final MaybeNullException exception) {
        NaviLogger.severe("Exception occured in unknown thread %d", reply.getThreadId());
    }
}
Also used : TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MaybeNullException(com.google.security.zynamics.binnavi.Exceptions.MaybeNullException) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)

Aggregations

ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)21 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)12 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)7 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)6 Test (org.junit.Test)6 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)5 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)4 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)3 DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)3 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)3 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)3 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)3 DebugExceptionWrapper (com.google.security.zynamics.binnavi.debug.debugger.DebugExceptionWrapper)2 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)2 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)2 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)2 RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)2 ArrayList (java.util.ArrayList)2 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)1 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)1