Class NTHeader
java.lang.Object
ghidra.app.util.bin.format.pe.NTHeader
- All Implemented Interfaces:
OffsetValidator, StructConverter
A class to represent the IMAGE_NT_HEADERS32 and IMAGE_NT_HEADERS64 structures as defined in
winnt.h
typedef struct _IMAGE_NT_HEADERS {
DWORD Signature;
IMAGE_FILE_HEADER FileHeader;
IMAGE_OPTIONAL_HEADER32 OptionalHeader;
};
-
Field Summary
FieldsChangeModifier and TypeFieldDescriptionstatic final intstatic final intThe size of the NT header signature. -
Constructor Summary
ConstructorsChangeConstructorDescriptionNTHeader(BinaryReader reader, int index, PortableExecutable.SectionLayout layout, boolean parseCliHeaders) Constructs a new NT header -
Method Summary
ChangeModifier and TypeMethodDescriptionbooleancheckPointer(long ptr) Returns whether or not the specified pointer is contained within the PE file.booleancheckRVA(long rva) Returns whether or not the specified RVA value is contained within the PE image.intReturns the PE's file alignment, or 0 if unknown/unused.Returns the file header.getName()Returns the name to use when converting into a structure data type.Returns the optional header.intReturns the PE's sectionAlignment, or 0 if unknown/unused.booleanintrvaToPointer(int rva) Returns the given relative virtual address (RVA) converted into a pointer into the binary image, or -1 if not valid.longrvaToPointer(long rva) Returns the given relative virtual address (RVA) converted into a pointer into the binary image, or -1 if not valid.Returns a structure datatype representing the contents of the implementor of this interface.intvaToPointer(int va) Returns the given virtual address (VA) converted into a pointer into the binary image, or -1 if not valid.longvaToPointer(long va) Returns the given virtual address (VA) converted into a pointer into the binary image, or -1 if not valid.
-
Field Details
-
SIZEOF_SIGNATURE
public static final int SIZEOF_SIGNATUREThe size of the NT header signature.- See Also:
-
MAX_SANE_COUNT
public static final int MAX_SANE_COUNT- See Also:
-
-
Constructor Details
-
NTHeader
public NTHeader(BinaryReader reader, int index, PortableExecutable.SectionLayout layout, boolean parseCliHeaders) throws InvalidNTHeaderException, IOException Constructs a new NT header- Parameters:
reader- the binary readerindex- the index into the reader to the start of the NT headerlayout- ThePortableExecutable.SectionLayoutparseCliHeaders- if true, CLI headers are parsed (if present)- Throws:
InvalidNTHeaderException- if the bytes the specified indexIOException- if an IO-related exception occurred
-
-
Method Details
-
getName
Returns the name to use when converting into a structure data type.- Returns:
- the name to use when converting into a structure data type
-
isRVAResoltionSectionAligned
public boolean isRVAResoltionSectionAligned() -
getFileHeader
-
getOptionalHeader
-
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:
-
rvaToPointer
public int rvaToPointer(int rva) Returns the given relative virtual address (RVA) converted into a pointer into the binary image, or -1 if not valid.- Parameters:
rva- the relative virtual address- Returns:
- the given relative virtual address (RVA) converted into a pointer into the binary image, or -1 if not valid
-
rvaToPointer
public long rvaToPointer(long rva) Returns the given relative virtual address (RVA) converted into a pointer into the binary image, or -1 if not valid.- Parameters:
rva- the relative virtual address- Returns:
- the given relative virtual address (RVA) converted into a pointer into the binary image, or -1 if not valid
-
checkPointer
public boolean checkPointer(long ptr) Description copied from interface:OffsetValidatorReturns whether or not the specified pointer is contained within the PE file.- Specified by:
checkPointerin interfaceOffsetValidator- Parameters:
ptr- the pointer value to check- Returns:
- whether or not the specified pointer is contained within the PE file
-
checkRVA
public boolean checkRVA(long rva) Description copied from interface:OffsetValidatorReturns whether or not the specified RVA value is contained within the PE image.- Specified by:
checkRVAin interfaceOffsetValidator- Parameters:
rva- the RVA to check- Returns:
- whether or not the specified RVA value is contained within the PE image
-
getSectionAlignment NEW
public int getSectionAlignment()Description copied from interface:OffsetValidatorReturns the PE's sectionAlignment, or 0 if unknown/unused.- Specified by:
getSectionAlignmentin interfaceOffsetValidator- Returns:
- the PE's sectionAlignment, or 0 if unknown/unused
-
getFileAlignment NEW
public int getFileAlignment()Description copied from interface:OffsetValidatorReturns the PE's file alignment, or 0 if unknown/unused.- Specified by:
getFileAlignmentin interfaceOffsetValidator- Returns:
- the PE's file alignment, or 0 if unknown/unused
-
vaToPointer
public int vaToPointer(int va) Returns the given virtual address (VA) converted into a pointer into the binary image, or -1 if not valid.- Parameters:
va- the virtual address- Returns:
- the given virtual address (VA) converted into a pointer into the binary image, or -1 if not valid
-
vaToPointer
public long vaToPointer(long va) Returns the given virtual address (VA) converted into a pointer into the binary image, or -1 if not valid.- Parameters:
va- the virtual address- Returns:
- the given virtual address (VA) converted into a pointer into the binary image, or -1 if not valid
-