FamilyMan

Thanks in advance to anyone who can help.

Here's what's happening:
When I start debugging a process and capture the LoadModule callback or the LoadAssembly callback I'm then trying to get the IMetaDataAssemblyImport for that associated module/assembly. I've had great success using the ICorDebugModule.GetMetaDataInterface function to return an IMetaDataAssemblyImport interface, however, from the documentation it states that the GetMetaDataInterface function "makes a copy of the original metadata for a module".

Here's what my concern is:
It may sound like I'm being picky, but I would prefer to get at the assembly metadata without have to "make a copy" of it. This is because of architecture decisions I've made to get the data "on demand" which could result in several calls to the assembly meta data. After each "on demand" request I would like to release the reference to the IMetaDataAssemblyImport so that I don't have to worry about disposing of it later. I'm concerned that for performance/overhead reasons that to get a "copy" for each one of these calls would be wasteful.

Here's what I would like to do:
So I've tried to use the IMetaDataDispenser.OpenScopeOnMemory to get the IMetaDataAssemblyImport. My understanding is that OpenScopeOnMemory doesn't make any copies and reads the meta data already in memory. However, I don't know how to find the base address and size of the assembly loaded into memory, which is required to use the OpenScopeOnMemory function.

Here's my questions:
Am I going about this the wrong way
Am I correct that using OpenScopeOnMemory would not create a copy of the assembly meta data whereas GetMetaDataInterface does
How do I get the base address and the size of the assembly in memory


Thanks,
Jacob
www.jacobslusser.com


Re: Building Development and Diagnostic Tools for .Net IMetaDataAssemblyImport using OpenScopeOnMemory

Mike Stall - MSFT

I think you should keep it simple and just call ICDModule::GetMetaDataInterface().

I think this is a classic case of premature optimization. You're about to make your design significantly more complicated for a potential performance gain. However, ICorDebug already holds a copy of the metadata, so ICDModule::GetMetaDataInterface() is actually cheap. The docs are misleading: in essence, the copy is made whether you call that API or not.






Re: Building Development and Diagnostic Tools for .Net IMetaDataAssemblyImport using OpenScopeOnMemory

FamilyMan

Thanks, that was exactly what I needed to know.


Jacob
www.jacobslusser.com