Search in sources :

Example 6 with RegisterValues

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.

the class SingleStepParser method parseSuccess.

@Override
public SingleStepReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final long tid = parseThreadId();
    final RelocatedAddress address = new RelocatedAddress(parseAddress());
    try {
        final RegisterValues registerValues = RegisterValuesParser.parse(parseData());
        return new SingleStepReply(packetId, 0, tid, address, registerValues);
    } catch (final MessageParserException e) {
        return new SingleStepReply(packetId, PARSER_ERROR, tid, address, null);
    }
}
Also used : SingleStepReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.SingleStepReply) MessageParserException(com.google.security.zynamics.binnavi.debug.connection.packets.parsers.MessageParserException) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)

Example 7 with RegisterValues

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.

the class StepBreakpointHitParser method parseSuccess.

@Override
public StepBreakpointHitReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final long tid = parseThreadId();
    final byte[] data = parseData();
    try {
        final RegisterValues registerValues = RegisterValuesParser.parse(data);
        return new StepBreakpointHitReply(packetId, 0, tid, registerValues);
    } catch (final MessageParserException e) {
        return new StepBreakpointHitReply(packetId, PARSER_ERROR, tid, null);
    }
}
Also used : MessageParserException(com.google.security.zynamics.binnavi.debug.connection.packets.parsers.MessageParserException) StepBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointHitReply) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)

Example 8 with RegisterValues

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.

the class RegisterValuesParser method parse.

/**
   * Parses a byte array from the debug client into usable register information.
   *
   * @param data Byte array from the debug client.
   *
   * @return Usable register information.
   *
   * @throws IllegalArgumentException If the data argument is null.
   * @throws MessageParserException If parsing the message failed.
   */
public static RegisterValues parse(final byte[] data) throws MessageParserException {
    Preconditions.checkNotNull(data, "IE01299: Data argument can not be null");
    final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    try {
        final DocumentBuilder builder = factory.newDocumentBuilder();
        final Document document = builder.parse(new ByteArrayInputStream(data, 0, data.length));
        final NodeList nodes = document.getFirstChild().getChildNodes();
        final List<ThreadRegisters> threads = new ArrayList<>();
        for (int i = 0; i < nodes.getLength(); ++i) {
            final Node node = nodes.item(i);
            if (node.getNodeName().equals("Thread")) {
                threads.add(parseThreadNode(node));
            } else {
                throw new MessageParserException(String.format("IE01040: Invalid node '%s' found during register values message parsing", node.getNodeName()));
            }
        }
        return new RegisterValues(threads);
    } catch (IOException | ParserConfigurationException | SAXException exception) {
        CUtilityFunctions.logException(exception);
        throw new MessageParserException(exception.getLocalizedMessage());
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Document(org.w3c.dom.Document) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues) SAXException(org.xml.sax.SAXException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ByteArrayInputStream(java.io.ByteArrayInputStream) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ThreadRegisters(com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)

Example 9 with RegisterValues

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.

the class EchoBreakpointHitParser method parseSuccess.

@Override
public EchoBreakpointHitReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final long tid = parseThreadId();
    final byte[] data = parseData();
    // Try to convert the byte data into valid register values.
    try {
        final RegisterValues registerValues = RegisterValuesParser.parse(data);
        return new EchoBreakpointHitReply(packetId, 0, tid, registerValues);
    } catch (final Exception e) {
        CUtilityFunctions.logException(e);
        return new EchoBreakpointHitReply(packetId, PARSER_ERROR, 0, null);
    }
}
Also used : EchoBreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply) IOException(java.io.IOException) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)

Example 10 with RegisterValues

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues in project binnavi by google.

the class BreakpointHitParser method parseSuccess.

@Override
public BreakpointHitReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final long tid = parseThreadId();
    final byte[] data = parseData();
    try {
        final RegisterValues registerValues = RegisterValuesParser.parse(data);
        return new BreakpointHitReply(packetId, 0, tid, registerValues);
    } catch (final Exception e) {
        CUtilityFunctions.logException(e);
        return new BreakpointHitReply(packetId, PARSER_ERROR, tid, null);
    }
}
Also used : BreakpointHitReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointHitReply) IOException(java.io.IOException) RegisterValues(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)

Aggregations

RegisterValues (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValues)17 ThreadRegisters (com.google.security.zynamics.binnavi.debug.models.targetinformation.ThreadRegisters)11 Test (org.junit.Test)10 RegisterValue (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterValue)9 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)9 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)8 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)7 EchoBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointHitReply)6 StepBreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointHitReply)6 BigInteger (java.math.BigInteger)6 StepBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointSetReply)5 EchoBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply)4 EchoBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply)4 StepBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointsRemovedReply)4 BreakpointConditionSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointConditionSetReply)3 BreakpointHitReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.BreakpointHitReply)3 SingleStepReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.SingleStepReply)3 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)2 Trace (com.google.security.zynamics.binnavi.API.disassembly.Trace)2 TracePoint (com.google.security.zynamics.binnavi.API.disassembly.TracePoint)2