internal DiaResolver(string binary, string pathExtension, ILogger logger) { _binary = binary; _logger = logger; string pdb = FindPdbFile(binary, pathExtension); if (pdb == null) { _logger.LogWarning($"Couldn't find the .pdb file of file '{binary}'. You will not get any source locations for your tests."); return; } try { var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); var manifest = IntPtr.Size == 8 ? ManifestFileNameX64 : ManifestFileNameX86; var path = Path.Combine(directory, manifest); _diaDataSource = (IDiaDataSource)NRegFreeCom.ActivationContext.CreateInstanceWithManifest(Dia140Guid, path); } catch (Exception e) { _logger.LogError($"Couldn't load the msdia.dll to parse *.pdb files. You will not get any source locations for your tests.\n{e.Message}"); return; } _logger.DebugInfo($"Parsing pdb file \"{pdb}\""); _fileStream = File.Open(pdb, FileMode.Open, FileAccess.Read, FileShare.Read); _diaDataSource.loadDataFromIStream(new DiaMemoryStream(_fileStream)); _diaDataSource.openSession(out _diaSession); }
private void WindowsNativeLoadPdbUsingDia(string peOrPdbPath, string symbolPath) { IDiaDataSource diaSource = MsdiaComWrapper.GetDiaSource(); Environment.SetEnvironmentVariable("_NT_SYMBOL_PATH", ""); if (symbolPath == null) { string pdbPath = Path.ChangeExtension(peOrPdbPath, ".pdb"); if (File.Exists(pdbPath)) { peOrPdbPath = pdbPath; } } // load the debug info depending on the file type if (peOrPdbPath.EndsWith(".pdb", StringComparison.OrdinalIgnoreCase)) { diaSource.loadDataFromPdb(peOrPdbPath); } else { diaSource.loadDataForExe(peOrPdbPath, symbolPath, IntPtr.Zero); } diaSource.openSession(out _session); }
/// <summary> /// Initializes a new instance of the <see cref="DiaModule"/> class. /// </summary> /// <param name="name">The module name.</param> /// <param name="nameSpace">The default namespace.</param> /// <param name="dia">The DIA data source.</param> /// <param name="session">The DIA session.</param> private DiaModule(string name, string nameSpace, IDiaDataSource dia, IDiaSession session) { this.session = session; this.dia = dia; Name = name; Namespace = nameSpace; }
private bool EnsureInitialized() { if (_isInitialized.HasValue) { return(_isInitialized.Value); } if (_project == null) { _logger.LogWarning("No project information. No source information will be available."); _isInitialized = false; return(_isInitialized.Value); } try { _diaDataSource = (IDiaDataSource) new DiaDataSource(); _isInitialized = true; } catch (Exception ex) { _logger.LogWarning("Failed to create DIA DataSource. No source information will be available.", ex); _isInitialized = false; return(_isInitialized.Value); } // We have a project, and we successfully loaded DIA, so let's capture the symbols // and create a session. try { var context = new CapturingLoadContext(); var assemblyName = new AssemblyName(_project.Name); _project.Load(assemblyName, context); _assembly = Assembly.Load(assemblyName); _diaDataSource.loadDataFromIStream(new StreamWrapper(context.Symbols)); _diaDataSource.openSession(out _diaSession); } catch (Exception ex) { _logger.LogWarning("Failed to load symbols. No source information will be available.", ex); _isInitialized = false; return(_isInitialized.Value); } try { _assemblyData = FetchSymbolData(_diaSession); } catch (Exception ex) { _logger.LogWarning("Failed to read symbols. No source information will be available.", ex); _isInitialized = false; return(_isInitialized.Value); } _isInitialized = true; return(_isInitialized.Value); }
/// <summary> /// Clears the symbol map and creates a new Dia source class. Sets Dia session to null /// </summary> private void Reset() { m_SymbolMap.Clear(); // If the creation of the DiaSourceClass fails, then you likely need // to register the MSDIA1xx.dll on your machine. See readme for more details m_DiaSource = new DiaSourceClass(); m_DiaSession = null; }
public DiaUtil(string pdbName) { Contract.Requires(pdbName != null); diaDataSource = new DiaSource(); diaDataSource.loadDataFromPdb(pdbName); diaDataSource.openSession(out diaSession); }
/// <summary> /// Initializes a new instance of the <see cref="DiaModule"/> class. /// </summary> /// <param name="pdbPath">The PDB path.</param> /// <param name="module">The module.</param> public DiaModule(string pdbPath, Module module) { IDiaSession diaSession; dia = DiaLoader.CreateDiaSource(); dia.loadDataFromPdb(pdbPath); dia.openSession(out diaSession); Initialize(diaSession, module); }
public static IDiaDataSource GetDiaSource() { IntPtr diaSourcePtr = IntPtr.Zero; CoCreateFromMsdia(new Guid(DiaSourceClsid), new Guid(IDiaDataSourceRiid), out diaSourcePtr); object objectForIUnknown = Marshal.GetObjectForIUnknown(diaSourcePtr); IDiaDataSource diaSourceInstance = objectForIUnknown as IDiaDataSource; return(diaSourceInstance); }
/// <summary> /// Opens the module for the specified XML module description. /// </summary> /// <param name="module">The XML module description.</param> public static Module Open(XmlModule module) { IDiaDataSource dia = DiaLoader.CreateDiaSource(); IDiaSession session; string moduleName = !string.IsNullOrEmpty(module.Name) ? module.Name : Path.GetFileNameWithoutExtension(module.SymbolsPath).ToLower(); module.Name = moduleName; dia.loadDataFromPdb(module.SymbolsPath); dia.openSession(out session); return(new DiaModule(module.Name, module.Namespace, dia, session)); }
public void PEBinary_CanCreateIDiaSourceFromMsdia() { if (!PlatformSpecificHelpers.RunningOnWindows()) { return; } Action action = () => { IDiaDataSource source = ProgramDatabase.MsdiaComWrapper.GetDiaSource(); }; action.ShouldNotThrow(); }
private bool TryCreateDiaInstance() { try { _diaDataSource = DiaFactory.CreateInstance(); return(true); } catch (Exception) { return(false); } }
public async Task <IDiaSession> LoadDiaSession(string module) { module = module.ToLowerInvariant(); if (this.activeSessions.ContainsKey(module)) { return(this.activeSessions[module]); } // Try each of the sources until we're able to get one. foreach (IDiaSessionSource source in this.sources) { int attempts = 1; while (attempts <= 3) { if (attempts > 1) { await source.WaitUntilReady(); } ++attempts; try { IDiaDataSource dataSource = this.CreateDataSource(); if (dataSource == null) { // Without a data source we can't use DIA at all. break; } IDiaSession session = source.LoadSessionForModule(dataSource, module); if (session != null) { this.activeSessions[module] = session; return(session); } break; } catch (DebuggerException) { throw; } catch (DiaSourceNotReadyException) { // Try again. continue; } catch { // Try the next source. break; } } } // The session load failed. this.activeSessions[module] = null; return(null); }
private bool TryCreateDiaInstance(Guid clsid) { try { Type comType = Type.GetTypeFromCLSID(clsid); _diaDataSource = (IDiaDataSource)Activator.CreateInstance(comType); return(true); } catch (Exception) { return(false); } }
private bool TryCreateDiaInstance(Guid clsid) { try { Type comType = Type.GetTypeFromCLSID(clsid); _diaDataSource = (IDiaDataSource)Activator.CreateInstance(comType); return true; } catch (Exception) { return false; } }
public IDiaSession LoadSessionForModule(IDiaDataSource source, string moduleName) { try { string imagePath = this.symbolCache.GetModuleImagePath(this.symbolCache.GetModuleBase(moduleName)); source.loadDataForExe(imagePath, this.SymPath, new ModuleReader(this.symbolCache, this.dataSpaces, moduleName)); } catch (InvalidOperationException) { throw new DiaSourceNotReadyException(); } IDiaSession session; source.openSession(out session); return(session); }
/// <summary> /// Searches for different MS DIA versions registered on the system and loads one that was found. /// It should be used instead of creating new <see cref="DiaSource"/> class instance. /// </summary> /// <returns>Instance of <see cref="IDiaDataSource"/>.</returns> public static IDiaDataSource CreateDiaSource() { foreach (var diaGuid in DiaGuids) { IDiaDataSource dia = CreateDiaInstance(diaGuid); if (dia != null) { return(dia); } } return(new DiaSource()); }
public DiaFile(String pdbFile, String dllFile) { m_dsc = GetDiaSourceClass(); string pdbPath = System.IO.Path.GetDirectoryName(pdbFile); // Open the PDB file, validating it matches the supplied DLL file DiaLoadCallback loadCallback = new DiaLoadCallback(); try { m_dsc.loadDataForExe(dllFile, pdbPath, loadCallback); } catch (System.Exception diaEx) { // Provide additional diagnostics context and rethrow string msg = "ERROR from DIA loading PDB for specified DLL"; COMException comEx = diaEx as COMException; if (comEx != null) { if (Enum.IsDefined(typeof(DiaHResults), comEx.ErrorCode)) { // This is a DIA-specific error code, DiaHResults hr = (DiaHResults)comEx.ErrorCode; msg += ": " + hr.ToString(); // Additional clarification for the common case of the DLL not matching the PDB if (hr == DiaHResults.E_PDB_NOT_FOUND) { msg += " - The specified PDB file does not match the specified DLL file"; } } } throw new ApplicationException(msg, diaEx); } // Save the path of the PDB file actually loaded Debug.Assert(loadCallback.LoadedPdbPath != null, "Didn't get PDB load callback"); m_loadedPdbPath = loadCallback.LoadedPdbPath; // Also use DIA to get the debug directory entry in the DLL referring // to the PDB, and save it's timestamp comparison at runtime. m_debugTimestamp = loadCallback.DebugTimeDateStamp; Debug.Assert(m_debugTimestamp != 0, "Didn't find debug directory entry"); m_dsc.openSession(out m_session); m_global = new DiaSymbol(m_session.globalScope); m_publicsEnum = null; }
private bool OpenSession(string filename, string searchPath) { try { // Activate the DIA data source COM object this.source = DiaSourceObject.GetDiaSourceObject(); if (this.source == null) { return(false); } // UWP(App model) scenario if (!Path.IsPathRooted(filename)) { filename = Path.Combine(Directory.GetCurrentDirectory(), filename); if (string.IsNullOrEmpty(searchPath)) { searchPath = Directory.GetCurrentDirectory(); } } // Load the data for the executable int hResult = this.source.LoadDataForExe(filename, searchPath, IntPtr.Zero); if (HResult.Failed(hResult)) { throw new COMException(string.Format(Resources.Resources.FailedToCreateDiaSession, hResult)); } // Open the session and return it if (HResult.Failed(this.source.OpenSession(out this.session))) { return(false); } } catch (COMException) { throw; } finally { if (this.source != null) { Marshal.FinalReleaseComObject(this.source); } } return(true); }
/// <summary> /// Attempt to load the PDB file from the given file location and populate the data table on the left /// </summary> /// <param name="FileName">Absolute file path of the PDB</param> /// <returns>Error message if failure</returns> public string LoadDataFromPdb(string FileName, BackgroundWorker LoadingWorker) { m_SymbolMap.Clear(); Stopwatch watch; if (FileName == null) { return("Empty file path provided! "); } m_DiaSource = new DiaSourceClass(); try { Reset(); watch = System.Diagnostics.Stopwatch.StartNew(); m_DiaSource.loadDataFromPdb(FileName); watch.Stop(); long elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine("Loading data from {0} took {1}ms ({2} sec.)", FileName, elapsedMs, (elapsedMs * 1000)); m_DiaSource.openSession(out m_DiaSession); } catch (System.Runtime.InteropServices.COMException exc) { return(exc.ToString()); } try { IDiaEnumSymbols allSymbols; m_DiaSession.findChildren(m_DiaSession.globalScope, SymTagEnum.SymTagUDT, null, 0, out allSymbols); { watch = System.Diagnostics.Stopwatch.StartNew(); PopulateDataTable(m_table, allSymbols, LoadingWorker); watch.Stop(); long elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine("PopulateDataTable took took {0}ms ({1} sec.)", elapsedMs, (elapsedMs * 1000)); } } catch (System.Exception e) { Console.WriteLine("Error populating data table: " + e.Message); } return(null); }
public Dia2Lib.IDiaSession LoadSessionForModule(IDiaDataSource source, string moduleName) { string symbolPath; try { symbolPath = this.symbolCache.GetModuleSymbolPath(moduleName); } catch (InvalidOperationException) { throw new DiaSourceNotReadyException(); } source.loadDataFromPdb(symbolPath); IDiaSession session; source.openSession(out session); return(session); }
private bool EnsureInitialized() { if (_isInitialized.HasValue) { return(_isInitialized.Value); } try { _diaDataSource = (IDiaDataSource) new DiaDataSource(); _isInitialized = true; } catch (Exception ex) { _logger.LogWarning("Failed to create DIA DataSource. No source information will be available.", ex); _isInitialized = false; return(_isInitialized.Value); } // We have a project, and we successfully loaded DIA, so let's capture the symbols // and create a session. try { _diaDataSource.loadDataFromPdb(_pdbPath); _diaDataSource.openSession(out _diaSession); } catch (Exception ex) { _logger.LogWarning("Failed to load symbols. No source information will be available.", ex); _isInitialized = false; return(_isInitialized.Value); } try { _assemblyData = FetchSymbolData(_diaSession); } catch (Exception ex) { _logger.LogWarning("Failed to read symbols. No source information will be available.", ex); _isInitialized = false; return(_isInitialized.Value); } _isInitialized = true; return(_isInitialized.Value); }
/// <summary> /// Initializes a new instance of the <see cref="DiaModule"/> class. /// </summary> /// <param name="pdbPath">The PDB path.</param> /// <param name="module">The module.</param> public DiaModule(string pdbPath, Module module) { Module = module; dia = new DiaSource(); dia.loadDataFromPdb(pdbPath); dia.openSession(out session); globalScope = session.globalScope; typeAllFields = new DictionaryCache<uint, List<Tuple<string, uint, int>>>(GetTypeAllFields); typeFields = new DictionaryCache<uint, List<Tuple<string, uint, int>>>(GetTypeFields); basicTypes = SimpleCache.Create(() => { var types = new Dictionary<string, IDiaSymbol>(); var basicTypes = globalScope.GetChildren(SymTagEnum.SymTagBaseType); foreach (var type in basicTypes) { try { string typeString = TypeToString.GetTypeString(type); if (!types.ContainsKey(typeString)) { types.Add(typeString, type); } } catch (Exception) { } } return types; }); symbolNamesByAddress = new DictionaryCache<uint, Tuple<string, ulong>>((distance) => { IDiaSymbol symbol; int displacement; string name; session.findSymbolByRVAEx(distance, SymTagEnum.SymTagNull, out symbol, out displacement); symbol.get_undecoratedNameEx(0 | 0x8000 | 0x1000, out name); return Tuple.Create(name, (ulong)displacement); }); session.loadAddress = module.Address; enumTypeNames = new DictionaryCache<uint, Dictionary<ulong, string>>(GetEnumName); }
/// <summary> /// Initializes a new instance of the <see cref="DiaModule"/> class. /// </summary> /// <param name="pdbPath">The PDB path.</param> /// <param name="module">The module.</param> public DiaModule(string pdbPath, Module module) { Module = module; dia = new DiaSource(); dia.loadDataFromPdb(pdbPath); dia.openSession(out session); globalScope = session.globalScope; typeAllFields = new DictionaryCache <uint, List <Tuple <string, uint, int> > >(GetTypeAllFields); typeFields = new DictionaryCache <uint, List <Tuple <string, uint, int> > >(GetTypeFields); basicTypes = SimpleCache.Create(() => { var types = new Dictionary <string, IDiaSymbol>(); var basicTypes = globalScope.GetChildren(SymTagEnum.SymTagBaseType); foreach (var type in basicTypes) { try { string typeString = TypeToString.GetTypeString(type); if (!types.ContainsKey(typeString)) { types.Add(typeString, type); } } catch (Exception) { } } return(types); }); symbolNamesByAddress = new DictionaryCache <uint, Tuple <string, ulong> >((distance) => { IDiaSymbol symbol; int displacement; string name; session.findSymbolByRVAEx(distance, SymTagEnum.SymTagNull, out symbol, out displacement); symbol.get_undecoratedNameEx(0 | 0x8000 | 0x1000, out name); return(Tuple.Create(name, (ulong)displacement)); }); session.loadAddress = module.Address; enumTypeNames = new DictionaryCache <uint, Dictionary <ulong, string> >(GetEnumName); }
public void Test1() { if (!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) { return; } string pdbPath = GetPdbPath(1); IDiaDataSource dia = DiaLoader.CreateDiaSource(); IDiaSession diaSession; dia.loadDataFromPdb(pdbPath); dia.openSession(out diaSession); using (PdbFile pdb = new PdbFile(pdbPath)) { TestUdts(diaSession, pdb); } }
public IDiaSession LoadSessionForModule(IDiaDataSource source, string moduleName) { try { string modulePath, symbolPath; this.runner.GetModuleInfo(moduleName, out modulePath, out symbolPath); if (modulePath == null) { modulePath = moduleName; } source.loadDataForExe(modulePath, this.SymPath, new ModuleReader(this.engine, moduleName)); } catch { throw new DiaSourceNotReadyException(); } IDiaSession session; source.openSession(out session); return(session); }
/// <summary> /// Initializes a new instance of the <see cref="Module"/> class. /// </summary> /// <param name="name">The module name.</param> /// <param name="nameSpace">The default namespace.</param> /// <param name="dia">The DIA data source.</param> /// <param name="session">The DIA session.</param> private Module(string name, string nameSpace, IDiaDataSource dia, IDiaSession session) { this.session = session; this.dia = dia; Name = name; Namespace = nameSpace; GlobalScope = GetSymbol(session.globalScope); PublicSymbols = new HashSet<string>(session.globalScope.GetChildren(SymTagEnum.SymTagPublicSymbol).Select((type) => { if (type.code != 0 || type.function != 0 || (LocationType)type.locationType != LocationType.Static) return string.Empty; string undecoratedName; type.get_undecoratedNameEx(0x1000, out undecoratedName); return undecoratedName ?? type.name; })); }
public IDiaSession LoadSessionForModule(IDiaDataSource source, string moduleName) { string symbolPath = null; try { string modulePath; this.runner.GetModuleInfo(moduleName, out modulePath, out symbolPath); } catch { } if (symbolPath == null) { throw new DiaSourceNotReadyException(); } source.loadDataFromPdb(symbolPath); IDiaSession session; source.openSession(out session); return(session); }
private void WindowsNativeLoadPdbUsingDia(string pePath, string symbolPath, string localSymbolDirectories) { IDiaDataSource diaSource = null; Environment.SetEnvironmentVariable("_NT_SYMBOL_PATH", ""); Environment.SetEnvironmentVariable("_NT_ALT_SYMBOL_PATH", ""); if (!string.IsNullOrEmpty(localSymbolDirectories)) { // If we have one or more local symbol directories, we want // to probe them before any other default load behavior. If // this load code path fails, we fill fallback to these // defaults locations in the second load pass below. this.restrictReferenceAndOriginalPathAccess = true; try { diaSource = MsdiaComWrapper.GetDiaSource(); diaSource.loadDataForExe( pePath, localSymbolDirectories, this.loadTrace != null ? this : (object)IntPtr.Zero); } catch { diaSource = null; } } if (diaSource == null) { this.restrictReferenceAndOriginalPathAccess = false; diaSource = MsdiaComWrapper.GetDiaSource(); diaSource.loadDataForExe( pePath, symbolPath, this.loadTrace != null ? this : (object)IntPtr.Zero); } diaSource.openSession(out this.session); }
/// <summary> /// Initializes a new instance of the <see cref="Module"/> class. /// </summary> /// <param name="name">The module name.</param> /// <param name="nameSpace">The default namespace.</param> /// <param name="dia">The DIA data source.</param> /// <param name="session">The DIA session.</param> private Module(string name, string nameSpace, IDiaDataSource dia, IDiaSession session) { this.session = session; this.dia = dia; Name = name; Namespace = nameSpace; GlobalScope = GetSymbol(session.globalScope); PublicSymbols = new HashSet <string>(session.globalScope.GetChildren(SymTagEnum.SymTagPublicSymbol).Select((type) => { if (type.code != 0 || type.function != 0 || (LocationType)type.locationType != LocationType.Static) { return(string.Empty); } string undecoratedName; type.get_undecoratedNameEx(0x1000, out undecoratedName); return(undecoratedName ?? type.name); })); }
/// <summary> /// Cache symbols from binary path /// </summary> /// <param name="binaryPath"> /// The binary path is assembly path Ex: \path\to\bin\Debug\simpleproject.dll /// </param> /// <param name="searchPath"> /// search path. /// </param> public void CacheSymbols(string binaryPath, string searchPath) { using (var activationContext = new RegistryFreeActivationContext(this.GetManifestFileForRegFreeCom())) { // Activating and Deactivating the context here itself since deactivating context from a different thread would throw an SEH exception. // We do not need the activation context post this point since the DIASession COM object is created here only. try { activationContext.ActivateContext(); this.source = new DiaSource(); this.source.loadDataForExe(binaryPath, searchPath, null); this.source.openSession(out this.session); this.PopulateCacheForTypeAndMethodSymbols(); } catch (COMException) { this.Dispose(); throw; } } }
private IDiaDataSource CreateDataSource() { IDiaDataSource result = null; // First try to load directly. try { string dllName = Path.Combine( Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "msdia140.dll" ); uint hr = DiaSessionLoader.LoadDataSource(dllName, out result); } catch { } // If that fails, try to load it from COM. if (result == null) { try { result = new DiaSource(); } catch { } } return(result); }
public override bool IsMatchingPdb(string pdbPath) { if (m_peFile == null) { m_peFile = new PEFile(new ReadVirtualStream(m_runtime.DataReader, (long)m_imageBase, (long)m_size), true); } string pdbName; Guid pdbGuid; int rev; if (!m_peFile.GetPdbSignature(out pdbName, out pdbGuid, out rev)) { throw new ClrDiagnosticsException("Failed to get PDB signature from module.", ClrDiagnosticsException.HR.DataRequestError); } IDiaDataSource source = DiaLoader.GetDiaSourceObject(); IDiaSession session; source.loadDataFromPdb(pdbPath); source.openSession(out session); return(pdbGuid == session.globalScope.guid); }
private bool EnsureInitialized() { if (_isInitialized.HasValue) { return _isInitialized.Value; } try { _diaDataSource = (IDiaDataSource)new DiaDataSource(); _isInitialized = true; } catch (Exception ex) { _logger.LogWarning("Failed to create DIA DataSource. No source information will be available.", ex); _isInitialized = false; return _isInitialized.Value; } // We have a project, and we successfully loaded DIA, so let's capture the symbols // and create a session. try { _diaDataSource.loadDataFromPdb(_pdbPath); _diaDataSource.openSession(out _diaSession); } catch (Exception ex) { _logger.LogWarning("Failed to load symbols. No source information will be available.", ex); _isInitialized = false; return _isInitialized.Value; } try { _assemblyData = FetchSymbolData(_diaSession); } catch (Exception ex) { _logger.LogWarning("Failed to read symbols. No source information will be available.", ex); _isInitialized = false; return _isInitialized.Value; } _isInitialized = true; return _isInitialized.Value; }
private static extern uint LoadDataSource([MarshalAs(UnmanagedType.LPWStr)] string dllName, out IDiaDataSource result);
private void loadPDBToolStripMenuItem_Click(object sender, EventArgs e) { if (openPdbDialog.ShowDialog() == DialogResult.OK) { m_symbols.Clear(); m_source = new DiaSourceClass(); try { Cursor.Current = Cursors.WaitCursor; m_source.loadDataFromPdb(openPdbDialog.FileName); m_source.openSession(out m_session); Cursor.Current = Cursors.Default; } catch (System.Runtime.InteropServices.COMException exc) { MessageBox.Show(this, exc.ToString()); return; } Cursor.Current = Cursors.WaitCursor; IDiaEnumSymbols allSymbols; m_session.findChildren(m_session.globalScope, SymTagEnum.SymTagUDT, null, 0, out allSymbols); // Temporarily clear the filter so, if current filter is invalid, we don't generate a ton of exceptions while populating the table var preExistingFilter = textBoxFilter.Text; textBoxFilter.Text = ""; { PopulateDataTable(m_table, allSymbols); Cursor.Current = Cursors.Default; // Sort by name by default (ascending) dataGridSymbols.Sort(dataGridSymbols.Columns[0], ListSortDirection.Ascending); bindingSourceSymbols.Filter = null;// "Symbol LIKE '*rde*'"; } // Restore the filter now that the table is populated textBoxFilter.Text = preExistingFilter; ShowSelectedSymbolInfo(); } }
private bool EnsureInitialized() { if (_isInitialized.HasValue) { return _isInitialized.Value; } if (_project == null) { _logger.LogWarning("No project information. No source information will be available."); _isInitialized = false; return _isInitialized.Value; } try { _diaDataSource = (IDiaDataSource)new DiaDataSource(); _isInitialized = true; } catch (Exception ex) { _logger.LogWarning("Failed to create DIA DataSource. No source information will be available.", ex); _isInitialized = false; return _isInitialized.Value; } // We have a project, and we successfully loaded DIA, so let's capture the symbols // and create a session. try { var context = new CapturingLoadContext(); _project.Load(context); _diaDataSource.loadDataFromIStream(new StreamWrapper(context.Symbols)); _diaDataSource.openSession(out _diaSession); } catch (Exception ex) { _logger.LogWarning("Failed to load symbols. No source information will be available.", ex); _isInitialized = false; return _isInitialized.Value; } try { _assemblyData = FetchSymbolData(_diaSession); } catch (Exception ex) { _logger.LogWarning("Failed to read symbols. No source information will be available.", ex); _isInitialized = false; return _isInitialized.Value; } _isInitialized = true; return _isInitialized.Value; }
private void loadPDBToolStripMenuItem_Click(object sender, EventArgs e) { if (openPdbDialog.ShowDialog() == DialogResult.OK) { m_symbols.Clear(); m_source = new DiaSourceClass(); try { m_source.loadDataFromPdb(openPdbDialog.FileName); m_source.openSession(out m_session); } catch (System.Runtime.InteropServices.COMException exc) { MessageBox.Show(this, exc.ToString()); return; } IDiaEnumSymbols allSymbols; m_session.findChildren(m_session.globalScope, SymTagEnum.SymTagUDT, null, 0, out allSymbols); PopulateDataTable(m_table, allSymbols); // Sort by name by default (ascending) dataGridSymbols.Sort(dataGridSymbols.Columns[0], ListSortDirection.Ascending); bindingSourceSymbols.Filter = null;// "Symbol LIKE '*rde*'"; ShowSelectedSymbolInfo(); } }