/// <summary>Find a .exe, .dbg or other standard file.</summary> /// <param name="exeFilename">Name of searched file</param> /// <param name="datestamp"></param> /// <param name="size"></param> /// <returns></returns> internal string FindExeFile(string exeFilename, uint datestamp, uint size) { return(FindFile(delegate(IntPtr nativePathBuffer) { return DbgHelp.SymFindFileInPath(base.handle, null, exeFilename, new IntPtr(datestamp), size, 0, 2, nativePathBuffer, null, IntPtr.Zero); })); }
internal string FindPdbFile(string pdbFilename, Guid id, uint age) { return(FindFile(delegate(IntPtr nativePathBuffer) { return DbgHelp.SymFindFileInPath(base.handle, null, pdbFilename, id, age, 0, 8, nativePathBuffer, null, IntPtr.Zero); })); }
/// <summary> /// Looks through the configured symbol paths to find a PDB symbol /// file matching specified name, GUID and age parameters. /// </summary> /// <param name="pdbFileName"></param> /// <param name="guid"></param> /// <param name="age"></param> /// <returns></returns> /// <remarks> /// Note how we don't have to have a module loaded to find its PDB, /// we just look for a PDB file using name, GUID and age. These are /// the parameters that can be extracted from module's PE header, /// in the Debug Directory section. /// </remarks> public string FindPdbFile(string pdbFileName, Guid guid, int age) { DbgHelp.SymSetOptions(DbgHelp.SYMOPT_DEBUG); var hProcess = new IntPtr(1); #if TARGET_NET_20 var searchPath = string.Join(";", this.SymbolPaths.ToArray()); #else var searchPath = string.Join(";", this.SymbolPaths); #endif DbgHelp.SymInitialize(hProcess, searchPath, false); var filePath = new StringBuilder(256); var guidHandle = GCHandle.Alloc(guid, GCHandleType.Pinned); try { if (!DbgHelp.SymFindFileInPath(hProcess, null, pdbFileName, guidHandle.AddrOfPinnedObject(), (uint)age, 0, DbgHelp.SSRVOPT_GUIDPTR, filePath, null, IntPtr.Zero)) { return(null); } } finally { guidHandle.Free(); DbgHelp.SymCleanup(hProcess); } return(filePath.ToString()); }