From 57c44958bfc5b153bcda820589a5c7b7d4c93301 Mon Sep 17 00:00:00 2001 From: Austin Wise Date: Fri, 22 Jul 2016 15:53:09 -0700 Subject: [PATCH] Validate the PDB type. This fixes #723. This duplicates the logic from jbevain/cecil#279 --- ILSpy/LoadedAssembly.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ILSpy/LoadedAssembly.cs b/ILSpy/LoadedAssembly.cs index f9cc50ad1..e83e96b72 100644 --- a/ILSpy/LoadedAssembly.cs +++ b/ILSpy/LoadedAssembly.cs @@ -139,6 +139,20 @@ namespace ICSharpCode.ILSpy 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)) {