Class ModelRule

java.lang.Object
ghidra.program.model.lang.protorules.ModelRule

public class ModelRule extends Object
A rule controlling how parameters are assigned addresses Rules are applied to a parameter in the context of a full function prototype. A rule applies only for a specific class of data-type associated with the parameter, as determined by its DatatypeFilter, and may have other criteria limiting when it applies (via QualifierFilter).
  • Constructor Details

    • ModelRule

      public ModelRule()
    • ModelRule

      public ModelRule(ModelRule op2, ParamListStandard res) throws InvalidInputException
      Copy constructor
      Parameters:
      op2 - is the ModelRule to copy from
      res - is the new resource set to associate with the copy
      Throws:
      InvalidInputException - if necessary resources are not present in the resource set
    • ModelRule

      public ModelRule(DatatypeFilter typeFilter, AssignAction action, ParamListStandard res) throws InvalidInputException
      Construct from components The provided components are cloned into the new object.
      Parameters:
      typeFilter - is the data-type filter the rule applies before performing the action
      action - is the action that will be applied
      res - is the resource list to which this rule will be applied
      Throws:
      InvalidInputException - if necessary resources are missing from the list
  • Method Details

    • isEquivalent

      public boolean isEquivalent(ModelRule op)
    • assignAddress

      public int assignAddress(DataType dt, PrototypePieces proto, int pos, DataTypeManager dtManager, int[] status, ParameterPieces res)
      Assign an address and other details for a specific parameter or for return storage in context The Address is only assigned if the data-type filter and the optional qualifier filter pass, otherwise a FAIL response is returned. If the filters pass, the Address is assigned based on the AssignAction specific to this rule, and the action's response code is returned.
      Parameters:
      dt - is the data-type of the parameter or return value
      proto - is the high-level description of the function prototype
      pos - is the position of the parameter (pos>=0) or return storage (pos=-1)
      dtManager - is a data-type manager for (possibly) transforming the data-type
      status - is the resource consumption array
      res - will hold the resulting description of the parameter
      Returns:
      the response code
    • encode

      public void encode(Encoder encoder) throws IOException
      Encode this rule to a stream
      Parameters:
      encoder - is the stream encode
      Throws:
      IOException - for problems with the stream
    • restoreXml

      public void restoreXml(XmlPullParser parser, ParamListStandard res) throws XmlParseException
      Decode this rule from stream
      Parameters:
      parser - is the stream decoder
      res - is the parameter resource list owning this rule
      Throws:
      XmlParseException - if there are problems decoding are missing resources