Class SequenceSearchState

java.lang.Object
ghidra.util.bytesearch.SequenceSearchState
All Implemented Interfaces:
Comparable<SequenceSearchState>

public class SequenceSearchState extends Object implements Comparable<SequenceSearchState>
SeqenceSearchState holds the state of a search for a DittedBitSequence within a byte sequence.
  • Constructor Details

    • SequenceSearchState

      public SequenceSearchState(SequenceSearchState parent)
      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

      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 add
      pos - 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 interface Comparable<SequenceSearchState>
    • sequenceMatch

      public void sequenceMatch(byte[] bytearray, int numbytes, 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 match
      numbytes - retrict number of bytes to allow to match
      match - list of matches, the result
    • apply

      public void apply(byte[] buffer, ArrayList<Match> match)
      Search for patterns in a byte array. All matches are returned.
      Parameters:
      buffer - is the array of bytes to search
      match - is populated with a Match object for each pattern and position that matches
    • apply

      public void apply(InputStream in, ArrayList<Match> match, TaskMonitor monitor) throws IOException
      Search for pattern in the stream -in-.
      Parameters:
      in - - The stream to scan for matches
      match - - Any matches are appended as Match records to this ArrayList
      monitor - - 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 matches
      maxBytes - - The maximum number of bytes to scan forward in this stream
      match - - Any matches are appended as Match records to this ArrayList
      monitor - - 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