use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CDebuggerSynchronizerTest method testEchoBreakpointSetErr.
@SuppressWarnings("unchecked")
@Test
public void testEchoBreakpointSetErr() throws DebugExceptionWrapper {
mockDebugger.connect();
breakpointManager.addBreakpoints(BreakpointType.ECHO, CommonTestObjects.BP_ADDRESS_123_SET);
debuggerSynchronizer.receivedEvent(new EchoBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 5))));
assertEquals(0, breakpointManager.getNumberOfBreakpoints(BreakpointType.ECHO));
assertEquals("ERROR_SET_ECHO_BREAKPOINT/00001123/5;", listener.events);
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress in project binnavi by google.
the class CDebuggerSynchronizerTest method testStepBreakpointLifecycle.
/**
* This test is used to determine whether the step breakpoint lifecycle (Set Step BP -> Hit Step
* BP -> Remove Step BP) works correctly.
*
* @throws DebugExceptionWrapper Thrown if something goes wrong.
*/
@SuppressWarnings("unchecked")
@Test
public void testStepBreakpointLifecycle() throws DebugExceptionWrapper {
mockDebugger.connect();
final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
mockDebugger.getProcessManager().addThread(thread);
mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_123_SET);
mockDebugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, CommonTestObjects.BP_ADDRESS_456_SET);
debuggerSynchronizer.receivedEvent(new StepBreakpointSetReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0), new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_456_RELOC, 0))));
assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, mockDebugger.getBreakpointManager().getBreakpointStatus(CommonTestObjects.BP_ADDRESS_123, BreakpointType.STEP));
assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, mockDebugger.getBreakpointManager().getBreakpointStatus(CommonTestObjects.BP_ADDRESS_456, BreakpointType.STEP));
final RegisterValues registerValues = new RegisterValues(Lists.<ThreadRegisters>newArrayList(new ThreadRegisters(0, Lists.newArrayList(new RegisterValue("esp", BigInteger.valueOf(0x123), new byte[0], true, false)))));
debuggerSynchronizer.receivedEvent(new StepBreakpointHitReply(0, 0, 0, registerValues));
listener.toString();
assertTrue(Iterables.isEmpty(mockDebugger.getBreakpointManager().getBreakpoints(BreakpointType.STEP)));
assertEquals(thread, mockDebugger.getProcessManager().getActiveThread());
assertEquals(0x123, thread.getCurrentAddress().getAddress().toLong());
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress 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.disassembly.RelocatedAddress in project binnavi by google.
the class CDebuggerSynchronizerTest method testEchoBreakpointRemoveSucc.
@SuppressWarnings("unchecked")
@Test
public void testEchoBreakpointRemoveSucc() throws DebugExceptionWrapper {
mockDebugger.connect();
breakpointManager.addBreakpoints(BreakpointType.ECHO, CommonTestObjects.BP_ADDRESS_123_SET);
debuggerSynchronizer.receivedEvent(new EchoBreakpointsRemovedReply(0, 0, Lists.newArrayList(new Pair<RelocatedAddress, Integer>(CommonTestObjects.BP_ADDRESS_123_RELOC, 0))));
assertEquals(0, breakpointManager.getNumberOfBreakpoints(BreakpointType.ECHO));
}
use of com.google.security.zynamics.binnavi.disassembly.RelocatedAddress 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);
}
}
}
Aggregations