DebugDir example

This is an accompanying example for Matching debug information article. It shows how to locate debug information in a PE executable and analyze its contents. Starting with the data directory in the executable's optional header, it proceeds to the debug directory and obtains the list of all kinds of debug information available in the executable. Then it displays detailed information about every debug directory entry and the corresponding data.

Sample output:

C:\DebugDir>debugdir c:\winnt\system32\ntdll.dll

File: c:\winnt\system32\ntdll.dll
Number of entries in debug directory: 1

Debug directory entry 1:
Type: 4 ( MISC )
TimeStamp: 3a1b6894  Characteristics: 0  MajorVer: 0  MinorVer: 0
Size: 272  RVA: 00000000  FileOffset: 00077a00
Data type: 1  Length: 272  Format: ANSI
File: dll\ntdll.dbg

View DebugDir source code (DebugDir.cpp)

Download DebugDir

To build DebugDir, create an empty console project and add DebugDir.cpp to the project.