Пример #1
0
        private bool CreateDump(Process process)
        {
            bool ret;

            using (FileStream file = File.Create(Path.Combine(WorkingDirectory, "crashdump.dmp")))
            {
                if (DbgHlp.MiniDumpWriteDump(process.Handle, procId, file.SafeFileHandle.DangerousGetHandle(),
                                             MINIDUMP_TYPE.MiniDumpWithPrivateReadWriteMemory |
                                             MINIDUMP_TYPE.MiniDumpWithDataSegs |
                                             MINIDUMP_TYPE.MiniDumpWithHandleData |
                                             MINIDUMP_TYPE.MiniDumpWithFullMemoryInfo |
                                             MINIDUMP_TYPE.MiniDumpWithThreadInfo |
                                             MINIDUMP_TYPE.MiniDumpWithUnloadedModules, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero))
                {
                    ret = false;
                }
                else
                {
                    int errorNo = Marshal.GetLastWin32Error();
                    ret = true;
                }

                file.Flush();
            }

            return(ret);
        }
Пример #2
0
        private bool CreateDump(Process process, IntPtr exceptionInfo, uint threadId, bool debugger)
        {
            bool ret = false;

            _strLatestDumpName = "crashdump-" + DateTime.Now.ToFileTimeUtc().ToString() + ".dmp";
            using (FileStream file = File.Create(Path.Combine(WorkingDirectory, _strLatestDumpName)))
            {
                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);
        }