Package ghidra.app.util.bin.format.coff
Class CoffFileHeader
java.lang.Object
ghidra.app.util.bin.format.coff.CoffFileHeader
- All Implemented Interfaces:
StructConverter
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionshortgetFlags()Returns the flags about this COFF.longgetImageBase(boolean isWindowsPlatform) Returns the image base.shortReturns the machine name.shortgetMagic()Returns the magic COFF file identifier.Returns the a.out optional header.shortReturns the size in bytes of the optional header.shortReturns the number of sections in this COFF file.Returns the sections in this COFF header.getSymbolAtIndex(long index) Returns the symbols in this COFF header.intReturns the number of symbols in the symbol table.intReturns the file offset to the symbol table.shortReturns the specific target idintReturns the time stamp of when this file was created.static booleanisValid(ByteProvider provider) Tests if the givenByteProvideris a validCoffFileHeader.voidparse(ByteProvider provider, TaskMonitor monitor) Finishes the parsing of this file header.voidparseSectionHeaders(ByteProvider provider) Read just the section headers, not including line numbers and relocationsintsizeof()Returns the size (in bytes) of this COFF file header.Returns a structure datatype representing the contents of the implementor of this interface.
-
Constructor Details
-
CoffFileHeader
- Throws:
IOException
-
-
Method Details
-
getMagic
public short getMagic()Returns the magic COFF file identifier.- Returns:
- the magic COFF file identifier
-
getSectionCount
public short getSectionCount()Returns the number of sections in this COFF file.- Returns:
- the number of sections in this COFF file
-
getTimestamp
public int getTimestamp()Returns the time stamp of when this file was created.- Returns:
- the time stamp of when this file was created
-
getSymbolTablePointer
public int getSymbolTablePointer()Returns the file offset to the symbol table.- Returns:
- the file offset to the symbol table
-
getSymbolTableEntries
public int getSymbolTableEntries()Returns the number of symbols in the symbol table.- Returns:
- the number of symbols in the symbol table
-
getOptionalHeaderSize
public short getOptionalHeaderSize()Returns the size in bytes of the optional header. The optional header immediately follows the file header and immediately proceeds the sections headers.- Returns:
- the size in bytes of the optional header
-
getFlags
public short getFlags()Returns the flags about this COFF.- Returns:
- the flags about this COFF
-
getTargetID
Returns the specific target id- Returns:
- the specific target id
- Throws:
CoffException
-
getImageBase
public long getImageBase(boolean isWindowsPlatform) Returns the image base.- Returns:
- the image base
-
getMachineName
Returns the machine name.- Returns:
- the machine name
-
getMachine
public short getMachine() -
parseSectionHeaders
Read just the section headers, not including line numbers and relocations- Parameters:
provider-- Throws:
IOException
-
parse
Finishes the parsing of this file header.- Parameters:
monitor- the task monitor- Throws:
IOException- if an i/o error occurs
-
getSections
Returns the sections in this COFF header.- Returns:
- the sections in this COFF header
-
getSymbols
Returns the symbols in this COFF header.- Returns:
- the symbols in this COFF header
-
getSymbolAtIndex
-
sizeof
public int sizeof()Returns the size (in bytes) of this COFF file header.- Returns:
- the size (in bytes) of this COFF file header
-
getOptionalHeader
Returns the a.out optional header. This return value may be null.- Returns:
- the a.out optional header
-
isValid
Tests if the givenByteProvideris a validCoffFileHeader.To avoid false positives when the machine type is
CoffMachineType.IMAGE_FILE_MACHINE_UNKNOWN, we do an additional check on some extra bytes at the beginning of the givenByteProviderto make sure the entire file isn't all 0's.- Parameters:
provider- TheByteProviderto check- Returns:
- True if this is a is a valid
CoffFileHeader; otherwise, false - Throws:
IOException- if there was an IO-related issue
-
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
- Throws:
DuplicateNameException- when a datatype of the same name already existsIOException- if an IO-related error occurs- See Also:
-