use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerFunctions method stepEnd.
/**
* Lets the debugger step to the end of the function.
*
* @param parent Parent window used for dialogs.
* @param debugger The debugger that steps to the end of the function.
* @param graph The graph where the step operation happens.
*/
public static void stepEnd(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 Set<BreakpointAddress> relocatedBlockAddresses = CStepEndHelper.getEndAddresses(graph);
if (relocatedBlockAddresses.isEmpty()) {
CMessageBox.showError(parent, "Couldn't step to the end of the function");
return;
} else {
debugger.getProcessManager().setActiveThread(null);
debugger.getBreakpointManager().addBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
try {
debugger.resume();
} catch (final DebugExceptionWrapper e) {
debugger.getBreakpointManager().removeBreakpoints(BreakpointType.STEP, relocatedBlockAddresses);
debugger.getProcessManager().setActiveThread(activeThread);
CUtilityFunctions.logException(e);
final String innerMessage = "E00086: " + "Could not send step end command to the debug client";
final String innerDescription = CUtilityFunctions.createDescription("BinNavi could not send the step end 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 CStepIntoHotkeyAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent event) {
final IDebugger debugger = m_debugPerspectiveModel.getCurrentSelectedDebugger();
final TargetProcessThread currentThread = debugger == null ? null : debugger.getProcessManager().getActiveThread();
if (currentThread != null && debugger != null) {
CDebuggerFunctions.stepInto(m_parent, debugger);
}
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CMemoryRefreshButtonSynchronizerTest method testSwitchDebugger.
@Test
public void testSwitchDebugger() throws DebugExceptionWrapper {
final TargetProcessThread thread = new TargetProcessThread(0x666, ThreadState.RUNNING);
final MemoryModule module = new MemoryModule("narf.exe", "C:\\zort\\narf.exe", new RelocatedAddress(new CAddress(0x1000)), 123345);
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, true, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
debugger.connection.m_synchronizer.receivedEvent(new ProcessStartReply(0, 0, new ProcessStart(thread, module)));
final MockDebugger debugger2 = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger2.connect();
debugger2.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
debugger2.connection.m_synchronizer.receivedEvent(new ProcessStartReply(0, 0, new ProcessStart(thread, module)));
m_model.setActiveDebugger(debugger);
debugger.getProcessManager().setActiveThread(thread);
assertTrue(m_refreshButton.isEnabled());
assertEquals(m_defaultAction, m_refreshButton.getAction());
m_model.setActiveDebugger(debugger2);
debugger2.getProcessManager().setActiveThread(thread);
assertTrue(m_refreshButton.isEnabled());
assertEquals(m_askAction, m_refreshButton.getAction());
m_synchronizer.dispose();
debugger.close();
debugger2.close();
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testRegisterValues_UnknownTID.
@Test
public void testRegisterValues_UnknownTID() throws MessageParserException {
mockDebugger.getProcessManager().addThread(new TargetProcessThread(123, ThreadState.SUSPENDED));
debuggerSynchronizer.receivedEvent(new RegistersReply(0, 0, RegisterValuesParser.parse(("<Registers><Thread id=\"123\"><Register name=\"EAX\" " + "value=\"123\" memory=\"\" /><Register name=\"EBX\" value=\"456\" memory=\"\" " + "/><Register name=\"EIP\" value=\"999\" memory=\"\" pc=\"true\" /></Thread>" + "</Registers>").getBytes())));
assertEquals(0, listener.exception);
}
use of com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread in project binnavi by google.
the class CDebuggerSynchronizerTest method testSingleStep_Valid.
@Test
public void testSingleStep_Valid() throws MessageParserException, MaybeNullException {
breakpointManager.addBreakpoints(BreakpointType.REGULAR, CommonTestObjects.BP_ADDRESS_333_SET);
breakpointManager.setBreakpointStatus(CommonTestObjects.BP_ADDRESS_333_SET, BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_HIT);
mockDebugger.getProcessManager().addThread(new TargetProcessThread(123, ThreadState.SUSPENDED));
debuggerSynchronizer.receivedEvent(new SingleStepReply(0, 0, 123, new RelocatedAddress(new CAddress(0x999)), RegisterValuesParser.parse(("<Registers><Thread id=\"123\">" + "<Register name=\"EAX\" value=\"123\" memory=\"\" />" + "<Register name=\"EBX\" value=\"456\" memory=\"\" />" + "<Register name=\"EIP\" value=\"999\" memory=\"\" pc=\"true\" />" + "</Thread></Registers>").getBytes())));
assertEquals(ThreadState.SUSPENDED, mockDebugger.getProcessManager().getThread(123).getState());
assertEquals(0x999, mockDebugger.getProcessManager().getThread(123).getCurrentAddress().getAddress().toLong());
assertEquals(0x456, mockDebugger.getProcessManager().getThread(123).getRegisterValues().get(1).getValue().longValue());
assertEquals(BreakpointStatus.BREAKPOINT_ACTIVE, breakpointManager.getBreakpointStatus(CommonTestObjects.BP_ADDRESS_333, BreakpointType.REGULAR));
}
Aggregations