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
-
Method Summary
Modifier and TypeMethodDescriptionshort
getFlags()
Returns the flags about this COFF.long
getImageBase
(boolean isWindowsPlatform) Returns the image base.short
Returns the machine name.short
getMagic()
Returns the magic COFF file identifier.Returns the a.out optional header.short
Returns the size in bytes of the optional header.short
Returns 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.int
Returns the number of symbols in the symbol table.int
Returns the file offset to the symbol table.short
Returns the specific target idint
Returns the time stamp of when this file was created.static boolean
isValid
(ByteProvider provider) Tests if the givenByteProvider
is a validCoffFileHeader
.void
parse
(ByteProvider provider, TaskMonitor monitor) Finishes the parsing of this file header.void
parseSectionHeaders
(ByteProvider provider) Read just the section headers, not including line numbers and relocationsint
sizeof()
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 givenByteProvider
is 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 givenByteProvider
to make sure the entire file isn't all 0's.- Parameters:
provider
- TheByteProvider
to 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: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 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:
-