private static void ReadSymbols(ModuleDefinition module, ReaderParameters parameters) { ISymbolReaderProvider symbolReaderProvider = parameters.SymbolReaderProvider; if (symbolReaderProvider == null && parameters.ReadSymbols) { symbolReaderProvider = new DefaultSymbolReaderProvider(); } if (symbolReaderProvider != null) { module.SymbolReaderProvider = symbolReaderProvider; ISymbolReader symbolReader = (parameters.SymbolStream != null) ? symbolReaderProvider.GetSymbolReader(module, parameters.SymbolStream) : symbolReaderProvider.GetSymbolReader(module, module.FileName); if (symbolReader != null) { module.ReadSymbols(symbolReader, parameters.ThrowIfSymbolsAreNotMatching); } } if (module.Image.HasDebugTables()) { module.ReadSymbols(new PortablePdbReader(module.Image, module)); } }
private static void ReadSymbols(ModuleDefinition module, ReaderParameters parameters) { ISymbolReaderProvider symbolReaderProvider = parameters.SymbolReaderProvider; if (symbolReaderProvider == null && parameters.ReadSymbols) { symbolReaderProvider = SymbolProvider.GetPlatformReaderProvider(); } if (symbolReaderProvider != null) { module.SymbolReaderProvider = symbolReaderProvider; module.ReadSymbols((parameters.SymbolStream != null ? symbolReaderProvider.GetSymbolReader(module, parameters.SymbolStream) : symbolReaderProvider.GetSymbolReader(module, module.FullyQualifiedName))); } }
private void Add (ModuleDefinition module) { try { module.ReadSymbols(); } catch (FileNotFoundException) { } catch (InvalidOperationException) { } foreach (var resource in from res in module.Resources where res.ResourceType == ResourceType.Embedded select res as EmbeddedResource) { AddResource (resource); } modules.Add (module); LocateLocalizationMethods (module); }
public void LoadModule(System.IO.Stream dllStream, System.IO.Stream pdbStream) { this.module = Mono.Cecil.ModuleDefinition.ReadModule(dllStream); if (pdbStream != null) { var debugInfoLoader = new Mono.Cecil.Pdb.PdbReaderProvider(); module.ReadSymbols(debugInfoLoader.GetSymbolReader(module, pdbStream)); } if (module.HasAssemblyReferences) { foreach (var ar in module.AssemblyReferences) { if (moduleref.Contains(ar.Name) == false) { moduleref.Add(ar.Name); } if (moduleref.Contains(ar.FullName) == false) { moduleref.Add(ar.FullName); } } } //mapModule[module.Name] = module; if (module.HasTypes) { foreach (var t in module.Types) { if (t.FullName.Contains(".My."))//vb skip the system class { continue; } mapType[t.FullName] = new ILType(this, t, logger); if (t.HasNestedTypes) { foreach (var nt in t.NestedTypes) { mapType[nt.FullName] = new ILType(this, nt, logger); } } } } }
private void LoadSymbols(ModuleDefinition module) { // search for pdb in same directory as dll string pdbName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".pdb"); if (File.Exists(pdbName)) { using (Stream s = File.OpenRead(pdbName)) { module.ReadSymbols(new Mono.Cecil.Pdb.PdbReaderProvider().GetSymbolReader(module, s)); } return; } // TODO: use symbol cache, get symbols from microsoft }
private static void Analysis(XmlTextWriter writer, ModuleDefinition module, string fullPath, bool withTypes) { try { module.ReadSymbols(); var provider = new PdbReaderProvider(); var reader = provider.GetSymbolReader(module, fullPath); } catch (FileNotFoundException fex) { // we don't want to fail on a missing pdb. // though we may place a breakpoint below. var debugException = fex; } Console.WriteLine("Parsing {0}", module.Name); writer.WriteStartElement("Assembly"); writer.WriteAttributeString("name", module.Assembly.Name.Name); writer.WriteAttributeString("version", module.Assembly.Name.Version.ToString()); writer.WriteStartElement("References"); foreach (var item in module.AssemblyReferences) { writer.WriteStartElement("Reference"); writer.WriteAttributeString("name", item.Name); writer.WriteAttributeString("fullName", item.FullName); writer.WriteAttributeString("version", item.Version.ToString()); writer.WriteEndElement(); if (!parsedAssemblies.Contains(item.FullName) && !assembliesToParse.Contains(item.FullName)) { assembliesToParse.Add(item.FullName); } } writer.WriteEndElement(); if (withTypes) { writer.WriteStartElement("TypeReferences"); foreach (var t in module.Types) { ParseType(writer, t); } writer.WriteEndElement(); } writer.WriteEndElement(); if (assembliesToParse.Contains(module.Assembly.Name.FullName)) { assembliesToParse.Remove(module.Assembly.Name.FullName); } parsedAssemblies.Add(module.Assembly.Name.FullName); }
static void Analysis(XmlTextWriter writer, ModuleDefinition module, string fullPath, bool withTypes) { try { module.ReadSymbols(); var provider = new PdbReaderProvider(); var reader = provider.GetSymbolReader(module, fullPath); } catch (FileNotFoundException) { } Console.WriteLine("Parsing {0}", module.Name); writer.WriteStartElement("Assembly"); writer.WriteAttributeString("name", module.Assembly.Name.Name); writer.WriteAttributeString("version", module.Assembly.Name.Version.ToString()); writer.WriteStartElement("References"); foreach (var item in module.AssemblyReferences) { writer.WriteStartElement("Reference"); writer.WriteAttributeString("name", item.Name); writer.WriteAttributeString("fullName", item.FullName); writer.WriteAttributeString("version", item.Version.ToString()); writer.WriteEndElement(); if (!Parsed.Contains(item.FullName) && !ToParse.Contains(item.FullName)) { ToParse.Add(item.FullName); } } writer.WriteEndElement(); if (withTypes) { writer.WriteStartElement("TypeReferences"); foreach (var t in module.Types) { ParseType(writer, t); } writer.WriteEndElement(); if (designAnalysis) { GenerateTypeDesignMeasures(writer, module); } } writer.WriteEndElement(); if (ToParse.Contains(module.Assembly.Name.FullName)) { ToParse.Remove(module.Assembly.Name.FullName); } Parsed.Add(module.Assembly.Name.FullName); }
private void LoadSymbols(ModuleDefinition module) { if (!module.HasDebugHeader) { return; } byte[] headerBytes; var debugHeader = module.GetDebugHeader(out headerBytes); if (debugHeader.Type != 2) { // the debug type is not IMAGE_DEBUG_TYPE_CODEVIEW return; } if (debugHeader.MajorVersion != 0 || debugHeader.MinorVersion != 0) { // the PDB type is not compatible with PdbReaderProvider. It is probably a Portable PDB return; } // search for pdb in same directory as dll string pdbName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".pdb"); if (File.Exists(pdbName)) { using (Stream s = File.OpenRead(pdbName)) { module.ReadSymbols(new Mono.Cecil.Pdb.PdbReaderProvider().GetSymbolReader(module, s)); } return; } // TODO: use symbol cache, get symbols from microsoft }