Search in sources :

Example 21 with Pair

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

the class CBreakpointRemoveFunctions method deleteBreakpoints.

/**
 * Deletes the breakpoints specified by the rows argument.
 *
 * @param debuggerProvider Provides the debuggers where breakpoints can be set.
 * @param rows Rows that identify the breakpoints.
 */
public static void deleteBreakpoints(final BackEndDebuggerProvider debuggerProvider, final int[] rows) {
    Preconditions.checkNotNull(debuggerProvider, "IE01886: Debugger provider argument can not be null");
    Preconditions.checkNotNull(rows, "IE02253: Rows argument can't be null");
    final ArrayList<Pair<IDebugger, BreakpointAddress>> addresses = new ArrayList<Pair<IDebugger, BreakpointAddress>>();
    for (final int row : rows) {
        final Pair<IDebugger, Integer> breakpoint = CBreakpointTableHelpers.findBreakpoint(debuggerProvider, row);
        final BreakpointManager manager = breakpoint.first().getBreakpointManager();
        final int breakpointIndex = breakpoint.second();
        addresses.add(new Pair<IDebugger, BreakpointAddress>(breakpoint.first(), manager.getBreakpoint(BreakpointType.REGULAR, breakpointIndex).getAddress()));
    }
    for (final Pair<IDebugger, BreakpointAddress> p : addresses) {
        final BreakpointManager manager = p.first().getBreakpointManager();
        final BreakpointAddress address = p.second();
        manager.setBreakpointStatus(Sets.newHashSet(address), BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DELETING);
    }
}
Also used : ArrayList(java.util.ArrayList) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) BreakpointManager(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointManager) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Breakpoint(com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 22 with Pair

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

the class CBreakpointTableHelpers method findBreakpoint.

/**
 * Given a row of the breakpoint table, this function calculates to what breakpoint manager the
 * breakpoint of that row belongs to and what index the breakpoint has within the breakpoint
 * manager.
 *
 * @param debuggerProvider The debuggers that are used to fill the breakpoint table.
 * @param row A row of the breakpoint table.
 *
 * @return A pair that contains the breakpoint manager and the breakpoint index of the breakpoint
 *         identified by the given row.
 *
 * @throws IllegalArgumentException Thrown if the debugger provider argument is null or the row
 *         argument is out of bounds.
 */
public static Pair<IDebugger, Integer> findBreakpoint(final BackEndDebuggerProvider debuggerProvider, final int row) {
    Preconditions.checkNotNull(debuggerProvider, "IE01336: Debugger provider argument can't be null");
    Preconditions.checkArgument(row >= 0, "IE01337: Row arguments can not be negative");
    int breakpoints = 0;
    for (final IDebugger debugger : debuggerProvider.getDebuggers()) {
        if ((row >= breakpoints) && (row < breakpoints + debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR))) {
            return new Pair<IDebugger, Integer>(debugger, row - breakpoints);
        } else {
            breakpoints += debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR);
        }
    }
    throw new IllegalArgumentException("IE01338: Invalid row number");
}
Also used : IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 23 with Pair

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

the class CViewPruner method convertEdges.

/**
 * Converts edges of the original view to the pruned view.
 *
 * @param view The original view.
 * @param prunedView The pruned view.
 * @param nodeMap A mapping between nodes of the original view and nodes of the pruned view.
 */
private static void convertEdges(final INaviView view, final INaviView prunedView, final Map<INaviViewNode, INaviViewNode> nodeMap) {
    final Set<Pair<INaviViewNode, INaviViewNode>> createdEdges = new HashSet<Pair<INaviViewNode, INaviViewNode>>();
    for (final INaviEdge edge : view.getGraph().getEdges()) {
        final Set<EdgeResult> sources = getSources(edge, nodeMap, new HashSet<INaviEdge>());
        final Set<EdgeResult> targets = getTargets(edge, nodeMap, new HashSet<INaviEdge>());
        for (final EdgeResult source : sources) {
            for (final EdgeResult target : targets) {
                final Pair<INaviViewNode, INaviViewNode> edgePair = new Pair<INaviViewNode, INaviViewNode>(source.m_node, target.m_node);
                if (createdEdges.contains(edgePair)) {
                    continue;
                }
                prunedView.getContent().createEdge(source.m_node, target.m_node, source.m_type);
                createdEdges.add(edgePair);
            }
        }
    }
}
Also used : INaviViewNode(com.google.security.zynamics.binnavi.disassembly.INaviViewNode) INaviEdge(com.google.security.zynamics.binnavi.disassembly.INaviEdge) Pair(com.google.security.zynamics.zylib.general.Pair) HashSet(java.util.HashSet)

Example 24 with Pair

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

the class CGlobalEdgeCommentSynchronizer method getModules.

/**
 * Returns the modules the nodes of the edge belong to.
 *
 * @param edge The edge to check.
 *
 * @return Source module and target module of the edge.
 *
 * @throws MaybeNullException Thrown if the edge does not have source module or target module.
 */
private static Pair<INaviModule, INaviModule> getModules(final INaviEdge edge) throws MaybeNullException {
    INaviModule srcModule = null;
    INaviModule tarModule = null;
    if (edge.getSource() instanceof INaviCodeNode) {
        srcModule = ((INaviCodeNode) edge.getSource()).getParentFunction().getModule();
    } else if (edge.getSource() instanceof INaviFunctionNode) {
        srcModule = ((INaviFunctionNode) edge.getSource()).getFunction().getModule();
    }
    if (edge.getTarget() instanceof INaviCodeNode) {
        tarModule = ((INaviCodeNode) edge.getTarget()).getParentFunction().getModule();
    } else if (edge.getTarget() instanceof INaviFunctionNode) {
        tarModule = ((INaviFunctionNode) edge.getTarget()).getFunction().getModule();
    }
    return new Pair<INaviModule, INaviModule>(srcModule, tarModule);
}
Also used : INaviCodeNode(com.google.security.zynamics.binnavi.disassembly.INaviCodeNode) INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) INaviFunctionNode(com.google.security.zynamics.binnavi.disassembly.INaviFunctionNode) Pair(com.google.security.zynamics.zylib.general.Pair)

Example 25 with Pair

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

the class LocalInstructionCommentAccessor method getAllComments.

@Override
public ArrayList<Pair<INaviInstruction, IComment>> getAllComments() {
    final ArrayList<Pair<INaviInstruction, IComment>> values = new ArrayList<>();
    final CCodeNodeComments currentComments = m_codeNode.getComments();
    for (final INaviInstruction instruction : m_codeNode.getInstructions()) {
        final List<IComment> comments = currentComments.getLocalInstructionComment(instruction);
        if ((comments == null) || comments.isEmpty()) {
            values.add(new Pair<INaviInstruction, IComment>(instruction, new EmptyComment()));
            continue;
        } else {
            for (final IComment comment : comments) {
                values.add(new Pair<INaviInstruction, IComment>(instruction, comment));
            }
            values.add(new Pair<INaviInstruction, IComment>(instruction, new EmptyComment()));
        }
    }
    return values;
}
Also used : EmptyComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.EmptyComment) IComment(com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment) CCodeNodeComments(com.google.security.zynamics.binnavi.disassembly.CCodeNodeComments) ArrayList(java.util.ArrayList) Pair(com.google.security.zynamics.zylib.general.Pair) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

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