Package ghidra.app.util.bin.format.pe

# Class DataDirectory

java.lang.Object
ghidra.app.util.bin.format.pe.DataDirectory

All Implemented Interfaces:
  `PeMarkupable`

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 Object implements PeMarkupable
An abstract base class to represent the `IMAGE_DATA_DIRECTORY` data structure defined in `winnt.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 boolean`
  `hasParsed`
  `static final byte`
  `IMAGE_SIZEOF_IMAGE_DIRECTORY_ENTRY`
  The size of the data directory, in bytes.
  `protected NTHeader`
  `ntHeader`
  `protected BinaryReader`
  `reader`
  `protected int`
  `size`
  `protected static final String`
  `TITLE`
  The name to use when converting into a structure data type.
  `protected int`
  `virtualAddress`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DataDirectory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `createDirectoryBookmark(Program program, Address addr)`
  `protected boolean`
  `createFragment(Program program, String fragmentName, Address start, Address end)`
  Creates a fragment with the given name (if it does not already exist) and moves the address range into the fragment.
  `protected void`
  `createTerminatedString(Program program, Address addr, boolean label, MessageLog log)`
  `abstract String`
  `getDirectoryName()`
  `int`
  `getPointer()`
  `int`
  `getSize()`
  Returns the size of this data directory.
  `int`
  `getVirtualAddress()`
  Returns the relative virtual address of this data directory.
  `boolean`
  `hasParsedCorrectly()`
  `abstract boolean`
  `parse()`
  Parses this data directory.
  `protected void`
  `processDataDirectory(NTHeader nt, BinaryReader rdr)`
  `protected void`
  `setBookmark(Program prog, Address addr, String comment)`
  `protected void`
  `setEolComment(Program prog, Address addr, String comment)`
  `protected void`
  `setPlateComment(Program prog, Address addr, String comment)`
  `protected void`
  `setPreComment(Program prog, Address addr, String comment)`
  `void`
  `setSize(int size)`
  Sets the size of this data directory.
  `void`
  `setVirtualAddress(int addr)`
  Sets the relative virtual address of this data directory.
  `String`
  `toString()`
  `protected long`
  `va(long va, boolean isBinary)`
  `protected boolean`
  `validateSize()`
  `void`
  `writeBytes(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 Details

  - ### TITLE

    protected static final 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 BinaryReader reader

  - ### virtualAddress

    protected int virtualAddress

  - ### size

    protected int size

  - ### hasParsed

    protected boolean hasParsed

- ## Constructor Details

  - ### DataDirectory

    public DataDirectory()

- ## Method Details

  - ### processDataDirectory

    protected void processDataDirectory(NTHeader nt, BinaryReader rdr) throws IOException
    Throws:
      `IOException`

  - ### validateSize

    protected boolean validateSize()

  - ### getDirectoryName

    public abstract String getDirectoryName()

  - ### parse

    public abstract boolean parse() throws IOException
    Parses this data directory.
    Returns:
      True if parsing completed successfully; otherwise, false.
    Throws:
      `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)

  - ### createDirectoryBookmark

    protected void createDirectoryBookmark(Program program, Address addr)

  - ### setBookmark

    protected void setBookmark(Program prog, Address addr, String comment)

  - ### setPlateComment

    protected void setPlateComment(Program prog, Address addr, String comment)

  - ### setEolComment

    protected void setEolComment(Program prog, Address addr, String comment)

  - ### setPreComment

    protected void setPreComment(Program prog, Address addr, String comment)

  - ### createFragment

    protected boolean createFragment(Program program, String fragmentName, Address start, Address end)
    Creates a fragment with the given name (if it does not already exist) and moves the address range into the fragment.

    Note: the end address is not inclusive!

    Parameters:
      `program` - The program
      `fragmentName` - The fragment name
      `start` - The start address
      `end` - The end address
    Returns:
      True on success; otherwise, false

  - ### 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 String toString()
    Overrides:
      `toString` in class `Object`
    See Also:
      - `Object.toString()`

  - ### writeBytes

    public void writeBytes(RandomAccessFile raf, DataConverter dc, PortableExecutable template) throws IOException
    Directories 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 output
      `dc` - the data converter for endianness
      `template` - the original unadulterated PE
    Throws:
      `IOException` - if an I/O error occurs

  - ### hasParsedCorrectly

    public boolean hasParsedCorrectly()

  - ### getPointer

    public int getPointer()