private static extern bool MiniDumpWriteDump( IntPtr hProcess, uint processId, SafeHandle hFile, uint dumpType, ref MiniDumpExceptionInformation expParam, IntPtr userStreamParam, IntPtr callbackParam);
public static bool Write(SafeHandle fileHandle, Option options) { var currentProcess = Process.GetCurrentProcess(); var currentProcessHandle = currentProcess.Handle; var currentProcessId = (uint)currentProcess.Id; var exp = new MiniDumpExceptionInformation() { ThreadId = GetCurrentThreadId(), ClientPointers = false, ExceptionPointers = IntPtr.Zero }; return(MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)); }
public static bool dumpSelf(string dumpFile) { IntPtr hProcess = Process.GetCurrentProcess().Handle; uint PID = (uint)Process.GetCurrentProcess().Id; // Create a crash dump, which we will then pass to windbg for analysis. using (FileStream foo = File.OpenWrite(dumpFile)) { MiniDumpExceptionInformation exp = new MiniDumpExceptionInformation(); exp.ThreadId = 0xffffffff; exp.ClientPointers = false; if (!MiniDumpWriteDump(hProcess, PID, foo.SafeFileHandle, Option.WithFullMemory, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)) { throw new Exception("unable to dump - GLE " + Marshal.GetLastWin32Error()); } } return(true); }
static extern bool MiniDumpWriteDump(IntPtr hProcess, uint processId, SafeHandle hFile, uint dumpType, ref MiniDumpExceptionInformation expParam, IntPtr userStreamParam, IntPtr callbackParam);