use of com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions in project binnavi by google.
the class ProcessTest method testGetTargetInformation.
@Test
public void testGetTargetInformation() {
final MockProcessListener listener = new MockProcessListener();
final ProcessManager manager = new ProcessManager();
final Process process = new Process(manager);
process.addListener(listener);
assertNull(process.getTargetInformation());
manager.setTargetInformation(new com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation(5, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
final TargetInformation t1 = process.getTargetInformation();
final TargetInformation t2 = process.getTargetInformation();
assertNotNull(t1);
assertEquals(t1, t2);
assertEquals("changedTargetInformation;", listener.events);
assertEquals(5, process.getTargetInformation().getAddressSize());
assertEquals(false, process.getTargetInformation().canTerminate());
process.removeListener(listener);
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions 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.DebuggerOptions 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.DebuggerOptions in project binnavi by google.
the class TargetInformationParser method parse.
/**
* Parses a target information message and creates Java objects from the information found in the
* message.
*
* @param data The byte array that contains the target information.
* @return The usable object that contains the target information.
* @throws IllegalArgumentException If the data argument is null.
* @throws MessageParserException If parsing goes wrong.
*/
public static TargetInformation parse(final byte[] data) throws MessageParserException {
Preconditions.checkNotNull(data, "IE01300: Data argument can not be null");
final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
int addressSize = -1;
List<RegisterDescription> registers = null;
DebuggerOptions options = null;
try {
final DocumentBuilder builder = factory.newDocumentBuilder();
final Document document = builder.parse(new ByteArrayInputStream(data, 0, data.length));
final NodeList nodes = document.getFirstChild().getChildNodes();
for (int i = 0; i < nodes.getLength(); ++i) {
final Node node = nodes.item(i);
final String nodeName = node.getNodeName();
if ("registers".equals(nodeName)) {
registers = parseRegisterInformation(node);
} else if ("size".equals(nodeName)) {
addressSize = Integer.valueOf(node.getTextContent());
} else if ("options".equals(nodeName)) {
options = parseOptionsInformation(node);
} else {
throw new MessageParserException(String.format("Found unknown node '%s' in target information string", nodeName));
}
}
} catch (final ParserConfigurationException | SAXException | IOException exception) {
CUtilityFunctions.logException(exception);
throw new MessageParserException(exception.getLocalizedMessage());
}
if (addressSize == -1) {
throw new MessageParserException("E00070: IE01043: Received invalid target information string (missing address size information)");
}
Preconditions.checkNotNull(registers, "IE01044: Received invalid target information string (missing registers information)");
Preconditions.checkNotNull(options, "IE01046: Received invalid target information string (missing options information)");
return new TargetInformation(addressSize, registers, options);
}
use of com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions in project binnavi by google.
the class DebuggerTest method writeRegister4.
@Test(expected = IllegalArgumentException.class)
public void writeRegister4() throws DebugException {
debugger.connect();
debugger.getNative().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)));
debugger.writeRegister(0, "ebx", 0);
}
Aggregations