/// <summary> /// Returns true if the given address space is a minidump. /// </summary> /// <param name="addressSpace">The address space to check.</param> /// <param name="position">The position of the minidump.</param> /// <returns>True if the address space is a minidump, false otherwise.</returns> public static bool IsValidMinidump(IAddressSpace addressSpace, ulong position = 0) { Reader headerReader = new Reader(addressSpace); MinidumpHeader header = headerReader.Read <MinidumpHeader>(position); return(header.IsSignatureValid.Check()); }
/// <summary> /// Constructor. This constructor will throw exceptions if the file is not a minidump or contains corrupted data /// which interferes with parsing it. /// </summary> /// <param name="addressSpace">The memory which backs this object.</param> /// <param name="position">The offset within addressSpace this minidump is located at.</param> public Minidump(IAddressSpace addressSpace, ulong position = 0) { _dataSource = addressSpace; _position = position; Reader headerReader = new Reader(_dataSource); _header = headerReader.Read <MinidumpHeader>(_position); _header.IsSignatureValid.CheckThrowing(); int systemIndex = -1; _directory = new MinidumpDirectory[_header.NumberOfStreams]; ulong streamPos = _position + _header.StreamDirectoryRva; for (int i = 0; i < _directory.Length; i++) { _directory[i] = headerReader.Read <MinidumpDirectory>(ref streamPos); var streamType = _directory[i].StreamType; if (streamType == MinidumpStreamType.SystemInfoStream) { Debug.Assert(systemIndex == -1); systemIndex = i; } else if (streamType == MinidumpStreamType.ModuleListStream) { Debug.Assert(_moduleListStream == -1); _moduleListStream = i; } } if (systemIndex == -1) { throw new BadInputFormatException("Minidump does not contain a MINIDUMP_SYSTEM_INFO stream"); } _systemInfo = headerReader.Read <MinidumpSystemInfo>(_position + _directory[systemIndex].Rva); _dataSourceReader = new Reader(_dataSource, new LayoutManager().AddCrashDumpTypes(false, Is64Bit)); _loadedImages = new Lazy <List <MinidumpLoadedImage> >(CreateLoadedImageList); _memoryRanges = new Lazy <List <MinidumpSegment> >(CreateSegmentList); _virtualAddressReader = new Lazy <Reader>(CreateVirtualAddressReader); }