Class SectionHeader

java.lang.Object
ghidra.app.util.bin.format.pef.SectionHeader
All Implemented Interfaces:
StructConverter

public class SectionHeader extends Object implements StructConverter
See Apple's -- PEFBinaryFormat
 struct PEFSectionHeader {
     SInt32   nameOffset;             // Offset of name within the section name table, -1 => none.
     UInt32   defaultAddress;         // Default address, affects relocations.
     UInt32   totalLength;            // Fully expanded size in bytes of the section contents.
     UInt32   unpackedLength;         // Size in bytes of the "initialized" part of the contents.
     UInt32   containerLength;        // Size in bytes of the raw data in the container.
     UInt32   containerOffset;        // Offset of section's raw data.
     UInt8    sectionKind;            // Kind of section contents/usage.
     UInt8    shareKind;              // Sharing level, if a writeable section.
     UInt8    alignment;              // Preferred alignment, expressed as log 2.
     UInt8    reservedA;              // Reserved, must be zero.
 };
 
  • Field Details

  • Method Details

    • getNameOffset

      public int getNameOffset()
      The offset from the start of the section name table to the name of this section. A value of -1 indicates an unnamed section.
      Returns:
      the offset from the start of the section name table
    • getName

      public String getName()
      Returns the name of this section.
      Returns:
      the name of this section
    • getData

      public InputStream getData() throws IOException
      Returns an input stream to underlying bytes of this section.
      Returns:
      an input stream to underlying bytes of this section
      Throws:
      IOException - if an i/o error occurs.
    • getUnpackedData

      public byte[] getUnpackedData(TaskMonitor monitor) throws IOException
      Unpack the data in a packed section. Calling this method is only valid on a packed section.
      Parameters:
      monitor - the task monitor
      Returns:
      the unpacked data
      Throws:
      IOException - if an i/o error occurs or the section is not packed.
    • getDefaultAddress

      public int getDefaultAddress()
      Returns the preferred address of this section.
      Returns:
      the preferred address of this section
    • getTotalLength

      public int getTotalLength()
    • getUnpackedLength

      public int getUnpackedLength()
      Returns the size in bytes of the "initialized" part of the contents.
      Returns:
      the size in bytes of the "initialized" part of the contents
    • getContainerLength

      public int getContainerLength()
      Returns the size in bytes of the raw data in the container.
      Returns:
      the size in bytes of the raw data in the container
    • getContainerOffset

      public int getContainerOffset()
    • getSectionKind

      public SectionKind getSectionKind()
    • getShareKind

      public SectionShareKind getShareKind()
    • getAlignment

      public byte getAlignment()
    • getReservedA

      public byte getReservedA()
      Reserved!
      Returns:
      Reserved!
    • isRead

      public boolean isRead()
      Returns true if this section has read permissions.
      Returns:
      true if this section has read permissions
    • isWrite

      public boolean isWrite()
      Returns true if this section has write permissions.
      Returns:
      true if this section has write permissions
    • isExecute

      public boolean isExecute()
      Returns true if this section has execute permissions.
      Returns:
      true if this section has execute permissions
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toDataType

      public DataType toDataType() throws DuplicateNameException, IOException
      Description copied from interface: StructConverter
      Returns a structure datatype representing the contents of the implementor of this interface.

      For example, given:

       class A {
           int foo;
           double bar;
       }
       

      The return value should be a structure data type with two data type components; an INT and a DOUBLE. The structure should contain field names and, if possible, field comments.

      Specified by:
      toDataType in interface StructConverter
      Returns:
      returns a structure datatype representing the implementor of this interface
      Throws:
      DuplicateNameException - when a datatype of the same name already exists
      IOException - if an IO-related error occurs
      See Also: