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 java.lang.Object implements StructConverter, PeMarkupable
Generic Metadata table. Subclasses should provided implementations for the actual tables.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.Integer>blobsprotected CliStreamMetadatametadataStreamprotected intnumRowsstatic java.lang.StringPATHprotected longreaderOffsetprotected java.util.ArrayList<CliAbstractTableRow>rowsprotected java.util.List<java.lang.Integer>stringsprotected CliTypeTabletableTypeprotected java.util.List<java.lang.Integer>userStrings
-
Constructor Summary
Constructors Constructor Description CliAbstractTable(BinaryReader reader, CliStreamMetadata metadataStream, CliTypeTable tableType)Creates a new generic CLI metadata table.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description intgetNumRows()Gets the number of rows in this table.CliAbstractTableRowgetRow(int rowIndex)Gets the row at the given index.abstract DataTypegetRowDataType()Gets the data type of a row in this table.protected java.lang.StringgetRowRepresentationSafe(CliTypeTable table, int index)Convenience method for getting the row representation of a table.protected java.lang.StringgetRowShortRepSafe(CliTypeTable otherTable, int index)Convenience method for getting a safe row representation of a table.intgetRowSize()Gets the size in bytes of a row in this table.intgetTableSize()Gets the size in bytes of this table.CliTypeTablegetTableType()Gets this table's table type.voidmarkup(Program program, boolean isBinary, TaskMonitor monitor, MessageLog log, NTHeader ntHeader)Marks up a PE structure.protected intreadBlobIndex(BinaryReader reader)Reads the blob index that the reader is positioned at.protected intreadGuidIndex(BinaryReader reader)Reads the GUID index that the reader is positioned at.protected intreadStringIndex(BinaryReader reader)Reads the string index that the reader is positioned at.protected intreadTableIndex(BinaryReader reader, CliTypeTable table)Reads the table index that the reader is positioned at.DataTypetoDataType()Returns a structure datatype representing the contents of the implementor of this interface.java.lang.StringtoString()
-
-
-
Field Detail
-
PATH
public static final java.lang.String PATH
- See Also:
- Constant Field Values
-
readerOffset
protected long readerOffset
-
tableType
protected CliTypeTable tableType
-
numRows
protected int numRows
-
rows
protected java.util.ArrayList<CliAbstractTableRow> rows
-
metadataStream
protected CliStreamMetadata metadataStream
-
strings
protected java.util.List<java.lang.Integer> strings
-
blobs
protected java.util.List<java.lang.Integer> blobs
-
userStrings
protected java.util.List<java.lang.Integer> userStrings
-
-
Constructor Detail
-
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 Detail
-
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 java.lang.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:
java.lang.IndexOutOfBoundsException- if the row index is invalid.
-
markup
public void markup(Program program, boolean isBinary, TaskMonitor monitor, MessageLog log, NTHeader ntHeader) throws DuplicateNameException, CodeUnitInsertionException, java.io.IOException, MemoryAccessException
Description copied from interface:PeMarkupableMarks up a PE structure.- Specified by:
markupin interfacePeMarkupable- 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:
DuplicateNameExceptionCodeUnitInsertionExceptionjava.io.IOExceptionMemoryAccessException
-
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:StructConverterReturns 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:
toDataTypein interfaceStructConverter- Returns:
- returns a structure datatype representing the implementor of this interface
- See Also:
StructureDataType
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
readBlobIndex
protected int readBlobIndex(BinaryReader reader) throws java.io.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:
java.io.IOException- if there is a problem reading the blob index.
-
readStringIndex
protected int readStringIndex(BinaryReader reader) throws java.io.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:
java.io.IOException- if there is a problem reading the string index.
-
readGuidIndex
protected int readGuidIndex(BinaryReader reader) throws java.io.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:
java.io.IOException- if there is a problem reading the GUID index.
-
readTableIndex
protected int readTableIndex(BinaryReader reader, CliTypeTable table) throws java.io.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:
java.io.IOException- if there is a problem reading the table index.
-
getRowRepresentationSafe
protected java.lang.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 java.lang.String getRowShortRepSafe(CliTypeTable otherTable, int index)
Convenience method for getting a safe row representation of a table.- Parameters:
table- The table that has the row.index- The index of the row.- Returns:
- The safe row representation of a table.
-
-