Package ghidra.util.bytesearch
Class SequenceSearchState
java.lang.Object
ghidra.util.bytesearch.SequenceSearchState
- All Implemented Interfaces:
Comparable<SequenceSearchState>
SeqenceSearchState holds the state of a search for a DittedBitSequence within a byte
sequence.
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a sub sequence state with a parent sequence -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSequence(DittedBitSequence pat, int pos) Add a pattern to this search sequence.voidSearch for patterns in a byte array.voidapply(InputStream in, long maxBytes, ArrayList<Match> match, TaskMonitor monitor) Search for pattern in the stream -in-.voidapply(InputStream in, ArrayList<Match> match, TaskMonitor monitor) Search for pattern in the stream -in-.static SequenceSearchStatebuildStateMachine(ArrayList<? extends DittedBitSequence> patterns) Build a search state machine from a list of DittedBitSequencesintintvoidsequenceMatch(byte[] bytearray, int numbytes, ArrayList<Match> match) Try to match this Sequence to the byteArray, and add any matches to the match listvoidSort the sequences that have been added
-
Constructor Details
-
SequenceSearchState
Construct a sub sequence state with a parent sequence- Parameters:
parent- parent SequenceSearchState
-
-
Method Details
-
getMaxSequenceSize
public int getMaxSequenceSize()- Returns:
- maximum number of bytes that could be matched by this sequence
-
addSequence
Add a pattern to this search sequence. The last pattern added is the successful match pattern.- Parameters:
pat- pattern to addpos- position within the current set of patterns to add this pattern
-
sortSequences
public void sortSequences()Sort the sequences that have been added -
compareTo
- Specified by:
compareToin interfaceComparable<SequenceSearchState>
-
sequenceMatch
Try to match this Sequence to the byteArray, and add any matches to the match list- Parameters:
bytearray- array of bytes to matchnumbytes- retrict number of bytes to allow to matchmatch- list of matches, the result
-
apply
Search for patterns in a byte array. All matches are returned.- Parameters:
buffer- is the array of bytes to searchmatch- is populated with a Match object for each pattern and position that matches
-
apply
Search for pattern in the stream -in-.- Parameters:
in- - The stream to scan for matchesmatch- - Any matches are appended as Match records to this ArrayListmonitor- - if non-null, check for user cancel, and maintain progress info- Throws:
IOException
-
apply
public void apply(InputStream in, long maxBytes, ArrayList<Match> match, TaskMonitor monitor) throws IOException Search for pattern in the stream -in-.- Parameters:
in- - The stream to scan for matchesmaxBytes- - The maximum number of bytes to scan forward in this streammatch- - Any matches are appended as Match records to this ArrayListmonitor- - if non-null, check for user cancel, and maintain progress info- Throws:
IOException
-
buildStateMachine
public static SequenceSearchState buildStateMachine(ArrayList<? extends DittedBitSequence> patterns) Build a search state machine from a list of DittedBitSequences- Parameters:
patterns- bit sequence patterns- Returns:
- search state the will match the given sequences
-