Groups | Blog | Home
all groups > dotnet clr > october 2004 >

dotnet clr : Managed PE manipulation ( Managed Assembly load procedure )


Nadav
10/3/2004 8:47:02 AM
Hi All,

- I am working on a tool that manipulate managed assemblies, some of the
functionality provided by the tool require manipulating the metadata sections
of the managed assembly in a way it could still be loaded by the consuming
application ( concerning the manipulated assembly is a DLL ), The tool uses
the unmanaged profiling API to monitor the application being executed ( and
actively effect it ), for each assembly being loaded an AssemblyLoadStarted &
AssemblyLoadFinished are being called. for the manipulated assembly none of
these events is called, an 'Object reference is set to null' exception is
being thrown when trying to instantiate one of the classes defined in the
manipulated assembly... I wonder what parameters are extracted from a managed
assembly by the .NET framework during the loading process ( and NOT through
class instantiation and method calls of that assembly ), In other words: what
is the process that take place from the point where the assembly file is
being opened ( e.g. CreateFileW ) to the point where the profiler
AssemblyLoadFinished callback is being called? what parts of metadata of the
assembly being loaded is being used by the .NET Framework? What metadata
properties are required so the assembly would load successfully ( e.g.
NameSpace, PublicKey, version, … )? My guess is that I am manipulating some
variables that prevent the assembly from being loaded, the metadata
manipulation involve merging large chunks of metadata from other assemblies
so it is hard to pinpoint what exactly causes this phenomenon…
- SOooo, any pointers samples or explanations of the metadata properties
required during managed assembly load ( the process that take place from
assembly file creation until AssemblyLoadFinished execution ) would be
appreciated.

--
Nadav
Nadav
10/3/2004 9:51:03 AM
Lets say that I am replacing the metadata of the DLL with some other
meaningful metadata, on runtime ( through AssemblyLoadFinished ) I
reconstruct the original metadata, apparently, some of the metadata is
required before AssemblyLoadFinished & AssemblyLoadStarted are called, my
question is what exactly is this metadata ( namespace, publickey, ... ) ?


[quoted text, click to view]
Kaushik Srenevasan
10/3/2004 10:02:15 PM
Can you tell us what you are trying to manipulate on the managed PE?

--
Kaushik Srenevasan
Microsoft Student Ambassador,
Manager, Madurai .NET student user group
http://groups.msn.com/MaduraiDotNet

[quoted text, click to view]

Brian Tyler
10/4/2004 8:56:15 AM
I am not entirely sure I follow what you are trying to do, but one thing to
remember - An assembly is a logical concept and technically has no meta
data. It is the module that contains the meta data and one or more modules
make up an assembly.

If you are using the profiling API, you need to focus your efforts on the
ModuleAttachedToAssembly() callback and use the IMetaDataXXX interfaces. I
would also recommend searching this group via Google for the words
profiler/corprofiler/etc. to see the various discussions that have taken
place. There are a lot of examples listed as well as some gotchas to be
aware of. If you have a specific question after that, let us know.

Brian

[quoted text, click to view]

AddThis Social Bookmark Button