Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win32 resources & PDB #53

Closed
picrap opened this issue Dec 19, 2015 · 5 comments
Closed

Win32 resources & PDB #53

picrap opened this issue Dec 19, 2015 · 5 comments

Comments

@picrap
Copy link

picrap commented Dec 19, 2015

Hi,

It seems that modifying the Win32 resources of an assembly corrupts the PDB.
I have an utility that updates the version number after build, including in the Win32 resources blocks, and after this, some other tools using Cecil do not want to load the .PDB file anymore. Also, some methods do not show their local variables anymore in the debugger.
Since I have absolutely no knowledge at all of .PDB format, I am not very useful to fix the problem.

@0xd4d
Copy link
Collaborator

0xd4d commented Dec 31, 2015

Cecil uses an old open sourced PDB reader written by Microsoft, but I don't think it was written by MS' PDB experts, my guess is it was written by an intern. You can debug it and see where it fails. If there are bugs in it, it's not something I'll fix.

Do you have code to reproduce this? Are you sure this only happens if you modify the Win32 resources? AFAICR, the PDB reader doesn't use anything from the Win32 resources.

You can use dnlib to loop over every type and method and print the name of the locals and sequence points (stored in instructions) and compare the output before your update and after it. dnlib has two PDB readers, one using Diagnostics Symbol Store (MS' COM PDB reader) and another managed reader written by Ki. Try both and see if they produce the same result.

@0xd4d
Copy link
Collaborator

0xd4d commented Dec 31, 2015

I should mention that I assume you let dnlib write a new PDB file after you modified the Win32 resources. If you didn't that's the first thing you should try. :)

var opts = new ModuleCreationOptions(ModuleDef.CreateModuleContext());
opts.PdbImplementation = comPdb ? PdbImplType.MicrosoftCOM : PdbImplType.Managed;
opts.TryToLoadPdbFromDisk = true;

@picrap
Copy link
Author

picrap commented Dec 31, 2015

I am totally sure that it is broken when modifying Win32 resources and only with this.
However I did not try both PDB writers (dnlib is rich 😄), I'll check this.
I was asking just in case it was ringing a bell and make you answer something like "Oh yes! I know!"; Since this is not the case, I'll do some research by myself and let you know.

@0xd4d
Copy link
Collaborator

0xd4d commented Dec 31, 2015

There's only one PDB writer, but two readers because the original COM reader has limitations (can only be used in the created thread) so Ki wrote a managed reader that can be used in any thread.

When you modify the Win32 resources, do you also write a new PDB file?

@picrap
Copy link
Author

picrap commented Dec 31, 2015

Yes, I write a new one. However, I don't make any change to it (I assume the magic works).

@0xd4d 0xd4d closed this as completed Jun 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant