Exemplo n.º 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);
        }
Exemplo n.º 2
0
        private void AttemptDebug(Process process)
        {
            bool sucess = DbgHlp.DebugActiveProcess(new IntPtr(process.Id));

            if (sucess)
            {
                Attributes["debugger-attached-sucess"] = "True";
            }
            else
            {
                Attributes["debugger-attached-error"] = new Win32Exception(Marshal.GetLastWin32Error()).Message;
            }
        }
Exemplo n.º 3
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);
        }