use of com.google.security.zynamics.binnavi.API.disassembly.FunctionBlock in project binnavi by google.
the class PathFinder method findPassedFunctions.
/**
* Determines all functions that lie on all possible paths between a given start function and a
* given target function.
*
* @param callgraph The Call graph that contains all function call information.
* @param startFunction The start function of the path.
* @param targetFunction The target function of the path.
*
* @return A set of all functions that are passed on the possible paths between the start function
* and the end function.
*/
private static LinkedHashSet<FunctionBlock> findPassedFunctions(final Callgraph callgraph, final Function startFunction, final Function targetFunction) {
// Find the graph nodes that correspond to the functions in the graph
final FunctionBlock sourceCallgraphNode = findBlock(callgraph, startFunction);
final FunctionBlock targetCallgraphNode = findBlock(callgraph, targetFunction);
Logger.info("Source block: %s\n", sourceCallgraphNode.getFunction().getName());
Logger.info("Target block: %s\n", targetCallgraphNode.getFunction().getName());
// Passed functions = Intersection of the successors of the start function and the predecessors
// of the target function.
final Collection<FunctionBlock> successorFunctions = GraphAlgorithms.getSuccessors(sourceCallgraphNode);
final Collection<FunctionBlock> predecessorFunctions = GraphAlgorithms.getPredecessors(targetCallgraphNode);
final LinkedHashSet<FunctionBlock> sharedFunctions = new LinkedHashSet<FunctionBlock>(successorFunctions);
sharedFunctions.retainAll(predecessorFunctions);
sharedFunctions.add(sourceCallgraphNode);
sharedFunctions.add(targetCallgraphNode);
return sharedFunctions;
}
Aggregations