Class PackedDecode

java.lang.Object
ghidra.program.model.pcode.PackedDecode
All Implemented Interfaces:
ByteIngest, Decoder
Direct Known Subclasses:
PackedDecodeOverlay

public class PackedDecode extends Object implements Decoder
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    protected AddressSpace[]
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clear any previous cached bytes.
    void
    closeElement(int id)
    Close the current element The data for the current element is considered fully processed.
    void
    Close the current element, skipping any child elements that have not yet been parsed.
    void
    Formal indicator that ingesting of bytes is complete and processing can begin
     
    int
    Get the next attribute id for the current element Attributes are automatically set up for traversal using this method, when the element is opened.
    void
    Ingest bytes from the stream up to (and including) the first 0 byte.
    boolean
     
    void
    open(int max, String source)
    Open the ingester for receiving bytes.
    int
    Open (traverse into) the next child element of the current parent.
    int
    Open (traverse into) the next child element, which must be of a specific type The child becomes the current parent, and its attributes are initialized for use with getNextAttributeId.
    int
    Peek at the next child element of the current parent, without traversing in (opening) it.
    boolean
    Parse the current attribute as a boolean value The last attribute, as returned by getNextAttributeId, is treated as a boolean, and its value is returned.
    boolean
    Find and parse a specific attribute in the current element as a boolean value The set of attributes for the current element is searched for a match to the given attribute id.
    long
    Parse the current attribute as a signed integer value The last attribute, as returned by getNextAttributeId, is treated as a signed integer, and its value is returned.
    long
    Find and parse a specific attribute in the current element as a signed integer The set of attributes for the current element is searched for a match to the given attribute id.
    Parse the current attribute as an address space The last attribute, as returned by getNextAttributeId, is returned as an address space.
    Find the specific attribute in the current element and return it as an address space Search attributes from the current element for a match to the given attribute id.
    Parse the current attribute as a string The last attribute, as returned by getNextAttributeId, is returned as a string.
    Find the specific attribute in the current element and return it as a string The set of attributes for the current element is searched for a match to the given attribute id.
    long
    Parse the current attribute as an unsigned integer value The last attribute, as returned by getNextAttributeId, is treated as an unsigned integer, and its value is returned.
    long
    Find and parse a specific attribute in the current element as an unsigned integer The set of attributes for the current element is searched for a match to the given attribute id.
    void
    Reset attribute traversal for the current element Attributes for a single element can be traversed more than once using the getNextAttributeId method.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface ghidra.program.model.pcode.Decoder

    skipElement
  • Field Details

  • Constructor Details

  • Method Details

    • getAddressFactory

      public AddressFactory getAddressFactory()
      Specified by:
      getAddressFactory in interface Decoder
    • clear

      public void clear()
      Description copied from interface: ByteIngest
      Clear any previous cached bytes.
      Specified by:
      clear in interface ByteIngest
    • open

      public void open(int max, String source)
      Description copied from interface: ByteIngest
      Open the ingester for receiving bytes. This establishes the description of the source of the bytes and maximum number of bytes that can be read
      Specified by:
      open in interface ByteIngest
      Parameters:
      max - is the maximum number of bytes that can be read
      source - is the description of the byte source
    • ingestStream

      public void ingestStream(InputStream stream) throws IOException
      Description copied from interface: ByteIngest
      Ingest bytes from the stream up to (and including) the first 0 byte. This can be called multiple times to read in bytes in different chunks. An absolute limit is set on the number of bytes that can be ingested via the max parameter to a previous call to open(), otherwise an exception is thrown.
      Specified by:
      ingestStream in interface ByteIngest
      Parameters:
      stream - is the input stream to read from
      Throws:
      IOException - for errors reading from the stream
    • endIngest

      public void endIngest()
      Description copied from interface: ByteIngest
      Formal indicator that ingesting of bytes is complete and processing can begin
      Specified by:
      endIngest in interface ByteIngest
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface ByteIngest
      Returns:
      true if no bytes have yet been ingested via ingestStream()
    • peekElement

      public int peekElement() throws DecoderException
      Description copied from interface: Decoder
      Peek at the next child element of the current parent, without traversing in (opening) it. The element id is returned, which can be compared to ElementId labels. If there are no remaining child elements to traverse, 0 is returned.
      Specified by:
      peekElement in interface Decoder
      Returns:
      the element id or 0
      Throws:
      DecoderException - for an unexpected end of stream
    • openElement

      public int openElement() throws DecoderException
      Description copied from interface: Decoder
      Open (traverse into) the next child element of the current parent. The child becomes the current parent. The list of attributes is initialized for use with getNextAttributeId.
      Specified by:
      openElement in interface Decoder
      Returns:
      the id of the child element or 0 if there are no additional children
      Throws:
      DecoderException - for an unexpected end of stream
    • openElement

      public int openElement(ElementId elemId) throws DecoderException
      Description copied from interface: Decoder
      Open (traverse into) the next child element, which must be of a specific type The child becomes the current parent, and its attributes are initialized for use with getNextAttributeId. The child must match the given element id or an exception is thrown.
      Specified by:
      openElement in interface Decoder
      Parameters:
      elemId - is the given element id to match
      Returns:
      the id of the child element
      Throws:
      DecoderException - if the expected element is not the next element
    • closeElement

      public void closeElement(int id) throws DecoderException
      Description copied from interface: Decoder
      Close the current element The data for the current element is considered fully processed. If the element has additional children, an exception is thrown. The stream must indicate the end of the element in some way.
      Specified by:
      closeElement in interface Decoder
      Parameters:
      id - is the id of the element to close (which must be the current element)
      Throws:
      DecoderException - if not at end of expected element
    • closeElementSkipping

      public void closeElementSkipping(int id) throws DecoderException
      Description copied from interface: Decoder
      Close the current element, skipping any child elements that have not yet been parsed. This closes the given element, which must be current. If there are child elements that have not been parsed, this is not considered an error, and they are skipped over in the parse.
      Specified by:
      closeElementSkipping in interface Decoder
      Parameters:
      id - is the id of the element to close (which must be the current element)
      Throws:
      DecoderException - if the indicated element is not the current element
    • getNextAttributeId

      public int getNextAttributeId() throws DecoderException
      Description copied from interface: Decoder
      Get the next attribute id for the current element Attributes are automatically set up for traversal using this method, when the element is opened. If all attributes have been traversed (or there are no attributes), 0 is returned.
      Specified by:
      getNextAttributeId in interface Decoder
      Returns:
      the id of the next attribute or 0
      Throws:
      DecoderException - for unexpected end of stream
    • rewindAttributes

      public void rewindAttributes()
      Description copied from interface: Decoder
      Reset attribute traversal for the current element Attributes for a single element can be traversed more than once using the getNextAttributeId method.
      Specified by:
      rewindAttributes in interface Decoder
    • readBool

      public boolean readBool() throws DecoderException
      Description copied from interface: Decoder
      Parse the current attribute as a boolean value The last attribute, as returned by getNextAttributeId, is treated as a boolean, and its value is returned.
      Specified by:
      readBool in interface Decoder
      Returns:
      the boolean value associated with the current attribute.
      Throws:
      DecoderException - if the expected value is not present
    • readBool

      public boolean readBool(AttributeId attribId) throws DecoderException
      Description copied from interface: Decoder
      Find and parse a specific attribute in the current element as a boolean value The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as a boolean and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.
      Specified by:
      readBool in interface Decoder
      Parameters:
      attribId - is the specific attribute id to match
      Returns:
      the boolean value
      Throws:
      DecoderException - if the expected value is not present
    • readSignedInteger

      public long readSignedInteger() throws DecoderException
      Description copied from interface: Decoder
      Parse the current attribute as a signed integer value The last attribute, as returned by getNextAttributeId, is treated as a signed integer, and its value is returned.
      Specified by:
      readSignedInteger in interface Decoder
      Returns:
      the signed integer value associated with the current attribute.
      Throws:
      DecoderException - if the expected value is not present
    • readSignedInteger

      public long readSignedInteger(AttributeId attribId) throws DecoderException
      Description copied from interface: Decoder
      Find and parse a specific attribute in the current element as a signed integer The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as a signed integer and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.
      Specified by:
      readSignedInteger in interface Decoder
      Parameters:
      attribId - is the specific attribute id to match
      Returns:
      the signed integer value
      Throws:
      DecoderException - if the expected value is not present
    • readUnsignedInteger

      public long readUnsignedInteger() throws DecoderException
      Description copied from interface: Decoder
      Parse the current attribute as an unsigned integer value The last attribute, as returned by getNextAttributeId, is treated as an unsigned integer, and its value is returned.
      Specified by:
      readUnsignedInteger in interface Decoder
      Returns:
      the unsigned integer value associated with the current attribute.
      Throws:
      DecoderException - if the expected value is not present
    • readUnsignedInteger

      public long readUnsignedInteger(AttributeId attribId) throws DecoderException
      Description copied from interface: Decoder
      Find and parse a specific attribute in the current element as an unsigned integer The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then parsed as an unsigned integer and its value returned. If there is no attribute matching the id, an exception is thrown. Parsing via getNextAttributeId is reset.
      Specified by:
      readUnsignedInteger in interface Decoder
      Parameters:
      attribId - is the specific attribute id to match
      Returns:
      the unsigned integer value
      Throws:
      DecoderException - if the expected value is not present
    • readString

      public String readString() throws DecoderException
      Description copied from interface: Decoder
      Parse the current attribute as a string The last attribute, as returned by getNextAttributeId, is returned as a string.
      Specified by:
      readString in interface Decoder
      Returns:
      the string associated with the current attribute.
      Throws:
      DecoderException - if the expected value is not present
    • readString

      public String readString(AttributeId attribId) throws DecoderException
      Description copied from interface: Decoder
      Find the specific attribute in the current element and return it as a string The set of attributes for the current element is searched for a match to the given attribute id. This attribute is then returned as a string. If there is no attribute matching the id, and exception is thrown. Parse via getNextAttributeId is reset.
      Specified by:
      readString in interface Decoder
      Parameters:
      attribId - is the specific attribute id to match
      Returns:
      the string associated with the attribute
      Throws:
      DecoderException - if the expected value is not present
    • readSpace

      public AddressSpace readSpace() throws DecoderException
      Description copied from interface: Decoder
      Parse the current attribute as an address space The last attribute, as returned by getNextAttributeId, is returned as an address space.
      Specified by:
      readSpace in interface Decoder
      Returns:
      the address space associated with the current attribute.
      Throws:
      DecoderException - if the expected value is not present
    • readSpace

      public AddressSpace readSpace(AttributeId attribId) throws DecoderException
      Description copied from interface: Decoder
      Find the specific attribute in the current element and return it as an address space Search attributes from the current element for a match to the given attribute id. Return this attribute as an address space. If there is no attribute matching the id, an exception is thrown. Parse via getNextAttributeId is reset.
      Specified by:
      readSpace in interface Decoder
      Parameters:
      attribId - is the specific attribute id to match
      Returns:
      the address space associated with the attribute
      Throws:
      DecoderException - if the expected value is not present