Search code examples
c#.netembedded-resource.net-assembly

Embedded Resource location within the assembly


How can we discover the location of an embedded resource within a .Net assembly? By "location", I mean the beginning and ending byte positions in the assembly. Is there any tool or some sample code to achieve this?

Thanks in advance.


Solution

  • What your looking for is a PE File reader/parser. The complete specification is located on msdn: http://msdn.microsoft.com/en-us/windows/hardware/gg463119

    Managed Resources:

    This parser looks pretty close to what you are after: http://www.codeproject.com/KB/dotnet/asmex.aspx

    And there are several other PE file readers, this one also looks promising however does not specifically call out managed resources. You might also look at Kris Stanton's Exploring pe file headers using managed code.

    Win32 Resources:

    Win32 resources are much easier. Many of the same PE readers will offset into the file to locate the resources. Once there, there is a well defined set of structures that define the layout of the resources. MSDN has defined these, and others have written about it. A few google searches should get you there.