Class CliAbstractTable

java.lang.Object
ghidra.app.util.bin.format.pe.cli.tables.CliAbstractTable
All Implemented Interfaces:
PeMarkupable, StructConverter
Direct Known Subclasses:
CliTableAssembly, CliTableAssemblyOS, CliTableAssemblyProcessor, CliTableAssemblyRef, CliTableAssemblyRefOS, CliTableAssemblyRefProcessor, CliTableClassLayout, CliTableConstant, CliTableCustomAttribute, CliTableDeclSecurity, CliTableEvent, CliTableEventMap, CliTableExportedType, CliTableField, CliTableFieldLayout, CliTableFieldMarshall, CliTableFieldRVA, CliTableFile, CliTableGenericParam, CliTableGenericParamConstraint, CliTableImplMap, CliTableInterfaceImpl, CliTableManifestResource, CliTableMemberRef, CliTableMethodDef, CliTableMethodImpl, CliTableMethodSemantics, CliTableMethodSpec, CliTableModule, CliTableModuleRef, CliTableNestedClass, CliTableParam, CliTableProperty, CliTablePropertyMap, CliTableStandAloneSig, CliTableTypeDef, CliTableTypeRef, CliTableTypeSpec

public abstract class CliAbstractTable extends Object implements StructConverter, PeMarkupable
Generic Metadata table. Subclasses should provided implementations for the actual tables.
  • Field Details

  • Constructor Details

    • CliAbstractTable

      public CliAbstractTable(BinaryReader reader, CliStreamMetadata metadataStream, CliTypeTable tableType)
      Creates a new generic CLI metadata table. This is intended to be called by a subclass metadata table during its creation.
      Parameters:
      reader - A reader that is used to read the table.
      metadataStream - The metadata stream that the table lives in.
      tableType - The type of table to create.
  • Method Details

    • getTableType

      public CliTypeTable getTableType()
      Gets this table's table type.
      Returns:
      This table's table type.
    • getNumRows

      public int getNumRows()
      Gets the number of rows in this table. return The number of rows in this table.
    • getRowSize

      public int getRowSize()
      Gets the size in bytes of a row in this table. return The size in bytes of a row in this table.
    • getTableSize

      public int getTableSize()
      Gets the size in bytes of this table.
      Returns:
      The size in bytes of this table.
    • getRow

      public CliAbstractTableRow getRow(int rowIndex) throws IndexOutOfBoundsException
      Gets the row at the given index.

      NOTE: Per ISO/IEC 23271:2012(E) III.1.9, Row indices start from 1, while heap/stream indices start from 0.

      Parameters:
      rowIndex - The index of the row to get (starting at 1).
      Returns:
      The row at the given index.
      Throws:
      IndexOutOfBoundsException - if the row index is invalid.
    • markup

      public void markup(Program program, boolean isBinary, TaskMonitor monitor, MessageLog log, NTHeader ntHeader) throws DuplicateNameException, CodeUnitInsertionException, IOException, MemoryAccessException
      Description copied from interface: PeMarkupable
      Marks up a PE structure.
      Specified by:
      markup in interface PeMarkupable
      Parameters:
      program - The program to markup.
      isBinary - True if the program is binary; otherwise, false.
      monitor - The monitor.
      log - The log.
      ntHeader - The PE's NT Header structure.
      Throws:
      DuplicateNameException
      CodeUnitInsertionException
      IOException
      MemoryAccessException
    • getRowDataType

      public abstract DataType getRowDataType()
      Gets the data type of a row in this table.
      Returns:
      The data type of a row in this table.
    • toDataType

      public DataType toDataType()
      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
      See Also:
    • toString

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

      protected int readBlobIndex(BinaryReader reader) throws IOException
      Reads the blob index that the reader is positioned at.
      Parameters:
      reader - A reader that is positioned at the blob index to read.
      Returns:
      The blob index that the reader is positioned at.
      Throws:
      IOException - if there is a problem reading the blob index.
    • readStringIndex

      protected int readStringIndex(BinaryReader reader) throws IOException
      Reads the string index that the reader is positioned at.
      Parameters:
      reader - A reader that is positioned at the string index to read.
      Returns:
      The string index that the reader is positioned at.
      Throws:
      IOException - if there is a problem reading the string index.
    • readGuidIndex

      protected int readGuidIndex(BinaryReader reader) throws IOException
      Reads the GUID index that the reader is positioned at.
      Parameters:
      reader - A reader that is positioned at the GUID index to read.
      Returns:
      The GUID index that the reader is positioned at.
      Throws:
      IOException - if there is a problem reading the GUID index.
    • readTableIndex

      protected int readTableIndex(BinaryReader reader, CliTypeTable table) throws IOException
      Reads the table index that the reader is positioned at.
      Parameters:
      reader - A reader that is positioned at the table index to read.
      Returns:
      The table index that the reader is positioned at.
      Throws:
      IOException - if there is a problem reading the table index.
    • getRowRepresentationSafe

      protected String getRowRepresentationSafe(CliTypeTable table, int index)
      Convenience method for getting the row representation of a table.
      Parameters:
      table - The table that has the row.
      index - The index of the row.
      Returns:
      The row representation of a table.
    • getRowShortRepSafe

      protected String getRowShortRepSafe(CliTypeTable otherTable, int index)
      Convenience method for getting a safe row representation of a table.
      Parameters:
      otherTable - The table that has the row.
      index - The index of the row.
      Returns:
      The safe row representation of a table.