Package ghidra.util.bytesearch
Class Pattern
- java.lang.Object
-
- ghidra.util.bytesearch.DittedBitSequence
-
- ghidra.util.bytesearch.Pattern
-
- Direct Known Subclasses:
GenericByteSequencePattern
public class Pattern extends DittedBitSequence
Pattern is an association of a DittedBitSequence to match, a set of post rules after a match is found that must be satisfied, and a set of actions to be taken if the pattern matches. These patterns can be restored from an XML file.
-
-
Field Summary
-
Fields inherited from class ghidra.util.bytesearch.DittedBitSequence
popcount
-
-
Constructor Summary
Constructors Constructor Description Pattern()Construct an empty pattern.Pattern(DittedBitSequence seq, int offset, PostRule[] postArray, MatchAction[] matchArray)Construct the pattern based on a DittedByteSequence a match offset, post matching rules, and a set of actions to take when the match occurs.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetMarkOffset()MatchAction[]getMatchActions()PostRule[]getPostRules()static voidreadPatterns(ResourceFile file, java.util.ArrayList<Pattern> patlist, PatternFactory pfactory)Read patterns from specified filestatic voidreadPostPatterns(java.io.File file, java.util.ArrayList<Pattern> patternList, PatternFactory pfactory)Read just the post patterns from thetags voidrestoreXml(XmlPullParser parser, PatternFactory pfactory)static voidrestoreXmlAttributes(java.util.ArrayList<PostRule> postrulelist, java.util.ArrayList<MatchAction> actionlist, XmlPullParser parser, PatternFactory pfactory)Restore the PostRule and the MatchAction tagsvoidsetMatchActions(MatchAction[] actions)-
Methods inherited from class ghidra.util.bytesearch.DittedBitSequence
concatenate, equals, getHexString, getIndex, getMaskBytes, getNumFixedBits, getNumInitialFixedBits, getNumUncertainBits, getSize, getValueBytes, hashCode, isMatch, restoreXmlData, setIndex, toString, writeBits
-
-
-
-
Constructor Detail
-
Pattern
public Pattern()
Construct an empty pattern. Use XML to initialize
-
Pattern
public Pattern(DittedBitSequence seq, int offset, PostRule[] postArray, MatchAction[] matchArray)
Construct the pattern based on a DittedByteSequence a match offset, post matching rules, and a set of actions to take when the match occurs.- Parameters:
seq- DittedByteSequenceoffset- offset from the actual match location to report a matchpostArray- post set of rules to check for the matchmatchArray- MatchActions to apply when a match occurs
-
-
Method Detail
-
getPostRules
public PostRule[] getPostRules()
-
getMatchActions
public MatchAction[] getMatchActions()
-
setMatchActions
public void setMatchActions(MatchAction[] actions)
-
getMarkOffset
public int getMarkOffset()
-
restoreXmlAttributes
public static void restoreXmlAttributes(java.util.ArrayList<PostRule> postrulelist, java.util.ArrayList<MatchAction> actionlist, XmlPullParser parser, PatternFactory pfactory) throws java.io.IOException
Restore the PostRule and the MatchAction tags- Parameters:
parser- is the parser at the start of tagspfactory- is the factory for the PostRule and MatchAction objects- Throws:
java.io.IOException
-
restoreXml
public void restoreXml(XmlPullParser parser, PatternFactory pfactory) throws java.io.IOException
- Throws:
java.io.IOException
-
readPatterns
public static void readPatterns(ResourceFile file, java.util.ArrayList<Pattern> patlist, PatternFactory pfactory) throws org.xml.sax.SAXException, java.io.IOException
Read patterns from specified file- Parameters:
file- pattern filepatlist- list for patterns to be added topfactory- optional factory for use in parsing PostRule and MatchAction elements. If null such elements may not be present.- Throws:
org.xml.sax.SAXExceptionjava.io.IOException
-
readPostPatterns
public static void readPostPatterns(java.io.File file, java.util.ArrayList<Pattern> patternList, PatternFactory pfactory) throws org.xml.sax.SAXException, java.io.IOExceptionRead just the post patterns from thetags - Parameters:
file- is the file to read frompatternList- collects the resulting Pattern objectspfactory- is the factory for constructing postrules and matchactions- Throws:
java.io.IOExceptionorg.xml.sax.SAXException
-
-