-
Notifications
You must be signed in to change notification settings - Fork 37
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
Support converting embedded Pdbs to XML #235
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use reflection?
The APIs I needed weren't public. Maybe I missed something? Feel free to push directly to the PR branch to fix. |
I'm sorry, I don't quite understand how to use the link you provided to get rid of reflection here. My task is given a |
I see. You can use MetadataReader.MetadataPointer and MetadataReader.Length to read the data. |
I'm sorry again, I'm not well-versed in pointers and unsafe code, so I really don't know how to do this. It would be great if you could just do it yourself when you have time (not urgent). |
I think PEReader should be able to read from an RVA given the position and size, and fill a byte array. Not sure if disk layout/memory layout of the PE format is relevant here. |
var embeddedProvider = reader.ReadEmbeddedPortablePdbDebugDirectoryData(entry); | ||
var memoryBlock = embeddedProvider.GetType().GetMethod("GetMetadataBlock", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(embeddedProvider, null); | ||
var memoryBlockType = memoryBlock.GetType(); | ||
var size = (int)memoryBlockType.GetProperty("Size").GetValue(memoryBlock); | ||
var bytes = (ImmutableArray<byte>)memoryBlockType.GetMethod("GetContentUnchecked").Invoke(memoryBlock, new object[] { 0, size }); | ||
pdbStream = new MemoryStream(bytes.ToArray()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var pdbStream = new UnmanagedMemoryStream(reader.MetadataPointer, reader.MetadataLength, reader.MetadataLength, FileAccess.Read);
No description provided.