Package ghidra.program.model.correlate
Class HashedFunctionAddressCorrelation
- java.lang.Object
- 
- ghidra.program.model.correlate.HashedFunctionAddressCorrelation
 
- 
- All Implemented Interfaces:
- FunctionAddressCorrelation,- ListingAddressCorrelation
 
 public class HashedFunctionAddressCorrelation extends java.lang.Object implements FunctionAddressCorrelation Correlator to construct a 1-1 map between the Instructions of two similar Functions. Matching is performed via a greedy algorithm that looks for sequences (n-grams) of Instructions that are similar between the two Functions. Similarity of two sequences is determined by comparing hashes generated by the HashCalculator object. 1) Potential sequences and their hashes are generated for both functions (see HashStore). 2) Sequences are pulled from the HashStore based on the uniqueness of a potential match and on the size of the sequence. 3) If a unique match is found between sequences, it is extended in either direction as far as possible, as constrained by HashCalculator and the containing basic-blocks. 4) The matching Instruction pairs are put in the final map and removed from further sequence lists to allow other potential matches to be considered. 5) Sequences with no corresponding match are also removed from consideration. 6) Sequences are limited to a single basic-block, and the algorithm is basic-block aware. Once a match establishes a correspondence between a pair of basic blocks, the algorithm uses that information to further narrow in on and disambiguate matching sequences. 7) If a particular sequence has matches that are not unique, the algorithm tries to disambiguate the potential matches by looking at parent/child relationships of the containing basic-blocks. (see DisambiguateStrategy) 8) Multiple passes are attempted, each time the set of potential sequences is completely regenerated, varying the range of sequence sizes for which a match is attempted and other hash parameters. This allows matches discovered by earlier passes to disambiguate sequences in later passes.
- 
- 
Constructor SummaryConstructors Constructor Description HashedFunctionAddressCorrelation(Function function1, Function function2, TaskMonitor mon)Correlates addresses between the two specified functions.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description AddressSetViewgetAddressesInFirst()Gets the first set of addresses for this correlator.AddressSetViewgetAddressesInSecond()Gets the second set of addresses for this correlator.AddressgetAddressInFirst(Address addressInSecond)Determine the address from the first set that matches the specified address in the second set.AddressgetAddressInSecond(Address addressInFirst)Determine the address from the second set that matches the specified address in the first set.FunctiongetFirstFunction()Gets the first function for this address correlator.ProgramgetFirstProgram()Gets the program containing the first set of addresses.java.util.Iterator<java.util.Map.Entry<Address,Address>>getFirstToSecondIterator()Gets an iterator of the matching addresses from the first function to the second.FunctiongetSecondFunction()Gets the second function for this address correlator.ProgramgetSecondProgram()Gets the program containing the second set of addresses.intgetTotalInstructionsInFirst()Gets the total number of instructions that are in the first function.intgetTotalInstructionsInSecond()Gets the total number of instructions that are in the second function.java.util.List<Instruction>getUnmatchedInstructionsInFirst()Determines the number of instructions from the first function that do not match an instruction in the second function.java.util.List<Instruction>getUnmatchedInstructionsInSecond()Determines the number of instructions from the second function that do not match an instruction in the first function.intnumMatchedInstructionsInFirst()Determines the number of instructions from the first function that match an instruction in the second function.intnumMatchedInstructionsInSecond()Determines the number of instructions from the second function that match an instruction in the first function.
 
- 
- 
- 
Constructor Detail- 
HashedFunctionAddressCorrelationpublic HashedFunctionAddressCorrelation(Function function1, Function function2, TaskMonitor mon) throws CancelledException, MemoryAccessException Correlates addresses between the two specified functions.- Parameters:
- function1- the first function
- function2- the second function
- mon- the task monitor that indicates progress and allows the user to cancel.
- Throws:
- CancelledException- if the user cancels
- MemoryAccessException- if either functions memory can't be accessed.
 
 
- 
 - 
Method Detail- 
getFirstProgrampublic Program getFirstProgram() Description copied from interface:ListingAddressCorrelationGets the program containing the first set of addresses.- Specified by:
- getFirstProgramin interface- ListingAddressCorrelation
- Returns:
- the program for the first set of addresses.
 
 - 
getSecondProgrampublic Program getSecondProgram() Description copied from interface:ListingAddressCorrelationGets the program containing the second set of addresses. This program may be different from or the same as the first program.- Specified by:
- getSecondProgramin interface- ListingAddressCorrelation
- Returns:
- the program for the second set of addresses.
 
 - 
getAddressesInFirstpublic AddressSetView getAddressesInFirst() Description copied from interface:ListingAddressCorrelationGets the first set of addresses for this correlator.- Specified by:
- getAddressesInFirstin interface- ListingAddressCorrelation
- Returns:
- the first set of addresses.
 
 - 
getAddressesInSecondpublic AddressSetView getAddressesInSecond() Description copied from interface:ListingAddressCorrelationGets the second set of addresses for this correlator.- Specified by:
- getAddressesInSecondin interface- ListingAddressCorrelation
- Returns:
- the second set of addresses.
 
 - 
getTotalInstructionsInFirstpublic int getTotalInstructionsInFirst() Gets the total number of instructions that are in the first function.- Returns:
- the first function's instruction count.
 
 - 
getTotalInstructionsInSecondpublic int getTotalInstructionsInSecond() Gets the total number of instructions that are in the second function.- Returns:
- the second function's instruction count.
 
 - 
numMatchedInstructionsInFirstpublic int numMatchedInstructionsInFirst() Determines the number of instructions from the first function that match an instruction in the second function.- Returns:
- the number of instructions in the first function that have matches.
 
 - 
numMatchedInstructionsInSecondpublic int numMatchedInstructionsInSecond() Determines the number of instructions from the second function that match an instruction in the first function.- Returns:
- the number of instructions in the second function that have matches.
 
 - 
getUnmatchedInstructionsInFirstpublic java.util.List<Instruction> getUnmatchedInstructionsInFirst() Determines the number of instructions from the first function that do not match an instruction in the second function.- Returns:
- the number of instructions in the first function without matches.
 
 - 
getUnmatchedInstructionsInSecondpublic java.util.List<Instruction> getUnmatchedInstructionsInSecond() Determines the number of instructions from the second function that do not match an instruction in the first function.- Returns:
- the number of instructions in the second function without matches.
 
 - 
getFirstToSecondIteratorpublic java.util.Iterator<java.util.Map.Entry<Address,Address>> getFirstToSecondIterator() Gets an iterator of the matching addresses from the first function to the second.- Returns:
- the iterator
 
 - 
getAddressInSecondpublic Address getAddressInSecond(Address addressInFirst) Description copied from interface:ListingAddressCorrelationDetermine the address from the second set that matches the specified address in the first set.- Specified by:
- getAddressInSecondin interface- ListingAddressCorrelation
- Parameters:
- addressInFirst- the address in the first address set.
- Returns:
- the matching address in the second set or null if a match couldn't be determined.
 
 - 
getAddressInFirstpublic Address getAddressInFirst(Address addressInSecond) Description copied from interface:ListingAddressCorrelationDetermine the address from the first set that matches the specified address in the second set.- Specified by:
- getAddressInFirstin interface- ListingAddressCorrelation
- Parameters:
- addressInSecond- the address in the second address set.
- Returns:
- the matching address in the first set or null if a match couldn't be determined.
 
 - 
getFirstFunctionpublic Function getFirstFunction() Description copied from interface:FunctionAddressCorrelationGets the first function for this address correlator.- Specified by:
- getFirstFunctionin interface- FunctionAddressCorrelation
- Returns:
- the first function.
 
 - 
getSecondFunctionpublic Function getSecondFunction() Description copied from interface:FunctionAddressCorrelationGets the second function for this address correlator.- Specified by:
- getSecondFunctionin interface- FunctionAddressCorrelation
- Returns:
- the second function.
 
 
- 
 
-