/// <summary> /// Constructor /// </summary> /// <param name="path">filename to open dump file</param> public DumpReader(string path) { _file = File.OpenRead(path); long length = _file.Length; // The dump file may be many megabytes large, so we don't want to // read it all at once. Instead, doing a mapping. _fileMapping = CreateFileMapping(_file.SafeFileHandle, IntPtr.Zero, PageProtection.Readonly, 0, 0, null); if (_fileMapping.IsInvalid) { int error = Marshal.GetHRForLastWin32Error(); Marshal.ThrowExceptionForHR(error, new IntPtr(-1)); } _view = MapViewOfFile(_fileMapping, WindowsFunctions.NativeMethods.FILE_MAP_READ, 0, 0, IntPtr.Zero); if (_view.IsInvalid) { int error = Marshal.GetHRForLastWin32Error(); Marshal.ThrowExceptionForHR(error, new IntPtr(-1)); } _base = DumpPointer.DangerousMakeDumpPointer(_view.BaseAddress, (uint)length); // // Cache stuff // DumpPointer pStream; // System info. pStream = GetStream(MINIDUMP_STREAM_TYPE.SystemInfoStream); _info = pStream.PtrToStructure <MINIDUMP_SYSTEM_INFO>(); // Memory64ListStream is present in MinidumpWithFullMemory. if (TryGetStream(MINIDUMP_STREAM_TYPE.Memory64ListStream, out pStream)) { _memoryChunks = new MinidumpMemoryChunks(pStream, MINIDUMP_STREAM_TYPE.Memory64ListStream); } else { // MiniDumpNormal doesn't have a Memory64ListStream, it has a MemoryListStream. pStream = GetStream(MINIDUMP_STREAM_TYPE.MemoryListStream); _memoryChunks = new MinidumpMemoryChunks(pStream, MINIDUMP_STREAM_TYPE.MemoryListStream); } _mappedFileMemory = new LoadedFileMemoryLookups(); IsMinidump = DumpNative.IsMiniDump(_view.BaseAddress); }