Search in sources :

Example 1 with MonoReilSolver

use of com.google.security.zynamics.reil.algorithms.mono2.common.MonoReilSolver in project binnavi by google.

the class RegisterTracker method track.

/**
 * Function to do register tracking.
 *
 * @param function The {@link ReilFunction} in which to do the register tracking.
 * @param startInstruction The {@link IInstruction} which is the start instruction.
 * @param trackedRegister The register to be tracked.
 * @param options The {@link RegisterTrackingOptions}.
 *
 * @return The {@link MonoReilSolverResult} of the tracking.
 */
public static MonoReilSolverResult<RegisterSetLatticeElement> track(final ReilFunction function, final IInstruction startInstruction, final String trackedRegister, final RegisterTrackingOptions options) {
    Preconditions.checkNotNull(function, "Error: function argument can not be null");
    Preconditions.checkNotNull(startInstruction, "Error: startInstruction argument can not be null");
    Preconditions.checkNotNull(trackedRegister, "Error: trackedRegister argument can not be null");
    Preconditions.checkNotNull(options, "Error: options argument can not be null");
    final CReilInstructionGraph instructionGraph = new CReilInstructionGraph(function.getGraph());
    final RegisterSetLatticeElement registerSetLatticeElement = new RegisterSetLatticeElement(trackedRegister);
    final MonoReilSolver<RegisterSetLatticeElement> monoReilSolver = new MonoReilSolver<RegisterSetLatticeElement>(instructionGraph, options.getAnalysisDirection(), new RegisterSetLattice());
    final Iterable<IInstructionGraphEdge> relevantEdges = options.trackIncoming() ? instructionGraph.getIncomingEdgesForAddress(startInstruction.getAddress()) : instructionGraph.getOutgoingEdgesForAddress(startInstruction.getAddress());
    final List<Pair<IInstructionGraphEdge, RegisterSetLatticeElement>> initialState = new ArrayList<Pair<IInstructionGraphEdge, RegisterSetLatticeElement>>();
    for (final IInstructionGraphEdge currentRelevantEdge : relevantEdges) {
        initialState.add(new Pair<IInstructionGraphEdge, RegisterSetLatticeElement>(currentRelevantEdge, registerSetLatticeElement));
    }
    final ITransformationProvider<RegisterSetLatticeElement> transformationProvider = new RegisterTrackingTransformationProvider(options);
    final MonoReilSolverResult<RegisterSetLatticeElement> solverResult = monoReilSolver.solve(transformationProvider, initialState, Integer.MAX_VALUE);
    return solverResult;
}
Also used : IInstructionGraphEdge(com.google.security.zynamics.reil.algorithms.mono2.common.instructiongraph.interfaces.IInstructionGraphEdge) ArrayList(java.util.ArrayList) CReilInstructionGraph(com.google.security.zynamics.reil.yfileswrap.algorithms.mono2.common.instructiongraph.CReilInstructionGraph) MonoReilSolver(com.google.security.zynamics.reil.algorithms.mono2.common.MonoReilSolver) Pair(com.google.security.zynamics.zylib.general.Pair)

Aggregations

MonoReilSolver (com.google.security.zynamics.reil.algorithms.mono2.common.MonoReilSolver)1 IInstructionGraphEdge (com.google.security.zynamics.reil.algorithms.mono2.common.instructiongraph.interfaces.IInstructionGraphEdge)1 CReilInstructionGraph (com.google.security.zynamics.reil.yfileswrap.algorithms.mono2.common.instructiongraph.CReilInstructionGraph)1 Pair (com.google.security.zynamics.zylib.general.Pair)1 ArrayList (java.util.ArrayList)1