Пример #1
0
        internal static bool TryGetModuleInfo(this DkmClrModuleInstance module, [NotNullWhen(true)] out EnC.DebuggeeModuleInfo?info)
        {
            Debug.Assert(Thread.CurrentThread.GetApartmentState() == ApartmentState.MTA, "SymReader requires MTA");

            IntPtr metadataPtr;
            uint   metadataSize;

            try
            {
                metadataPtr = module.GetBaselineMetaDataBytesPtr(out metadataSize);
            }
            catch (Exception e) when(DkmExceptionUtilities.IsBadOrMissingMetadataException(e))
            {
                info = null;
                return(false);
            }

            var symReader = module.GetSymUnmanagedReader() as ISymUnmanagedReader5;

            if (symReader == null)
            {
                info = null;
                return(false);
            }

            var metadata = ModuleMetadata.CreateFromMetadata(metadataPtr, (int)metadataSize);

            info = new EnC.DebuggeeModuleInfo(metadata, symReader);
            return(true);
        }
        private static ModuleMetadata GetBaselineModuleMetadata(DkmClrModuleInstance module)
        {
            IntPtr metadataPtr;
            uint   metadataSize;

            try
            {
                metadataPtr = module.GetBaselineMetaDataBytesPtr(out metadataSize);
            }
            catch (Exception e) when(DkmExceptionUtilities.IsBadOrMissingMetadataException(e))
            {
                return(null);
            }

            return(ModuleMetadata.CreateFromMetadata(metadataPtr, (int)metadataSize));
        }