private ChecksumAlgorithmType ChecksumAlgorithmForFullPdb() { string fileName = Path.GetFileName(this.FileName); string extension = Path.GetExtension(fileName); string pdbPath = this.FileName.Replace(fileName, fileName.Replace(extension, ".pdb")); if (!File.Exists(pdbPath)) { return(ChecksumAlgorithmType.Unknown); } using var pdbStream = new FileStream(pdbPath, FileMode.Open, FileAccess.Read); var metadataProvider = new SymMetadataProvider(this.metadataReader); object importer = SymUnmanagedReaderFactory.CreateSymReaderMetadataImport(metadataProvider); ISymUnmanagedReader3 reader = SymUnmanagedReaderFactory.CreateReaderWithMetadataImport <ISymUnmanagedReader3>(pdbStream, importer, SymUnmanagedReaderCreationOptions.UseComRegistry); try { Guid algorithm = Guid.Empty; foreach (ISymUnmanagedDocument document in reader.GetDocuments()) { document.GetChecksumAlgorithmId(ref algorithm); return(algorithm == sha256guid ? ChecksumAlgorithmType.Sha256 : ChecksumAlgorithmType.Sha1); } } finally { _ = ((ISymUnmanagedDispose)reader).Destroy(); } return(ChecksumAlgorithmType.Unknown); }
private ISymUnmanagedReader GetReaderForFrame(ClrStackFrame frame) { ClrModule module = frame.Method?.Type?.Module; PdbInfo info = module?.Pdb; ISymUnmanagedReader reader = null; string name = string.Empty; if (info != null) { if (_pdbReaders.TryGetValue(info, out reader)) { return(reader); } name = Path.GetFileName(info.FileName); if (!File.Exists(name)) { _logger?.LogTrace("Symbol file {0} missing", name); return(null); } try { Stream stream = File.OpenRead(name); if (IsPortablePdb(stream)) { var bindar = new SymBinder(); int result = bindar.GetReaderFromPdbFile(new MetaDataImportProvider(module.MetadataImport), name, out reader); } else { reader = SymUnmanagedReaderFactory.CreateReaderWithMetadataImport <ISymUnmanagedReader3>(stream, module.MetadataImport, SymUnmanagedReaderCreationOptions.Default); } } catch (Exception e) { _logger?.LogError(e, "Unable to obtain symbol reader for {0}", name); } } if (reader != null) { _logger?.LogTrace("Symbol file {0} found, reader created", name); _pdbReaders.Add(info, reader); } else { _logger?.LogTrace("Unable to obtain symbol reader for {0}", name); } return(reader); }