Platform SDK: Debugging and Error Handling

ImageDirectoryEntryToDataEx

The ImageDirectoryEntryToDataEx function locates a directory entry within the image header and returns the address of the data for the directory entry. This function returns the section header for the data located, if one exists.

PVOID ImageDirectoryEntryToDataEx(
  PVOID Base,
  BOOLEAN MappedAsImage,
  USHORT DirectoryEntry,
  PULONG Size,
  PIMAGE_SECTION_HEADER *FoundHeader
);

Parameters

Base
[in] Specifies the base address of the image or data file.
MappedAsImage
[in] Specifies how the file is mapped. If the flag is TRUE, the file is mapped by the system as an image. If this flag is FALSE, the file is mapped as a data file by the MapViewOfFile function.
DirectoryEntry
[in] Specifies the directory entry to locate. The value must be one of the following values.
Value Meaning
IMAGE_DIRECTORY_ENTRY_EXPORT Export directory
IMAGE_DIRECTORY_ENTRY_IMPORT Import directory
IMAGE_DIRECTORY_ENTRY_RESOURCE Resource directory
IMAGE_DIRECTORY_ENTRY_EXCEPTION Exception directory
IMAGE_DIRECTORY_ENTRY_SECURITY Security directory
IMAGE_DIRECTORY_ENTRY_BASERELOC Base relocation table
IMAGE_DIRECTORY_ENTRY_DEBUG Debug directory
IMAGE_DIRECTORY_ENTRY_ARCHITECTURE Architecture-specific data
IMAGE_DIRECTORY_ENTRY_GLOBALPTR Relative virtual address of global pointer
IMAGE_DIRECTORY_ENTRY_TLS Thread local storage directory
IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG Load configuration directory
IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT Bound import directory
IMAGE_DIRECTORY_ENTRY_IAT Import address table
IMAGE_DIRECTORY_ENTRY_DELAY_IMPORT Delay load import descriptors
IMAGE_DIRECTORY_ENTRY_COM_DESCRIPTOR COM run-time descriptor

Size
[out] Receives the size of the data for the directory entry that is located.
FoundHeader
[out] Receives the IMAGE_SECTION_HEADER structure for the data. If the section header does not exist, this parameter is NULL.

Return Value

If the function succeeds, the return value is a pointer to the data for the directory entry.

If the function fails, the return value is NULL. To retrieve extended error information, call GetLastError.

Requirements

  Windows NT/2000: Requires Windows 2000. Available as a redistributable for Windows NT 4.0.
  Windows 95/98: Requires Available as a redistributable for Windows 98.
  Header: Declared in Dbghelp.h.
  Library: Use Dbghelp.lib.

See Also

Debug Help Library Overview, DbgHelp Functions, IMAGE_SECTION_HEADER, MapViewOfFile