Search in sources :

Example 31 with Pair

use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.

the class EchoBreakpointSetParser method parseSuccess.

@Override
public EchoBreakpointSetReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final int counter = parseInteger();
    final List<Pair<RelocatedAddress, Integer>> addresses = new ArrayList<>();
    for (int i = 0; i < counter; i++) {
        final RelocatedAddress address = new RelocatedAddress(parseAddress());
        final int error = parseInteger();
        addresses.add(new Pair<RelocatedAddress, Integer>(address, error));
    }
    return new EchoBreakpointSetReply(packetId, 0, addresses);
}
Also used : RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) EchoBreakpointSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply) ArrayList(java.util.ArrayList) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 32 with Pair

use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.

the class EchoBreakpointRemovedParser method parseSuccess.

@Override
public EchoBreakpointsRemovedReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final int counter = parseInteger();
    final List<Pair<RelocatedAddress, Integer>> addresses = new ArrayList<>();
    for (int i = 0; i < counter; i++) {
        final RelocatedAddress address = new RelocatedAddress(parseAddress());
        final int error = parseInteger();
        addresses.add(new Pair<RelocatedAddress, Integer>(address, error));
    }
    return new EchoBreakpointsRemovedReply(packetId, 0, addresses);
}
Also used : EchoBreakpointsRemovedReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) ArrayList(java.util.ArrayList) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 33 with Pair

use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.

the class StepBreakpointSetParser method parseSuccess.

@Override
public StepBreakpointSetReply parseSuccess(final int packetId, final int argumentCount) throws IOException {
    final List<Pair<RelocatedAddress, Integer>> addresses = new ArrayList<>();
    final int numberOfAddresses = parseInteger();
    for (int i = 0; i < numberOfAddresses; i++) {
        final RelocatedAddress address = new RelocatedAddress(parseAddress());
        addresses.add(new Pair<RelocatedAddress, Integer>(address, parseInteger()));
    }
    return new StepBreakpointSetReply(packetId, 0, addresses);
}
Also used : StepBreakpointSetReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.StepBreakpointSetReply) RelocatedAddress(com.google.security.zynamics.binnavi.disassembly.RelocatedAddress) ArrayList(java.util.ArrayList) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 34 with Pair

use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.

the class MemoryRangeCalculator method calculateRequestRange.

/**
 * Calculates the range of memory to request from the debug client. For performance reasons this
 * range is different from the range specified by the user.
 *
 * @param offset The start offset of the range according to the user.
 * @param size The number of bytes to request according to the user.
 * @param sectionStart Beginning of the section the offset belongs to.
 * @param sectionEnd End of the section the offset belongs to.
 *
 * @return A pair that contains the real start offset and the real size information of the
 *         request.
 */
public static Pair<IAddress, Integer> calculateRequestRange(final BigInteger offset, final int size, final IAddress sectionStart, final IAddress sectionEnd) {
    // To smoothen scrolling we try to load a range that is at max
    // +- 3 requested ranges.
    final BigInteger availableBefore = offset.subtract(sectionStart.toBigInteger());
    final BigInteger availableAfter = sectionEnd.toBigInteger().subtract(offset).add(BigInteger.ONE);
    final BigInteger loadBefore = availableBefore.compareTo(BigInteger.valueOf(3L * size)) == -1 ? availableBefore : BigInteger.valueOf(3L * size);
    final BigInteger loadAfter = availableAfter.compareTo(BigInteger.valueOf(3L * size)) == -1 ? availableAfter : BigInteger.valueOf(3L * size);
    final BigInteger realOffset = offset.subtract(loadBefore);
    final int realSize = (int) (loadBefore.add(loadAfter)).longValue();
    return new Pair<IAddress, Integer>(new CAddress(realOffset), realSize);
}
Also used : BigInteger(java.math.BigInteger) Pair(com.google.security.zynamics.zylib.general.Pair) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Example 35 with Pair

use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.

the class MemoryRangeCalculator method calculateRequestRange.

/**
 * Calculates the range of memory to request from the debug client. For performance reasons this
 * range is different than the range specified by the user.
 *
 * @param debugger The debugger from which the memory is loaded.
 * @param offset The start offset of the range according to the user.
 * @param size The number of bytes to request according to the user.
 *
 * @return A pair that contains the real start offset and the real size information of the
 *         request.
 */
public static Pair<IAddress, Integer> calculateRequestRange(final IDebugger debugger, final BigInteger offset, final int size) {
    final MemoryMap mmap = debugger.getProcessManager().getMemoryMap();
    final MemorySection section = mmap.findOffset(offset);
    if (section == null) {
        return new Pair<IAddress, Integer>(new CAddress(offset), size);
    } else {
        return calculateRequestRange(offset, size, section.getStart(), section.getEnd());
    }
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) Pair(com.google.security.zynamics.zylib.general.Pair) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress)

Aggregations

Pair (com.google.security.zynamics.zylib.general.Pair)55 ArrayList (java.util.ArrayList)26 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)7 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)7 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)6 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)6 IAddress (com.google.security.zynamics.zylib.disassembly.IAddress)6 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)4 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)4 Test (org.junit.Test)4 CouldntLoadDataException (com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)3 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)3 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)3 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)3 INaviCodeNode (com.google.security.zynamics.binnavi.disassembly.INaviCodeNode)3 ReilBlock (com.google.security.zynamics.reil.ReilBlock)3 ReilInstruction (com.google.security.zynamics.reil.ReilInstruction)3 BigInteger (java.math.BigInteger)3 HashSet (java.util.HashSet)3