예제 #1
0
 internal BfAssembly(BfCache cache, AssemblyDefinition assemblyDef, bool isCoreAssembly, string rootDirectory)
 {
     this.int_0 = cache.method_15();
     this.assemblyDefinition_0 = assemblyDef;
     this.string_1             = assemblyDef.Name.Name;
     this.bool_0   = isCoreAssembly;
     this.string_0 = this.assemblyDefinition_0.Name.Version.ToString();
     try
     {
         PdbFactory pdbFactory = new PdbFactory();
         string     text       = Path.Combine(rootDirectory, this.assemblyDefinition_0.Name.Name + ".dll");
         if (System.IO.File.Exists(text))
         {
             this.isymbolReader_0 = pdbFactory.CreateReader(null, text);
         }
         text = Path.Combine(rootDirectory, this.assemblyDefinition_0.Name.Name + ".exe");
         if (System.IO.File.Exists(text))
         {
             this.isymbolReader_0 = pdbFactory.CreateReader(null, text);
         }
     }
     catch (Exception ex)
     {
         Logger.LogWarning("AssemblyConstructor", "Something went wrong " + ex.ToString());
     }
 }
 public void loadAndMapSymbols(AssemblyDefinition assemblyDefinition, string assemblyPath, bool decompileCodeIfNoPdb, string pathToSaveDecompiledSourceCode)
 {
     try
     {
         if (assemblyPath != null)
         {
             var pdbFile = assemblyPath.Replace(Path.GetExtension(assemblyPath), ".pdb");
             if (File.Exists(pdbFile))
             {
                 string           unit    = assemblyPath;
                 ModuleDefinition modDef  = assemblyDefinition.MainModule;
                 var           pdbFactory = new PdbFactory();
                 ISymbolReader reader     = pdbFactory.CreateReader(modDef, unit);
                 modDef.LoadSymbols(reader);
             }
             else
             {
                 if (decompileCodeIfNoPdb)
                 {
                     new CecilDecompiler().decompile(assemblyDefinition, pathToSaveDecompiledSourceCode);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         PublicDI.log.error("in loadAndMapSymbols: {0]", ex.Message);
     }
 }
예제 #3
0
        public SymbolEngine(string assemblyPath)
        {
            AssemblyDefinition assemblyDef = AssemblyFactory.GetAssembly(assemblyPath);

            m_moduleDef = assemblyDef.MainModule;
            PdbFactory    factory = new PdbFactory();
            ISymbolReader reader  = factory.CreateReader(m_moduleDef, assemblyPath);

            m_moduleDef.LoadSymbols(reader);
        }
예제 #4
0
        public ISymbolReader LoadPdbForModule(ModuleDefinition module)
        {
            using (Tracer t = new Tracer(myType, "LoadPdbForModule"))
            {
                string fileName = module.Assembly.MainModule.Image.FileInformation.FullName;
                t.Info("Module file name: {0}", fileName);
                ISymbolReader reader = null;

                if (!myFile2PdbMap.TryGetValue(fileName, out reader))
                {
                    if (myFailedPdbs.Contains(fileName))
                    {
                        t.Warning("This pdb could not be successfully downloaded");
                        return(reader);
                    }

                    for (int i = 0; i < 2; i++)
                    {
                        try
                        {
                            reader = myPdbFactory.CreateReader(module, fileName);
                            myFile2PdbMap[fileName] = reader;
                            break;
                        }
                        catch (Exception ex)
                        {
                            t.Error(Level.L3, ex, "Pdb did not match or it is not present");

                            string pdbFileName = Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + ".pdb");
                            try
                            {
                                File.Delete(pdbFileName);
                            }
                            catch (Exception delex)
                            {
                                t.Error(Level.L2, delex, "Could not delete pdb {0}", pdbFileName);
                            }

                            // When we have symbol server we try to make us of it for matches.
                            if (String.IsNullOrEmpty(mySymbolServer))
                            {
                                break;
                            }

                            t.Info("Try to download pdb from symbol server {0}", mySymbolServer);
                            bool bDownloaded = myDownLoader.DownloadPdbs(new FileQuery(fileName),
                                                                         mySymbolServer);
                            t.Info("Did download pdb {0} from symbol server with return code: {1}", fileName, bDownloaded);


                            if (bDownloaded == false || i == 1) // second try did not work out as well
                            {
                                myFailedPdbs.Add(fileName);
                                break;
                            }
                        }
                    }
                }

                return(reader);
            }
        }