void ReadModules() { string line; Regex moduleLineRegex = new Regex(@"'(?<path>.*)' (?<baseAddress>0x[0-9|a-f|A-F]*) (?<size>\d*) (?<guid>[0-9|a-f|A-F]*) (?<age>\d*)"); while (!(line = m_logDataStream.ReadLine()).Equals("<\\modules>")) { Match moduleLineMatch = moduleLineRegex.Match(line); string path = moduleLineMatch.Groups["path"].Value; ulong baseAddress = Convert.ToUInt32(moduleLineMatch.Groups["baseAddress"].Value, 16); uint size = Convert.ToUInt32(moduleLineMatch.Groups["size"].Value); Guid guid = new Guid(moduleLineMatch.Groups["guid"].Value); uint age = Convert.ToUInt32(moduleLineMatch.Groups["age"].Value); try { IDiaSession diaSession; DiaSourceClass diaSource = new DiaSourceClass(); diaSource.loadAndValidateDataFromPdb(path, ref guid, 0, age); diaSource.openSession(out diaSession); diaSession.loadAddress = baseAddress; SymbolResolver symbolResolver = new SymbolResolver(diaSession, size); m_symbolResolvers.Add(symbolResolver); Marshal.ReleaseComObject(diaSource); } catch (System.Runtime.InteropServices.COMException ex) { switch ((UInt32)ex.ErrorCode) { // look in dia.h for error codes case 0x806D0005: Console.WriteLine("Couldn't find pdb: " + path); break; case 0x806D0006: Console.WriteLine("Signature invalid for: " + path); break; default: Console.WriteLine("Unknown pdb load error for: " + path + ", errorcode: " + ex.ErrorCode); break; } } } }
void ReadModules() { int nLoadedModules = m_logDataStream.ReadInt32(); //while (!(line = m_logDataStream.ReadLine()).Equals("<\\modules>")) for (int i = 0; i < nLoadedModules; i++) { string path = ReadString(); ulong baseAddress = m_logDataStream.ReadUInt32(); uint size = m_logDataStream.ReadUInt32(); string guidStr = ReadString(); Guid guid = new Guid(guidStr); uint age = m_logDataStream.ReadUInt32(); bool bTryLocal = false; // Try pdb path and local dir do { if (bTryLocal) { path = m_logFilePath + path.Substring(path.LastIndexOf('\\') + 1); } try { IDiaSession diaSession; DiaSourceClass diaSource = new DiaSourceClass(); diaSource.loadAndValidateDataFromPdb(path, ref guid, 0, age); diaSource.openSession(out diaSession); diaSession.loadAddress = baseAddress; SymbolResolver symbolResolver = new SymbolResolver(diaSession, size); m_symbolResolvers.Add(symbolResolver); Marshal.ReleaseComObject(diaSource); bTryLocal = false; } catch (System.Runtime.InteropServices.COMException ex) { switch ((UInt32)ex.ErrorCode) { // look in dia.h for error codes case 0x806D0005: bTryLocal = bTryLocal ? false : true; Console.WriteLine("Couldn't find pdb: " + path); break; case 0x806D0006: bTryLocal = bTryLocal ? false : true; Console.WriteLine("Signature invalid for: " + path); break; default: bTryLocal = bTryLocal ? false : true; Console.WriteLine("Unknown pdb load error for: " + path + ", errorcode: " + ex.ErrorCode); break; } } } while (bTryLocal); } }