Search in sources :

Example 11 with DebuggerOptions

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);
}
Also used : FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) Test(org.junit.Test)

Example 12 with DebuggerOptions

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();
}
Also used : CDebugPerspectiveModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel) JHexView(com.google.security.zynamics.zylib.gui.JHexPanel.JHexView) IGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.IGraphModel) ArrayList(java.util.ArrayList) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) TargetInformationReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply) MockGraphModel(com.google.security.zynamics.binnavi.Gui.GraphWindows.MockGraphModel) Test(org.junit.Test)

Example 13 with DebuggerOptions

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();
}
Also used : ProcessStart(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessStart) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) ArrayList(java.util.ArrayList) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ProcessStartReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.ProcessStartReply) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) MemoryModule(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) TargetInformationReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply) Test(org.junit.Test)

Example 14 with DebuggerOptions

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);
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) IOException(java.io.IOException) Document(org.w3c.dom.Document) SAXException(org.xml.sax.SAXException) RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 15 with DebuggerOptions

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);
}
Also used : RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) Test(org.junit.Test)

Aggregations

DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)31 Test (org.junit.Test)29 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)28 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)26 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)20 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)20 ArrayList (java.util.ArrayList)19 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)18 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)18 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)18 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)16 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)16 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)15 DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)13 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)10 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)10 DetachReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.DetachReply)5 ModuleLoadedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ModuleLoadedReply)4 ModuleUnloadedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ModuleUnloadedReply)4 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)4