// Internal helper to get the list of modules private MINIDUMP_MODULE_LIST GetModuleList() { EnsureValid(); DumpPointer pStream = GetStream(MINIDUMP_STREAM_TYPE.ModuleListStream); MINIDUMP_MODULE_LIST list = new MINIDUMP_MODULE_LIST(pStream); return(list); }
/// <summary> /// Enumerate all the modules in the dump. /// </summary> /// <returns></returns> public IEnumerable <DumpModule> EnumerateModules() { MINIDUMP_MODULE_LIST list = GetModuleList(); uint num = list.Count; for (uint i = 0; i < num; i++) { MINIDUMP_MODULE module = list.GetElement(i); yield return(new DumpModule(this, module)); } }
/// <summary> /// Return the module containing the target address, or null if no match. /// </summary> /// <param name="targetAddress">address in target</param> /// <returns> /// Null if no match. Else a DumpModule such that the target address is in between the range specified /// by the DumpModule's .BaseAddress and .Size property /// </returns> /// <remarks> /// This can be useful for symbol lookups or for using module images to /// supplement memory read requests for minidumps. /// </remarks> public DumpModule TryLookupModuleByAddress(ulong targetAddress) { // This is an optimized lookup path, which avoids using IEnumerable or creating // unnecessary DumpModule objects. MINIDUMP_MODULE_LIST list = GetModuleList(); uint num = list.Count; for (uint i = 0; i < num; i++) { MINIDUMP_MODULE module = list.GetElement(i); ulong targetStart = module.BaseOfImage; ulong targetEnd = targetStart + module.SizeOfImage; if (targetStart <= targetAddress && targetEnd > targetAddress) { return(new DumpModule(this, module)); } } return(null); }
//todo /* * public NativeContext ExceptionStreamThreadContext() * { * NativeMethods.MINIDUMP_EXCEPTION_STREAM es = GetExceptionStream(); * return GetThreadContext(es.ThreadContext); * } */ /// <summary> /// Lookup the first module in the target with a matching. /// </summary> /// <param name="nameModule">The name can either be a matching full name, or just shortname</param> /// <returns>The first DumpModule that has a matching name. </returns> public DumpModule LookupModule(string nameModule) { MINIDUMP_MODULE_LIST list = GetModuleList(); uint num = list.Count; for (uint i = 0; i < num; i++) { MINIDUMP_MODULE module = list.GetElement(i); RVA rva = module.ModuleNameRva; DumpPointer ptr = TranslateRVA(rva); string name = GetString(ptr); if (nameModule == name || name.EndsWith(nameModule)) { return(new DumpModule(this, module)); } } return(null); }