Exemple #1
0
        internal unsafe static ImmutableArray <MetadataBlock> GetMetadataBlocks(this DkmProcess process, DkmClrAppDomain appDomain)
        {
            var builder = ArrayBuilder <MetadataBlock> .GetInstance();

            foreach (DkmClrModuleInstance module in process.GetModulesInAppDomain(appDomain))
            {
                int            size;
                IntPtr         ptr;
                MetadataReader reader;
                if (module.TryGetMetadataReader(out ptr, out size, out reader))
                {
                    var moduleDef       = reader.GetModuleDefinition();
                    var moduleVersionId = reader.GetGuid(moduleDef.Mvid);
                    var generationId    = reader.GetGuid(moduleDef.GenerationId);
                    Debug.Assert(moduleVersionId == module.Mvid);
                    builder.Add(new MetadataBlock(moduleVersionId, generationId, ptr, size));
                }
            }
            return(builder.ToImmutableAndFree());
        }