20

I'm attempting to use JetBrains dotPeek 1.4 symbol server however I've encountered some 3rd party assemblies that fail, with dotPeek status of:

Pdb has not been generated because assembly does not contain debug directory

Using CFF Explorer I've discovered that these assemblies have empty "Debug Directory" Portable Executable (PE) header values.

Is there an (easy) way to edit the PE to add Debug Directory header values?

Jason Morse
  • 6,204
  • 5
  • 29
  • 29

1 Answers1

6

de4dot creates invalid .net executable module in the eyes of dotPeek. It's problem of dotPeek, not de4dot, however. But since we do not have sources of dotPeek we ought to modify de4dot instead to achieve interoperability. Modify: de4dot.code/AssemblyModule.cs module adding

writerOptions.WritePdb = true;
module.CreatePdbState();

to de4dot.code.AssemblyModule.Save function and you fill have valid pdb function in exe module.

To save your time you can use de4dot project with my patch: https://github.com/earnol/de4dot/commit/24c6e696fb9251f7d048ac33c88c710013a649d6 It will add debug directory to the output executable. Just delete resulting PDB and run dotPeek again. It will work flawlessly. Use something like: de4dot.exe -f filein.exe -o fileout.exe -fpdb

  • 1
    I applied @ainz-ooal-gown's modification to the latest de4dot version and compiled a binary release for download: https://github.com/djkrose/de4dot/releases/tag/v3.1.41592-fpdb – djk Aug 01 '17 at 22:14
  • I wrote a [simple script](https://gist.github.com/akeeton/84ee158e15727080c2d4508af4943ce2) for myself that should be useful to others, too. Drop it in the same directory as a modified `de4dot.dll`, such as @Hannobo's, and run. – Andrew Keeton Dec 26 '19 at 20:50
  • I also made a [somewhat newer fork of de4dot](https://github.com/akeeton/de4dot/tree/djkrose.master) with @Hannobo's changes. If I remember correctly, there was merge conflict I needed to fix, so this may be useful to someone else. – Andrew Keeton Dec 26 '19 at 20:57