public static bool MiniDumpReadDumpStream(IntPtr pBase, MINIDUMP_STREAM_TYPE type, out IntPtr streamPointer, out uint cbStreamSize) { MINIDUMP_HEADER header = (MINIDUMP_HEADER)Marshal.PtrToStructure(pBase, typeof(MINIDUMP_HEADER)); streamPointer = IntPtr.Zero; cbStreamSize = 0; // todo: throw dump format exception here: if (header.Singature != MINIDUMP_SIGNATURE || (header.Version & 0xffff) != MINIDUMP_VERSION) { return(false); } int sizeOfDirectory = Marshal.SizeOf(typeof(MINIDUMP_DIRECTORY)); long dirs = pBase.ToInt64() + (int)header.StreamDirectoryRva; for (int i = 0; i < (int)header.NumberOfStreams; ++i) { MINIDUMP_DIRECTORY dir = (MINIDUMP_DIRECTORY)Marshal.PtrToStructure(new IntPtr(dirs + i * sizeOfDirectory), typeof(MINIDUMP_DIRECTORY)); if (dir.StreamType != type) { continue; } streamPointer = new IntPtr(pBase.ToInt64() + (int)dir.Rva); cbStreamSize = dir.DataSize; return(true); } return(false); }
public static bool IsMiniDump(IntPtr pbase) { MINIDUMP_HEADER header = (MINIDUMP_HEADER)Marshal.PtrToStructure(pbase, typeof(MINIDUMP_HEADER)); return((header.Flags & MiniDumpWithFullMemoryInfo) == 0); }