示例#1
0
        /**//*
         * 自己包装的一个函数
         */
        public static Boolean TryDump(String dmpPath, MiniDumpType dmpType)
        {
            //使用文件流来创健 .dmp文件
            using (FileStream stream = new FileStream(dmpPath, FileMode.Create, FileAccess.ReadWrite))
            {
                //取得进程信息
                Process process = Process.GetCurrentProcess();

                // MINIDUMP_EXCEPTION_INFORMATION 信息的初始化
                MinidumpExceptionInfo mei = new MinidumpExceptionInfo();

                mei.ThreadId          = Thread.CurrentThread.ManagedThreadId;
                mei.ExceptionPointers = Marshal.GetExceptionPointers();
                mei.ClientPointers    = true;

                Boolean res = MiniDumpWriteDump(
                    process.Handle,
                    process.Id,
                    stream.Handle,                //stream.SafeFileHandle.DangerousGetHandle(),
                    dmpType,
                    ref mei,
                    IntPtr.Zero,
                    IntPtr.Zero);

                //清空 stream
                stream.Flush();
                stream.Close();

                return(res);
            }
        }
示例#2
0
            public static Boolean TryDump(String dmpPath, MiniDumpType dmpType)
            {
                //使用文件流来创健 .dmp文件
                using (var stream = new FileStream(dmpPath, FileMode.Create))
                {
                    //取得进程信息
                    var process = Process.GetCurrentProcess();

                    // MINIDUMP_EXCEPTION_INFORMATION 信息的初始化
                    var mei = new MinidumpExceptionInfo();

                    mei.ThreadId          = (UInt32)GetCurrentThreadId();
                    mei.ExceptionPointers = Marshal.GetExceptionPointers();
                    mei.ClientPointers    = 1;

                    //这里调用的Win32 API
                    var fileHandle = stream.SafeFileHandle.DangerousGetHandle();
                    var res        = MiniDumpWriteDump(process.Handle, process.Id, fileHandle, dmpType, ref mei, IntPtr.Zero, IntPtr.Zero);

                    //清空 stream
                    stream.Flush();
                    stream.Close();

                    return(res);
                }
            }
示例#3
0
        public static Boolean TryDump(String dmpPath, MiniDumpType dmpType)
        {
            //Dumpファイルを作成
            using (FileStream stream = new FileStream(dmpPath, FileMode.Create))
            {
                //プロセス情報を取得
                Process process = Process.GetCurrentProcess();

                // MINIDUMP_EXCEPTION_INFORMATION 情報の初期化
                MinidumpExceptionInfo mei = new MinidumpExceptionInfo();

                mei.ThreadId          = Thread.CurrentThread.ManagedThreadId;
                mei.ExceptionPointers = Marshal.GetExceptionPointers();
                mei.ClientPointers    = true;


                //Win32 APIを呼び出し
                Boolean res = MiniDumpWriteDump(
                    process.Handle,
                    process.Id,
                    stream.SafeFileHandle.DangerousGetHandle(),
                    dmpType,
                    ref mei,
                    IntPtr.Zero,
                    IntPtr.Zero);

                //ストリームをクリア
                stream.Flush();
                stream.Close();

                return(res);
            }
        }
示例#4
0
        /*
         * 自己包装的一个函数
         */
        public static Boolean TryDump(String dmpPath, MiniDumpType dmpType)
        {
            var path = Path.Combine(Environment.CurrentDirectory, dmpPath);
            var dir  = Path.GetDirectoryName(path);

            if (dir != null && !Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            //使用文件流来创健 .dmp文件
            using (FileStream stream = new FileStream(path, FileMode.Create))
            {
                //取得进程信息
                Process process = Process.GetCurrentProcess();
                // MINIDUMP_EXCEPTION_INFORMATION 信息的初始化
                MinidumpExceptionInfo mei = new MinidumpExceptionInfo();
                mei.ThreadId          = System.AppDomain.GetCurrentThreadId();//only this can generate full imformation,f**k ms//System.Threading.Thread.CurrentThread.ManagedThreadId;//System.AppDomain.GetCurrentThreadId();//Thread.CurrentThread.ManagedThreadId;
                mei.ExceptionPointers = Marshal.GetExceptionPointers();
                mei.ClientPointers    = true;
                //这里调用的Win32 API
                Boolean res = MiniDumpWriteDump(
                    process.Handle,
                    process.Id,
                    stream.SafeFileHandle.DangerousGetHandle(),
                    dmpType,
                    ref mei,
                    IntPtr.Zero,
                    IntPtr.Zero);

                //清空 stream
                stream.Flush();
                stream.Close();
                return(res);
            }
        }
示例#5
0
 private static extern Boolean MiniDumpWriteDump(
     IntPtr hProcess,
     Int32 processId,
     IntPtr fileHandle,
     MiniDumpType dumpType,
     ref MinidumpExceptionInfo excepInfo,
     IntPtr userInfo,
     IntPtr extInfo);
示例#6
0
            public static Boolean TryDump(String dmpPath, MiniDumpType dmpType)
            {
                //使用文件流来创健 .dmp文件
                using (FileStream stream = new FileStream(dmpPath, FileMode.Create))
                {
                    //取得进程信息
                    Process process = Process.GetCurrentProcess();

                    // MINIDUMP_EXCEPTION_INFORMATION 信息的初始化
                    MinidumpExceptionInfo mei = new MinidumpExceptionInfo();

                    mei.ThreadId = (UInt32)GetCurrentThreadId();
                    mei.ExceptionPointers = Marshal.GetExceptionPointers();
                    mei.ClientPointers = 1;

                    //这里调用的Win32 API
                    Boolean res = MiniDumpWriteDump(
                    process.Handle,
                    process.Id,
                    stream.SafeFileHandle.DangerousGetHandle(),
                    dmpType,
                   ref mei,
                    IntPtr.Zero,
                    IntPtr.Zero);

                    //清空 stream
                    stream.Flush();
                    stream.Close();

                    return res;
                }
            }
示例#7
0
  private static extern Boolean MiniDumpWriteDump(
  IntPtr hProcess,
  Int32 processId,
  IntPtr fileHandle,
  MiniDumpType dumpType,
 ref MinidumpExceptionInfo excepInfo,
  IntPtr userInfo,
  IntPtr extInfo);