public static extern bool MiniDumpWriteDump( IntPtr hProcess, short ProcessId, IntPtr hFile, MINIDUMP_TYPE DumpType, ref MiniDumpExceptionInformation ExceptionParam, IntPtr UserStreamParam, IntPtr CallbackParam );
public static extern bool MiniDumpWriteDump ( IntPtr hProcess, short ProcessId, IntPtr hFile, MINIDUMP_TYPE DumpType, ref MiniDumpExceptionInformation ExceptionParam, IntPtr UserStreamParam, IntPtr CallbackParam );
private bool CreateDump(Process process, IntPtr exceptionInfo, uint threadId, bool debugger) { bool ret; _strLatestDumpName = "crashdump-" + DateTime.Now.ToFileTimeUtc().ToString() + ".dmp"; using (FileStream file = File.Create(Path.Combine(WorkingDirectory, _strLatestDumpName))) { MiniDumpExceptionInformation info = new MiniDumpExceptionInformation { ClientPointers = true, ExceptionPointers = exceptionInfo, ThreadId = threadId }; const MINIDUMP_TYPE dtype = MINIDUMP_TYPE.MiniDumpWithPrivateReadWriteMemory | MINIDUMP_TYPE.MiniDumpWithDataSegs | MINIDUMP_TYPE.MiniDumpWithHandleData | MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo | MINIDUMP_TYPE.MiniDumpWithThreadInfo | MINIDUMP_TYPE.MiniDumpWithUnloadedModules; bool extraInfo = !(exceptionInfo == IntPtr.Zero || threadId == 0 || !debugger); if (extraInfo) { ret = !NativeMethods.MiniDumpWriteDump(process.Handle, _procId, file.SafeFileHandle?.DangerousGetHandle() ?? IntPtr.Zero, dtype, ref info, IntPtr.Zero, IntPtr.Zero); } else if (NativeMethods.MiniDumpWriteDump(process.Handle, _procId, file.SafeFileHandle?.DangerousGetHandle() ?? IntPtr.Zero, dtype, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)) { ret = false; //Might solve the problem if crashhandler stops working on remote (hah) Attributes["debug-debug-exception-info"] = exceptionInfo.ToString(); Attributes["debug-debug-thread-id"] = threadId.ToString(); } else { ret = true; } file.Flush(); } return(ret); }
private bool CreateDump(Process process, IntPtr exceptionInfo, uint threadId, bool debugger) { bool ret; using (FileStream file = File.Create(Path.Combine(WorkingDirectory, "crashdump.dmp"))) { MiniDumpExceptionInformation info = new MiniDumpExceptionInformation(); info.ClientPointers = true; info.ExceptionPointers = exceptionInfo; info.ThreadId = threadId; MINIDUMP_TYPE dtype = MINIDUMP_TYPE.MiniDumpWithPrivateReadWriteMemory | MINIDUMP_TYPE.MiniDumpWithDataSegs | MINIDUMP_TYPE.MiniDumpWithHandleData | MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo | MINIDUMP_TYPE.MiniDumpWithThreadInfo | MINIDUMP_TYPE.MiniDumpWithUnloadedModules; bool extraInfo = !(exceptionInfo == IntPtr.Zero || threadId == 0 || !debugger); if (extraInfo) { dtype |= 0; ret = !(DbgHlp.MiniDumpWriteDump(process.Handle, procId, file.SafeFileHandle.DangerousGetHandle(), dtype, ref info, IntPtr.Zero, IntPtr.Zero)); } else if (DbgHlp.MiniDumpWriteDump(process.Handle, procId, file.SafeFileHandle.DangerousGetHandle(), dtype, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)) { ret = false; //Might solve the problem if crashhandler stops working on remote (hah) Attributes["debug-debug-exception-info"] = exceptionInfo.ToString(); Attributes["debug-debug-thread-id"] = threadId.ToString(); } else { int errorNo = Marshal.GetLastWin32Error(); ret = true; } file.Flush(); } return(ret); }