Class AlignRule

java.lang.Object
ghidra.util.bytesearch.AlignRule
All Implemented Interfaces:
PostRule

public class AlignRule extends Object implements PostRule
ByteSearch post search rule when a pattern is found. Used when a pattern must have a certain alignment at an offset from the location the pattern matches.

The pattern can be constructed or restored from XML of the form, where alignOffset=mark, alignmask=bits


   <align mark="0" bits="1"/>
 
  • Constructor Details

    • AlignRule

      public AlignRule()
    • AlignRule

      public AlignRule(int alignOffset, int alignmask)
      ByteSearch post search rule when a pattern is found. Used when a pattern must have a certain alignment at an offset from the location the pattern matches. The alignment is specified by the alignmask bits that must be zero. Normally alignOffset is 0, since most patterns will match at the address that must be aligned To align a match, use the following align to 2 = alignmask 0x1 - lower bit must be zero align to 4 = alignmask 0x3 - lower two bits must be zero align to 8 = alignmask 0x7 - lower three bits must be zero align to 16 = alignmask 0xF - lower four bits must be zero .... Other strange alignments could be specified, but most likely the above suffice.
      Parameters:
      alignOffset - - bytes offset from pattern to check for alignment
      alignmask - - the mask where a 1 bit must be zero
  • Method Details

    • apply

      public boolean apply(Pattern pat, long matchoffset)
      Description copied from interface: PostRule
      Apply a post rule given the matching pattern and offset into the byte stream.
      Specified by:
      apply in interface PostRule
      Parameters:
      pat - pattern that matched
      matchoffset - offset of the match
      Returns:
      true if the PostRule is satisfied
    • restoreXml

      public void restoreXml(XmlPullParser parser)
      Description copied from interface: PostRule
      Can restore state of instance PostRule from XML
      Specified by:
      restoreXml in interface PostRule
      Parameters:
      parser - XML pull parser
    • getAlignMask

      public int getAlignMask()