Package ghidra.util.bytesearch
Class SequenceSearchState
- java.lang.Object
-
- ghidra.util.bytesearch.SequenceSearchState
-
- All Implemented Interfaces:
java.lang.Comparable<SequenceSearchState>
public class SequenceSearchState extends java.lang.Object implements java.lang.Comparable<SequenceSearchState>
SeqenceSearchState holds the state of a search for a DittedBitSequence within a byte sequence.
-
-
Constructor Summary
Constructors Constructor Description SequenceSearchState(SequenceSearchState parent)
Construct a sub sequence state with a parent sequence
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSequence(DittedBitSequence pat, int pos)
Add a pattern to this search sequence.void
apply(byte[] buffer, java.util.ArrayList<Match> match)
Search for patterns in a byte array.void
apply(java.io.InputStream in, long maxBytes, java.util.ArrayList<Match> match, TaskMonitor monitor)
Search for pattern in the stream -in-.void
apply(java.io.InputStream in, java.util.ArrayList<Match> match, TaskMonitor monitor)
Search for pattern in the stream -in-.static SequenceSearchState
buildStateMachine(java.util.ArrayList<? extends DittedBitSequence> patterns)
Build a search state machine from a list of DittedBitSequencesint
compareTo(SequenceSearchState o)
int
getMaxSequenceSize()
void
sequenceMatch(byte[] bytearray, int numbytes, java.util.ArrayList<Match> match)
Try to match this Sequence to the byteArray, and add any matches to the match listvoid
sortSequences()
Sort the sequences that have been added
-
-
-
Constructor Detail
-
SequenceSearchState
public SequenceSearchState(SequenceSearchState parent)
Construct a sub sequence state with a parent sequence- Parameters:
parent
- parent SequenceSearchState
-
-
Method Detail
-
getMaxSequenceSize
public int getMaxSequenceSize()
- Returns:
- maximum number of bytes that could be matched by this sequence
-
addSequence
public void addSequence(DittedBitSequence pat, int pos)
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
public int compareTo(SequenceSearchState o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<SequenceSearchState>
-
sequenceMatch
public void sequenceMatch(byte[] bytearray, int numbytes, java.util.ArrayList<Match> match)
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
public void apply(byte[] buffer, java.util.ArrayList<Match> match)
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
public void apply(java.io.InputStream in, java.util.ArrayList<Match> match, TaskMonitor monitor) throws java.io.IOException
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:
java.io.IOException
-
apply
public void apply(java.io.InputStream in, long maxBytes, java.util.ArrayList<Match> match, TaskMonitor monitor) throws java.io.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:
java.io.IOException
-
buildStateMachine
public static SequenceSearchState buildStateMachine(java.util.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
-
-