Exemplo n.º 1
0
        PEFile LoadAssembly(object state)
        {
            MetadataReaderOptions options;

            if (DecompilerSettingsPanel.CurrentDecompilerSettings.ApplyWindowsRuntimeProjections)
            {
                options = MetadataReaderOptions.ApplyWindowsRuntimeProjections;
            }
            else
            {
                options = MetadataReaderOptions.None;
            }

            PEFile module;

            // runs on background thread
            if (state is Stream stream)
            {
                // Read the module from a precrafted stream
                var streamOptions = stream is MemoryStream ? PEStreamOptions.PrefetchEntireImage : PEStreamOptions.Default;
                module = new PEFile(fileName, stream, streamOptions, metadataOptions: options);
            }
            else
            {
                // Read the module from disk (by default)
                stream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
                module = new PEFile(fileName, stream, PEStreamOptions.PrefetchEntireImage,
                                    metadataOptions: options);
            }

            if (DecompilerSettingsPanel.CurrentDecompilerSettings.UseDebugSymbols)
            {
                try
                {
                    debugInfoProvider = DebugInfoUtils.FromFile(module, PdbFileOverride)
                                        ?? DebugInfoUtils.LoadSymbols(module);
                }
                catch (IOException)
                {
                }
                catch (UnauthorizedAccessException)
                {
                }
                catch (InvalidOperationException)
                {
                    // ignore any errors during symbol loading
                }
            }
            lock (loadedAssemblies)
            {
                loadedAssemblies.Add(module, this);
            }
            return(module);
        }
Exemplo n.º 2
0
 IDebugInfoProvider?LoadDebugInfo(PEFile module)
 {
     if (useDebugSymbols)
     {
         try
         {
             return((PdbFileName != null ? DebugInfoUtils.FromFile(module, PdbFileName) : null)
                    ?? DebugInfoUtils.LoadSymbols(module));
         }
         catch (IOException)
         {
         }
         catch (UnauthorizedAccessException)
         {
         }
         catch (InvalidOperationException)
         {
             // ignore any errors during symbol loading
         }
     }
     return(null);
 }
Exemplo n.º 3
0
 IDebugInfoProvider?LoadDebugInfo(PEFile module)
 {
     if (DecompilerSettingsPanel.CurrentDecompilerSettings.UseDebugSymbols)
     {
         try
         {
             return(DebugInfoUtils.FromFile(module, PdbFileName)
                    ?? DebugInfoUtils.LoadSymbols(module));
         }
         catch (IOException)
         {
         }
         catch (UnauthorizedAccessException)
         {
         }
         catch (InvalidOperationException)
         {
             // ignore any errors during symbol loading
         }
     }
     return(null);
 }
Exemplo n.º 4
0
        LoadResult LoadAssembly(Stream stream, PEStreamOptions streamOptions)
        {
            MetadataReaderOptions options;

            if (DecompilerSettingsPanel.CurrentDecompilerSettings.ApplyWindowsRuntimeProjections)
            {
                options = MetadataReaderOptions.ApplyWindowsRuntimeProjections;
            }
            else
            {
                options = MetadataReaderOptions.None;
            }

            PEFile module = new PEFile(fileName, stream, streamOptions, metadataOptions: options);

            if (DecompilerSettingsPanel.CurrentDecompilerSettings.UseDebugSymbols)
            {
                try
                {
                    debugInfoProvider = DebugInfoUtils.FromFile(module, PdbFileOverride)
                                        ?? DebugInfoUtils.LoadSymbols(module);
                }
                catch (IOException)
                {
                }
                catch (UnauthorizedAccessException)
                {
                }
                catch (InvalidOperationException)
                {
                    // ignore any errors during symbol loading
                }
            }
            lock (loadedAssemblies)
            {
                loadedAssemblies.Add(module, this);
            }
            return(new LoadResult(module));
        }