Example #1
0
        public static int Write(string filepath, MiniDumpType dumpType)
        {
            MiniDumpProvider.MinidumpExceptionInfo structure = new MiniDumpProvider.MinidumpExceptionInfo()
            {
                ThreadId = MiniDumpProvider.GetCurrentThreadId(), ExceptionPointers = Marshal.GetExceptionPointers(), ClientPointers = false
            };
            IntPtr num = Marshal.AllocHGlobal(Marshal.SizeOf <MiniDumpProvider.MinidumpExceptionInfo>(structure));

            try
            {
                using (FileStream fileStream = new FileStream(filepath, FileMode.Create))
                {
                    Process currentProcess = Process.GetCurrentProcess();
                    Marshal.StructureToPtr <MiniDumpProvider.MinidumpExceptionInfo>(structure, num, false);
                    return(MiniDumpProvider.MiniDumpWriteDump(currentProcess.Handle, currentProcess.Id, fileStream.SafeFileHandle.DangerousGetHandle(), dumpType, structure.ClientPointers ? num : IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) ? 0 : Marshal.GetLastWin32Error());
                }
            }
            finally
            {
                Marshal.FreeHGlobal(num);
            }
        }
Example #2
0
 public static int Write(string filepath)
 {
     return(MiniDumpProvider.Write(filepath, MiniDumpType.WithDataSegs | MiniDumpType.WithFullMemory | MiniDumpType.WithHandleData));
 }