Exemplo n.º 1
0
 public static bool TryWriteMiniDump(string dmpFileName, MiniDumpType dmpType)
 {
     try
     {
         using (FileStream stream = new FileStream(dmpFileName, FileMode.OpenOrCreate))
         {
             Process process = Process.GetCurrentProcess();
             MiniDumpExceptionInfo exceptionInfo = new MiniDumpExceptionInfo();
             exceptionInfo.ThreadId          = GetCurrentThreadId();
             exceptionInfo.ExceptionPointers = Marshal.GetExceptionPointers();
             exceptionInfo.ClientPointers    = true;
             if (exceptionInfo.ExceptionPointers == IntPtr.Zero)
             {
                 return(MiniDumpWriteDump(process.Handle, process.Id, stream.SafeFileHandle.DangerousGetHandle(), dmpType, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
             }
             else
             {
                 return(MiniDumpWriteDump(process.Handle, process.Id, stream.SafeFileHandle.DangerousGetHandle(), dmpType, ref exceptionInfo, IntPtr.Zero, IntPtr.Zero));
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     return(true);
 }
Exemplo n.º 2
0
 private static extern bool MiniDumpWriteDump(IntPtr hProcess, int processId, IntPtr fileHandle, MiniDumpType dumpType, ref MiniDumpExceptionInfo excepInfo, IntPtr userInfo, IntPtr extInfo);