예제 #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);
        }
예제 #2
0
        internal static object?GetSymReader(this DkmClrModuleInstance clrModule)
        {
            var module = clrModule.Module; // Null if there are no symbols.

            if (module == null)
            {
                return(null);
            }
            // Use DkmClrModuleInstance.GetSymUnmanagedReader()
            // rather than DkmModule.GetSymbolInterface() since the
            // latter does not handle .NET Native modules.
            return(clrModule.GetSymUnmanagedReader());
        }