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;
}
Aggregations