Search in sources :

Example 51 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class CGraphDebugger method toggleBreakpointStatus.

/**
   * Disables or enables a breakpoint at a given address.
   *
   * @param manager The breakpoint manager that is used to toggle the breakpoint status.
   * @param module The module where the breakpoint is set.
   * @param unrelocatedAddress The unrelocated address where the breakpoint is set.
   */
public static void toggleBreakpointStatus(final BreakpointManager manager, final INaviModule module, final UnrelocatedAddress unrelocatedAddress) {
    Preconditions.checkNotNull(manager, "IE01723: Manager argument can not be null");
    Preconditions.checkNotNull(module, "IE01724: Module argument can not be null");
    Preconditions.checkNotNull(unrelocatedAddress, "IE01725: Address argument can not be null");
    final BreakpointAddress address = new BreakpointAddress(module, unrelocatedAddress);
    toggleBreakpoint(manager, address);
}
Also used : BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)

Example 52 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class BreakpointRemovedSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final BreakpointsRemovedReply reply) {
    // If a breakpoint was removed from the target process, it can be removed
    // from the breakpoint manager too unless the breakpoint is set to disabled
    // there.
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final Set<BreakpointAddress> addressesToRemove = new HashSet<>();
    final Set<BreakpointAddress> addressesToInvalidate = new HashSet<>();
    for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
        if (resultPair.second() == 0) {
            final BreakpointAddress address = DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first());
            if (manager.getBreakpointStatus(address, BreakpointType.REGULAR) == BreakpointStatus.BREAKPOINT_DELETING) {
                addressesToRemove.add(address);
            }
        } else {
            addressesToInvalidate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first()));
        }
    }
    manager.removeBreakpointsPassive(BreakpointType.REGULAR, addressesToRemove);
    manager.setBreakpointStatus(addressesToInvalidate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_INVALID);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) HashSet(java.util.HashSet)

Example 53 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class BreakpointSetSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final BreakpointSetReply reply) {
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final Set<BreakpointAddress> addressesToActivate = new HashSet<>();
    final Set<BreakpointAddress> addressesToInvalidate = new HashSet<>();
    for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
        if (resultPair.second() == 0) {
            // If a breakpoint was successfully set in the target process, its status is
            // set to ACTIVE in the breakpoint manager.
            final BreakpointAddress breakpointAddress = DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first());
            if (manager.getBreakpointStatus(breakpointAddress, BreakpointType.REGULAR) != BreakpointStatus.BREAKPOINT_DISABLED) {
                addressesToActivate.add(breakpointAddress);
            }
        } else {
            // If a breakpoint could not be set in the target process, its status in the
            // breakpoint manager is set to INVALID. The real status of the breakpoint
            // is unknown though.
            addressesToInvalidate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), resultPair.first()));
        }
    }
    manager.setBreakpointStatus(addressesToInvalidate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_INVALID);
    manager.setBreakpointStatus(addressesToActivate, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) HashSet(java.util.HashSet)

Example 54 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class DebuggerHelpers method getBreakpointAddress.

/**
   * Converts a memory address into a breakpoint address.
   *
   * @param debugger The debugger which handles the breakpoint.
   * @param memoryAddress The memory address to convert.
   *
   * @return The breakpoint address.
   */
public static BreakpointAddress getBreakpointAddress(final IDebugger debugger, final RelocatedAddress memoryAddress) {
    Preconditions.checkNotNull(debugger, "IE00161: Debugger argument can not be null");
    Preconditions.checkNotNull(memoryAddress, "IE00163: Memory address argument can not be null");
    final INaviModule module = debugger.getModule(memoryAddress);
    return new BreakpointAddress(module, module == null ? new UnrelocatedAddress(memoryAddress.getAddress()) : debugger.memoryToFile(module, memoryAddress));
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)

Example 55 with BreakpointAddress

use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress in project binnavi by google.

the class EchoBreakpointSetSynchronizer method handleSuccess.

@Override
protected void handleSuccess(final EchoBreakpointSetReply reply) {
    final BreakpointManager manager = getDebugger().getBreakpointManager();
    final Set<BreakpointAddress> addressesToActivate = new HashSet<>();
    final Set<BreakpointAddress> addressesToRemove = new HashSet<>();
    for (final Pair<RelocatedAddress, Integer> resultPair : reply.getAddresses()) {
        final RelocatedAddress address = resultPair.first();
        if (resultPair.second() == 0) {
            addressesToActivate.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
        } else {
            addressesToRemove.add(DebuggerHelpers.getBreakpointAddress(getDebugger(), address));
        }
    }
    manager.setBreakpointStatus(addressesToActivate, BreakpointType.ECHO, BreakpointStatus.BREAKPOINT_ACTIVE);
    manager.removeBreakpointsPassive(BreakpointType.ECHO, addressesToRemove);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) HashSet(java.util.HashSet)

Aggregations

BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)87 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)60 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)49 Test (org.junit.Test)39 HashSet (java.util.HashSet)24 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)22 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)15 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)15 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)13 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)11 BreakpointManager (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager)11 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)11 ArrayList (java.util.ArrayList)9 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)8 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)8 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)8 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)7 TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)7 ITraceEvent (com.google.security.zynamics.binnavi.debug.models.trace.interfaces.ITraceEvent)7