Class PcodeInjectLibrary

java.lang.Object
ghidra.program.model.lang.PcodeInjectLibrary

public class PcodeInjectLibrary extends Object
  • Field Details

    • language

      protected SleighLanguage language
    • uniqueBase

      protected long uniqueBase
  • Constructor Details

    • PcodeInjectLibrary

      public PcodeInjectLibrary(SleighLanguage l)
    • PcodeInjectLibrary

      public PcodeInjectLibrary(PcodeInjectLibrary op2)
      Clone a library so that a Program can extend the library without modifying the base library from Language. InjectPayloads can be considered immutable and don't need to be cloned.
      Parameters:
      op2 - is the library to clone
  • Method Details

    • clone

      public PcodeInjectLibrary clone()
      Overrides:
      clone in class Object
      Returns:
      A clone of this library
    • getProgramPayloads

      public InjectPayloadSleigh[] getProgramPayloads()
      Returns:
      an array of all the program specific payloads (or null)
    • hasProgramPayload

      public boolean hasProgramPayload(String nm, int type)
      Determine if the given payload name and type exists and is an extension of the program.
      Parameters:
      nm - is the payload name
      type - is the payload type
      Returns:
      true if the program extension exists
    • isOverride

      public boolean isOverride(String nm, int type)
      Check if a specific payload has been overridden by a user extension
      Parameters:
      nm - is the name of the payload
      type - is the type of payload
      Returns:
      true if the payload is overridden
    • getPayload

      public InjectPayload getPayload(int type, String name)
    • parseInject

      public void parseInject(InjectPayload payload) throws SleighException
      Convert the XML string representation of the given payload to a ConstructTpl The payload should be unattached (not already installed in the library)
      Parameters:
      payload - is the given payload whose XML should be converted
      Throws:
      SleighException - if there is any parsing issue
    • getCallFixupNames

      public String[] getCallFixupNames()
      Returns:
      a list of names for all installed call-fixups
    • getCallotherFixupNames

      public String[] getCallotherFixupNames()
      Returns:
      a list of names for all installed callother-fixups
    • buildInjectContext

      public InjectContext buildInjectContext()
    • hasUserDefinedOp

      public boolean hasUserDefinedOp(String name)
      Determine if the language has a given user-defined op. In which case, a CALLOTHER_FIXUP can be installed for it.
      Parameters:
      name - is the putative name of the user-defined op
      Returns:
      true if the user-defined op exists
    • registerInject

      protected void registerInject(InjectPayload payload)
    • removeMechanismPayload

      protected boolean removeMechanismPayload(String nm)
      Remove a specific call mechanism payload.
      Parameters:
      nm - is the name of the payload
      Returns:
      true if a payload was successfully removed
    • uninstallProgramPayloads

      protected void uninstallProgramPayloads()
    • registerProgramInject

      protected void registerProgramInject(List<InjectPayloadSleigh> userPayloads)
    • allocateInject

      public InjectPayload allocateInject(String sourceName, String name, int tp)
      The main InjectPayload factory interface. This can be overloaded by derived libraries to produce custom dynamic payloads.
      Parameters:
      sourceName - is a description of the source of the payload
      name - is the formal name of the payload
      tp - is the type of payload: CALLFIXUP_TYPE, CALLOTHERFIXUP_TYPE, etc.
      Returns:
      the newly minted InjectPayload
    • encodeCompilerSpec

      public void encodeCompilerSpec(Encoder encoder) throws IOException
      Encode the parts of the inject library that come from the compiler spec to the output stream
      Parameters:
      encoder - is the stream encoder
      Throws:
      IOException - for errors writing to the underlying stream
    • restoreXmlInject

      public InjectPayload restoreXmlInject(String source, String name, int tp, XmlPullParser parser) throws XmlParseException
      Throws:
      XmlParseException
    • getConstantPool

      public ConstantPool getConstantPool(Program program) throws IOException
      Get the constant pool associated with the given Program
      Parameters:
      program - is the given Program
      Returns:
      the ConstantPool associated with the Program
      Throws:
      IOException - for issues constructing the object
    • getUniqueBase

      protected long getUniqueBase()
    • isEquivalent

      public boolean isEquivalent(PcodeInjectLibrary obj)
      Compare that this and the other library contain all equivalent payloads
      Parameters:
      obj - is the other library
      Returns:
      true if all payloads are equivalent