Package ghidra.app.util.bin.format.pe
Class DataDirectory
- java.lang.Object
-
- ghidra.app.util.bin.format.pe.DataDirectory
-
- All Implemented Interfaces:
PeMarkupable,StructConverter
- Direct Known Subclasses:
ArchitectureDataDirectory,BaseRelocationDataDirectory,BoundImportDataDirectory,CliMetadataDirectory,COMDescriptorDataDirectory,DebugDataDirectory,DefaultDataDirectory,DelayImportDataDirectory,ExceptionDataDirectory,ExportDataDirectory,GlobalPointerDataDirectory,ImportAddressTableDataDirectory,ImportDataDirectory,LoadConfigDataDirectory,ResourceDataDirectory,SecurityDataDirectory,TLSDataDirectory
public abstract class DataDirectory extends java.lang.Object implements StructConverter, PeMarkupable
An abstract base class to represent theIMAGE_DATA_DIRECTORYdata structure defined inwinnt.h.typedef struct _IMAGE_DATA_DIRECTORY { DWORD VirtualAddress; DWORD Size; } IMAGE_DATA_DIRECTORY, *PIMAGE_DATA_DIRECTORY; {
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanhasParsedstatic byteIMAGE_SIZEOF_IMAGE_DIRECTORY_ENTRYThe size of the data directory, in bytes.protected NTHeaderntHeaderprotected FactoryBundledWithBinaryReaderreaderprotected intsizeprotected static java.lang.StringTITLEThe name to use when converting into a structure data type.protected intvirtualAddress
-
Constructor Summary
Constructors Constructor Description DataDirectory()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcreateDirectoryBookmark(Program program, Address addr)protected booleancreateFragment(Program program, java.lang.String fragmentName, Address start, Address end)Creates a fragment with the given name (if it does not already exist).protected voidcreateTerminatedString(Program program, Address addr, boolean label, MessageLog log)abstract java.lang.StringgetDirectoryName()intgetPointer()intgetSize()Returns the size of this data directory.intgetVirtualAddress()Returns the relative virtual address of this data directory.booleanhasParsedCorrectly()abstract booleanparse()Parses this data directory.protected voidprocessDataDirectory(NTHeader ntHeader, FactoryBundledWithBinaryReader reader)protected voidsetBookmark(Program prog, Address addr, java.lang.String comment)protected voidsetEolComment(Program prog, Address addr, java.lang.String comment)protected voidsetPlateComment(Program prog, Address addr, java.lang.String comment)protected voidsetPreComment(Program prog, Address addr, java.lang.String comment)voidsetSize(int size)Sets the size of this data directory.voidsetVirtualAddress(int addr)Sets the relative virtual address of this data directory.abstract DataTypetoDataType()This method should return a datatype representing the data stored in this directory.java.lang.StringtoString()protected longva(long va, boolean isBinary)voidwriteBytes(java.io.RandomAccessFile raf, DataConverter dc, PortableExecutable template)Directories that are not contained inside of sections should override this method to write their bytes into the specified file.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface ghidra.app.util.bin.format.pe.PeMarkupable
markup
-
-
-
-
Field Detail
-
TITLE
protected static final java.lang.String TITLE
The name to use when converting into a structure data type.- See Also:
- Constant Field Values
-
IMAGE_SIZEOF_IMAGE_DIRECTORY_ENTRY
public static final byte IMAGE_SIZEOF_IMAGE_DIRECTORY_ENTRY
The size of the data directory, in bytes.- See Also:
- Constant Field Values
-
ntHeader
protected NTHeader ntHeader
-
reader
protected FactoryBundledWithBinaryReader reader
-
virtualAddress
protected int virtualAddress
-
size
protected int size
-
hasParsed
protected boolean hasParsed
-
-
Method Detail
-
processDataDirectory
protected void processDataDirectory(NTHeader ntHeader, FactoryBundledWithBinaryReader reader) throws java.io.IOException
- Throws:
java.io.IOException
-
getDirectoryName
public abstract java.lang.String getDirectoryName()
-
parse
public abstract boolean parse() throws java.io.IOExceptionParses this data directory.- Returns:
- True if parsing completed successfully; otherwise, false.
- Throws:
java.io.IOException- If there was an IO problem while parsing.
-
va
protected long va(long va, boolean isBinary)
-
createTerminatedString
protected void createTerminatedString(Program program, Address addr, boolean label, MessageLog log)
-
setPlateComment
protected void setPlateComment(Program prog, Address addr, java.lang.String comment)
-
createFragment
protected boolean createFragment(Program program, java.lang.String fragmentName, Address start, Address end)
Creates a fragment with the given name (if it does not already exist). Move the address range into the fragment. Note: the end address is not inclusive!
-
getVirtualAddress
public int getVirtualAddress()
Returns the relative virtual address of this data directory.- Returns:
- the relative virtual address of this data directory
-
setVirtualAddress
public void setVirtualAddress(int addr)
Sets the relative virtual address of this data directory.- Parameters:
addr- the new relative virtual address
-
getSize
public int getSize()
Returns the size of this data directory.- Returns:
- the size of this data directory
-
setSize
public void setSize(int size)
Sets the size of this data directory.- Parameters:
size- the new size of this data directory
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
toDataType
public abstract DataType toDataType() throws DuplicateNameException, java.io.IOException
This method should return a datatype representing the data stored in this directory.- 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 existsjava.io.IOException- See Also:
StructureDataType
-
writeBytes
public void writeBytes(java.io.RandomAccessFile raf, DataConverter dc, PortableExecutable template) throws java.io.IOExceptionDirectories that are not contained inside of sections should override this method to write their bytes into the specified file.- Parameters:
raf- the random access file used for outputdc- the data converter for endiannesstemplate- the original unadulterated PE- Throws:
java.io.IOException- if an I/O error occurs
-
hasParsedCorrectly
public boolean hasParsedCorrectly()
-
getPointer
public int getPointer()
-
-