use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testHitBreakpoint_Wellformed.
@Test
public void testHitBreakpoint_Wellformed() throws MessageParserException {
breakpointManager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_456_SET);
breakpointManager.setBreakpointStatus(CommonTestObjects.BP_ADDRESS_456_SET, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_ACTIVE);
mockDebugger.getProcessManager().addThread(new TargetProcessThread(CommonTestObjects.THREAD_ID, ThreadState.SUSPENDED));
debuggerSynchronizer.receivedEvent(DebuggerMessageBuilder.buildRegularBreakpointHit(CommonTestObjects.BP_ADDRESS_456_RELOC));
assertEquals(0, listener.exception);
assertEquals(BreakpointStatus.BREAKPOINT_HIT, breakpointManager.getBreakpointStatus(CommonTestObjects.BP_ADDRESS_456, BreakpointType.REGULAR));
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testModuleLifecycle.
/**
* This test makes sure that the memory module lifecycle (Module Loaded -> Module Unloaded) is
* working and that the process manager of the debugger is updated correctly.
*
* @throws DebugExceptionWrapper
*/
@Test
public void testModuleLifecycle() throws DebugExceptionWrapper {
assertTrue(mockDebugger.getProcessManager().getModules().isEmpty());
mockDebugger.connect();
mockDebugger.getProcessManager().getThreads().clear();
debuggerSynchronizer.receivedEvent(new ThreadCreatedReply(0, 0, 1000, ThreadState.RUNNING));
final MemoryModule module = new MemoryModule("hannes.dll", "C:\\hannes.dll", new RelocatedAddress(new CAddress(0x1000000)), 1000);
debuggerSynchronizer.receivedEvent(new ModuleLoadedReply(0, 0, module, new TargetProcessThread(1000, ThreadState.RUNNING)));
mockDebugger.getProcessManager().setTargetInformation(new TargetInformation(5, Lists.newArrayList(new RegisterDescription("eax", 4, true), new RegisterDescription("ebx", 4, false)), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
assertTrue(mockDebugger.getProcessManager().getModules().size() == 1);
assertTrue(mockDebugger.getProcessManager().getModules().get(0) == module);
debuggerSynchronizer.receivedEvent(new ModuleUnloadedReply(0, 0, module));
assertTrue(mockDebugger.getProcessManager().getModules().isEmpty());
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread 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);
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerFunctions method stepOver.
/**
* Lets the debugger step over the next instruction.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that steps over the next instruction.
* @param graph The graph where the step operation happens.
*/
public static void stepOver(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> relocatedAddresses = CStepOverHelper.getNextInstructions(graph, oldAddress);
if (relocatedAddresses.isEmpty()) {
CMessageBox.showError(parent, "Couldn't step over the current instruction");
return;
} else {
debugger.getProcessManager().setActiveThread(null);
debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedAddresses);
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 = "E00087: " + "Could not send step over command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step over 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);
}
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerFunctions method stepInto.
/**
* Lets the debugger execute a single step.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that executes the single step.
*/
public static void stepInto(final JFrame parent, final IDebugger debugger) {
checkArguments(parent, debugger);
if (!debugger.isConnected()) {
return;
}
final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
try {
debugger.getProcessManager().setActiveThread(null);
debugger.singleStep();
} catch (final DebugExceptionWrapper e) {
CUtilityFunctions.logException(e);
debugger.getProcessManager().setActiveThread(activeThread);
final String innerMessage = "E00192: " + "Could not send single step command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the single step 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