Remove IMAGE_DEBUG_DIRECTORY from .rdata section

Viewed 2789

How can I remove IMAGE_DEBUG_DIRECTORY data from .rdata section of PE?

I am using MS Visual Studio 2015. I did check almost all compile options of project properties. But IMAGE_DEBUG_DIRECTORY data still exists in my output executable file...

2 Answers

As of Visual Studio 2022 version 17.3 this workaround no longer works because it produces corrupt executable (IMAGE_RESOURCE_DIRECTORY entry is invalid and neither Windows Explorer nor resource manipulation tools can find the .rsrc section even though it is still present in the file).

The workaround is to use the CFF Exlporer from the Explorer Suite. Despite claiming it's version III, it is actually version VIII, only the standalone CFF Explorer is older than the one bundled in the Suite.

Once you have installed the suite, removing the IMAGE_DEBUG_DIRECTORY is really easy.

  • Right-click the executable, select Open with CFF Explorer from the context menu

    CFF Explorer

  • Click on Data Directories in the left pane

  • Right-click on Debug Directory RVA, and select Remove Debug Directory

  • Click File then Save As... and save under a new name

Important: Make sure you thoroughly test the new executable before replacing the original.

Related