use of com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation in project binnavi by google.
the class CStackViewSynchronizerTest method testSwitchDebugger.
@Test
public void testSwitchDebugger() throws DebugExceptionWrapper {
final MemorySection section1 = new MemorySection(new CAddress(0x100), new CAddress(0x1FF));
final MemorySection section2 = new MemorySection(new CAddress(0x300), new CAddress(0x3FF));
final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
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);
debugger.connect();
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, true, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
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 MemoryMapReply(0, 0, memoryMap));
debugger2.connection.m_synchronizer.receivedEvent(new ProcessStartReply(0, 0, new ProcessStart(thread, module)));
m_model.setActiveDebugger(debugger);
assertTrue(m_stackView.isEnabled());
m_model.setActiveDebugger(debugger2);
assertTrue(m_stackView.isEnabled());
m_synchronizer.dispose();
debugger.close();
debugger2.close();
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation in project binnavi by google.
the class CStackViewSynchronizerTest method testDetach.
@Test
public void testDetach() throws DebugExceptionWrapper {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.SUSPENDED);
debugger.getProcessManager().addThread(thread);
debugger.getProcessManager().setActiveThread(thread);
debugger.connect();
m_model.setActiveDebugger(debugger);
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, true, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
final MemorySection section1 = new MemorySection(new CAddress(0x100), new CAddress(0x1FF));
final MemorySection section2 = new MemorySection(new CAddress(0x300), new CAddress(0x3FF));
final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
assertTrue(m_stackView.isEnabled());
debugger.connection.m_synchronizer.receivedEvent(new DetachReply(0, 0));
assertFalse(m_stackView.isEnabled());
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation in project binnavi by google.
the class CMemoryViewerSynchronizerTest method testActiveDebugger.
@Test
public void testActiveDebugger() {
final IGraphModel graphModel = new MockGraphModel();
final CDebugPerspectiveModel model = new CDebugPerspectiveModel(graphModel);
final JHexView hexView = new JHexView();
final CMemoryProvider provider = new CMemoryProvider();
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
model.setActiveDebugger(debugger);
final CMemoryViewerSynchronizer synchronizer = new CMemoryViewerSynchronizer(hexView, provider, model);
debugger.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))));
assertEquals(AddressMode.BIT32, hexView.getAddressMode());
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(64, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
assertEquals(AddressMode.BIT64, hexView.getAddressMode());
synchronizer.dispose();
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation 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.targetinformation.TargetInformation in project binnavi by google.
the class CDebuggerFunctions method showDebuggerOptionsDialogAlways.
/**
* Shows the debugger options dialog.
*
* @param parent Parent window of the dialog.
* @param target Provides the debugger target.
* @param debugger The debugger whose options are shown in the dialog.
*/
public static void showDebuggerOptionsDialogAlways(final JFrame parent, final DebugTargetSettings target, final IDebugger debugger) {
Preconditions.checkNotNull(parent, "IE01559: Parent argument can not be null");
Preconditions.checkNotNull(target, "IE01560: Target argument can not be null");
Preconditions.checkNotNull(debugger, "IE01561: Debugger argument can not be null");
final TargetInformation targetInformation = debugger.getProcessManager().getTargetInformation();
if (targetInformation == null) {
CMessageBox.showInformation(parent, "Debugger information can not be shown before the debugger is active.");
return;
}
DebuggerOptions options = targetInformation.getDebuggerOptions();
if (options == null) {
CMessageBox.showInformation(parent, "Debugger information can not be shown before the debugger is active.");
return;
}
if (!debugger.isConnected()) {
CMessageBox.showInformation(parent, "Debugger information can not be shown since the debugger is not currently connected.");
return;
}
try {
options.setExceptions(new ArrayList<DebuggerException>(mergeExceptionsSettings(target, options.getExceptions(), debugger.getId())));
} catch (final CouldntLoadDataException exception) {
CUtilityFunctions.logException(exception);
final String message = "Exception settings could not be loaded.";
final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not load the exception settings from the database."), new String[] { "Communication error while contacting the database" }, new String[] { "BinNavi is unable to show the debugger options dialog until the problem is resolved." + " The default debugger options will be used during this session." });
NaviErrorDialog.show(parent, message, description, exception);
}
final DebuggerEventSettings eventSettings = readDebuggerEventSettings(parent, debugger, target);
final COptionsDialog dlg = new COptionsDialog(parent, options, eventSettings);
dlg.setVisible(true);
options = dlg.getDebuggerOptions();
try {
writeDebuggerExceptionSettings(options, target, debugger.getId());
writeDebuggerEventSettings(debugger, target, dlg.getDebuggerEventSettings());
} catch (final CouldntSaveDataException exception) {
CUtilityFunctions.logException(exception);
CUtilityFunctions.logException(exception);
final String message = "Exception settings could not be written.";
final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not write the debugger options to the database."), new String[] { "Communication error while contacting the database" }, new String[] { "BinNavi is unable to store the debugger options in the database.", "Nevertheless, the debugger options will be sent to the debugger." });
NaviErrorDialog.show(parent, message, description, exception);
}
sendExceptionSettings(parent, debugger, options.getExceptions());
sendDebuggerEventSettings(parent, debugger, target);
}
Aggregations