use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.
the class CBreakpointModuleSynchronizer method processModuleBreakpoints.
private static void processModuleBreakpoints(final IDebugger debugger, final MemoryModule module, final BreakpointType breakPointType, final IModuleBreakpointEnumerator callback) {
final BreakpointManager manager = debugger.getBreakpointManager();
final Set<BreakpointAddress> breakpointAddresses = new HashSet<BreakpointAddress>();
for (final Breakpoint breakpoint : manager.getBreakpointsByModule(breakPointType, module)) {
if ((manager.getBreakpointStatus(breakpoint.getAddress(), breakpoint.getType()) != BreakpointStatus.BREAKPOINT_ENABLED) && (manager.getBreakpointStatus(breakpoint.getAddress(), breakpoint.getType()) != BreakpointStatus.BREAKPOINT_DISABLED) && isWithinModule(debugger, module, breakpoint)) {
breakpointAddresses.add(breakpoint.getAddress());
}
}
callback.handleAddress(manager, breakpointAddresses);
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.
the class CBreakpointFunctionsTest method test6removeFunctions.
@Test
public void test6removeFunctions() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final MockFunction mockFunction = new MockFunction();
final INaviModule mockModule = mockFunction.getModule();
CFunctionContainerHelper.addFunction(mockModule.getContent().getFunctionContainer(), mockFunction);
final DebugTargetSettings target = new ModuleTargetSettings(mockModule);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(mockModule));
debugger.getBreakpointManager().addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234)))));
@SuppressWarnings("unused") final Breakpoint breakPoint = debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, new BreakpointAddress(mockModule, new UnrelocatedAddress(new CAddress(0x1234))));
debuggerProvider.addDebugger(debugger);
final CBreakpointTableModel tableModel = new CBreakpointTableModel(debuggerProvider);
assertEquals(1, tableModel.getRowCount());
final IFilledList<Pair<IDebugger, INaviFunction>> targets = new FilledList<Pair<IDebugger, INaviFunction>>();
final Pair<IDebugger, INaviFunction> targetPair = new Pair<IDebugger, INaviFunction>(debugger, mockFunction);
targets.add(targetPair);
assertEquals(1, targets.size());
CBreakpointRemoveFunctions.removeBreakpoints(targets);
@SuppressWarnings("unused") final BreakpointManager manager = debugger.getBreakpointManager();
assertEquals(0, tableModel.getRowCount());
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.
the class ReplySynchronizer method resetTargetProcess.
/**
* Resets information about the target process.
*/
protected void resetTargetProcess() {
final BreakpointManager manager = debugger.getBreakpointManager();
final ProcessManager processManager = debugger.getProcessManager();
debugger.setTerminated();
manager.clearBreakpointsPassive(BreakpointType.ECHO);
manager.clearBreakpointsPassive(BreakpointType.STEP);
deactivateBreakpoints();
processManager.getMemory().clear();
processManager.setMemoryMap(new MemoryMap(new ArrayList<MemorySection>()));
final Collection<TargetProcessThread> threads = processManager.getThreads();
for (final TargetProcessThread thread : threads) {
processManager.removeThread(thread);
}
for (final MemoryModule module : processManager.getModules()) {
processManager.removeModule(module);
}
processManager.setAttached(false);
processManager.setActiveThread(null);
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.
the class ReplySynchronizer method deactivateBreakpoints.
/**
* Deactivates all regular breakpoints which are not disabled.
*/
private void deactivateBreakpoints() {
final BreakpointManager manager = debugger.getBreakpointManager();
final Set<BreakpointAddress> addressesToRemove = new HashSet<>();
final Set<BreakpointAddress> addressesToDisable = new HashSet<>();
for (final Breakpoint breakpoint : manager.getBreakpoints(BreakpointType.REGULAR)) {
final BreakpointAddress address = breakpoint.getAddress();
if (manager.getBreakpointStatus(address, BreakpointType.REGULAR) == BreakpointStatus.BREAKPOINT_DELETING) {
// When the target process is reset, the BreakpointDeleted message will never arrive.
// It is therefore necessary to delete the DELETING breakpoints manually.
// See Case 2109 for an example of what can happen.
addressesToRemove.add(address);
} else if (manager.getBreakpointStatus(address, BreakpointType.REGULAR) != BreakpointStatus.BREAKPOINT_DISABLED) {
addressesToDisable.add(address);
}
}
manager.removeBreakpoints(BreakpointType.REGULAR, addressesToRemove);
manager.setBreakpointStatus(addressesToDisable, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_INACTIVE);
}
use of com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager in project binnavi by google.
the class ResumeSynchronizer method handleSuccess.
@Override
protected void handleSuccess(final ResumeReply reply) {
final BreakpointManager manager = getDebugger().getBreakpointManager();
final ProcessManager processManager = getDebugger().getProcessManager();
for (final Breakpoint breakpoint : manager.getBreakpoints(BreakpointType.REGULAR)) {
if (manager.getBreakpointStatus(breakpoint.getAddress(), breakpoint.getType()) == BreakpointStatus.BREAKPOINT_HIT) {
manager.setBreakpointStatus(Sets.newHashSet(breakpoint.getAddress()), breakpoint.getType(), BreakpointStatus.BREAKPOINT_ACTIVE);
}
}
processManager.setActiveThread(null);
}
Aggregations