Exemple #1
0
        private static bool Write(SafeHandle fileHandle, CrashDump.Options options,
                                  CrashDump.ExceptionInfo exceptionInfo)
        {
            if (!Platform.IsWindows)
            {
                return(false);
            }
            var currentProcess = Process.GetCurrentProcess();
            var handle         = currentProcess.Handle;
            var id             = (uint)currentProcess.Id;

            CrashDump.MiniDumpExceptionInformation expParam;
            expParam.ThreadId          = CrashDump.GetCurrentThreadId();
            expParam.ClientPointers    = false;
            expParam.ExceptionPointers = IntPtr.Zero;
            if (exceptionInfo == CrashDump.ExceptionInfo.Present)
            {
                expParam.ExceptionPointers = Marshal.GetExceptionPointers();
            }
            return(!(expParam.ExceptionPointers == IntPtr.Zero)
                ? CrashDump.MiniDumpWriteDump(handle, id, fileHandle, (uint)options, ref expParam, IntPtr.Zero,
                                              IntPtr.Zero)
                : CrashDump.MiniDumpWriteDump(handle, id, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero,
                                              IntPtr.Zero));
        }
Exemple #2
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var dumpFileName = DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".dmp";

            using (var file = new FileStream(dumpFileName, FileMode.Create))
            {
                var info = new MinidumpExceptionInformation
                {
                    ThreadId          = GetCurrentThreadId(),
                    ExceptionPointers = Marshal.GetExceptionPointers(),
                    ClientPointers    = false
                };

                MiniDumpWriteDump(
                    GetCurrentProcess(),
                    GetCurrentProcessId(),
                    file.SafeFileHandle,
                    MinidumpType.WithFullMemory,
                    ref info,
                    IntPtr.Zero,
                    IntPtr.Zero);
            }

            Process.GetCurrentProcess().Kill();
        }
Exemple #3
0
        public void MiniDumpCallbackOrderTest()
        {
            try
            {
                // Load an exception into the system tables
                throw new InvalidOperationException();
            }
            catch
            {
                // Test for debug exception info
                var memCallbackCalled = false;
                using var hFile = CreateFile("CallbackOrder.dmp", Kernel32.FileAccess.GENERIC_READ | Kernel32.FileAccess.GENERIC_WRITE, 0, default, FileMode.Create, FileFlagsAndAttributes.FILE_ATTRIBUTE_NORMAL);
                if (!hFile.IsInvalid)
                {
                    var mdei = new MINIDUMP_EXCEPTION_INFORMATION
                    {
                        ThreadId          = GetCurrentThreadId(),
                        ExceptionPointers = Marshal.GetExceptionPointers()
                    };

                    var mci = new MINIDUMP_CALLBACK_INFORMATION {
                        CallbackRoutine = MyMiniDumpCallback
                    };

                    Assert.That(MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MINIDUMP_TYPE.MiniDumpNormal, mdei, default, mci), ResultIs.Successful);
Exemple #4
0
        static bool Write(SafeHandle fileHandle, Option options, ExceptionInfo exceptionInfo)
        {
            Process currentProcess       = Process.GetCurrentProcess();
            IntPtr  currentProcessHandle = currentProcess.Handle;
            uint    currentProcessId     = (uint)currentProcess.Id;
            MiniDumpExceptionInformation exp;

            exp.ThreadId          = GetCurrentThreadId();
            exp.ClientPointers    = false;
            exp.ExceptionPointers = IntPtr.Zero;
            if (exceptionInfo == ExceptionInfo.Present)
            {
                exp.ExceptionPointers = Marshal.GetExceptionPointers();
            }
            bool bRet;

            if (exp.ExceptionPointers == IntPtr.Zero)
            {
                bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            }
            else
            {
                bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, ref exp, IntPtr.Zero, IntPtr.Zero);
            }
            return(bRet);
        }
Exemple #5
0
        public static void WriteDump(string fileName, DumpType typeOfdumpType)
        {
            MiniDumpExceptionInformation info;

            info.ThreadId          = NativeMethods.GetCurrentThreadId();
            info.ClientPointers    = false;
            info.ExceptionPointers = Marshal.GetExceptionPointers();

            using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                uint   processId      = (uint)Process.GetCurrentProcess().Id;
                IntPtr processHandle  = NativeMethods.GetCurrentProcess();
                IntPtr processHandle2 = Process.GetCurrentProcess().Handle;
                // Feel free to specify different dump types
                //uint dumpType = (uint) (DumpType.MiniDumpNormal | DumpType.MiniDumpWithDataSegs);
                uint dumpType = (uint)typeOfdumpType;
                NativeMethods.MiniDumpWriteDump(processHandle2,
                                                processId,
                                                fs.SafeFileHandle.DangerousGetHandle(),
                                                dumpType,
                                                ref info,
                                                IntPtr.Zero,
                                                IntPtr.Zero);
            }
        }
Exemple #6
0
        //--------------------------------------------------------------------------------------------------

        public static void Exception(string line, Exception exception, Entity sender = null)
        {
            string msg;

            if (exception is SEHException)
            {
                // Try to get infos from native
                var info = Interop.ExceptionHelper.GetNativeExceptionInfo(Marshal.GetExceptionPointers());
                if (info != null)
                {
                    msg = $"{info.Message} [{info.Source}]";
                }
                else
                {
                    msg = "Unknown native exception.";
                }
            }
            else
            {
                msg = $"{exception.Message} [ {exception.GetType().FullName} ]";
            }

            string expl    = "Exception: " + msg + "\n" + exception.StackTrace;
            var    handler = CoreContext.Current?.MessageHandler;

            handler?.AddMessage(new MessageItem(MessageSeverity.Error, line, expl, sender ?? handler.CurrentReferenceEntity));
        }
        public WatsonExceptionReport(string eventType, Process process, Exception exception, ReportOptions reportOptions) : base(eventType, process)
        {
            this.exception     = exception;
            base.ReportOptions = reportOptions;
            IntPtr exceptionPointers = Marshal.GetExceptionPointers();

            if ((base.ReportOptions & ReportOptions.DoNotLogProcessAndThreadIds) == ReportOptions.None)
            {
                base.LogExtraData("Process ID=" + base.ProcessId);
                if (!base.TargetExternalProcess)
                {
                    base.LogExtraData(string.Concat(new object[]
                    {
                        "Managed Thread ID=",
                        Environment.CurrentManagedThreadId,
                        Environment.NewLine,
                        "Native Thread ID=",
                        DiagnosticsNativeMethods.GetCurrentThreadId()
                    }));
                }
            }
            if (exceptionPointers == IntPtr.Zero)
            {
                this.exceptionInfo = null;
                this.exceptionEIP  = IntPtr.Zero;
                return;
            }
            this.exceptionInfo = new DiagnosticsNativeMethods.WER_EXCEPTION_INFORMATION();
            this.exceptionInfo.exceptionPointers = exceptionPointers;
            this.exceptionInfo.clientPointers    = false;
            this.exceptionEIP = ((DiagnosticsNativeMethods.ExceptionRecord)Marshal.PtrToStructure(((DiagnosticsNativeMethods.ExceptionPointers)Marshal.PtrToStructure(exceptionPointers, typeof(DiagnosticsNativeMethods.ExceptionPointers))).ExceptionRecord, typeof(DiagnosticsNativeMethods.ExceptionRecord))).ExceptionAddress;
        }
Exemple #8
0
        private static bool Write(SafeHandle fileHandle, Options options, ExceptionInfo exceptionInfo)
        {
            if (!Platform.get_IsWindows())
            {
                return(false);
            }
            Process currentProcess = Process.GetCurrentProcess();
            IntPtr  handle         = currentProcess.Handle;
            uint    id             = (uint)currentProcess.Id;
            MiniDumpExceptionInformation expParam = default(MiniDumpExceptionInformation);

            expParam.ThreadId          = GetCurrentThreadId();
            expParam.ClientPointers    = false;
            expParam.ExceptionPointers = IntPtr.Zero;
            if (exceptionInfo == ExceptionInfo.Present)
            {
                expParam.ExceptionPointers = Marshal.GetExceptionPointers();
            }
            bool flag = false;

            if (expParam.ExceptionPointers == IntPtr.Zero)
            {
                return(MiniDumpWriteDump(handle, id, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero));
            }
            return(MiniDumpWriteDump(handle, id, fileHandle, (uint)options, ref expParam, IntPtr.Zero, IntPtr.Zero));
        }
Exemple #9
0
        //--------------------------------------------------------------------------------------------------

        static void _Dump(bool full)
        {
            var fileName   = Path.Combine(_CrashDumpDirectory, $"Macad_{ (full ? "Full" : "Small")}_{DateTime.Now:yyyy-MM-yy_HHmmss}.dmp");
            var fileStream = File.Create(fileName);

            if (fileStream.SafeFileHandle == null)
            {
                return;
            }

            var info = new Win32Api.MINIDUMP_EXCEPTION_INFORMATION
            {
                ClientPointers    = 1,
                ExceptionPointers = Marshal.GetExceptionPointers(),
                ThreadId          = Win32Api.GetCurrentThreadId()
            };

            Win32Api.MiniDumpWriteDump(
                Win32Api.GetCurrentProcess(), Win32Api.GetCurrentProcessId(),
                fileStream.SafeFileHandle.DangerousGetHandle(),
                full ? Win32Api.MINIDUMP_TYPE.MiniDumpWithFullMemory : Win32Api.MINIDUMP_TYPE.MiniDumpNormal,
                ref info, IntPtr.Zero, IntPtr.Zero);

            fileStream.Close();
        }
Exemple #10
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);
            }
        }
Exemple #11
0
        // Token: 0x06000977 RID: 2423 RVA: 0x003B60B8 File Offset: 0x003B42B8
        private static bool Write(SafeHandle fileHandle, CrashDump.Options options, CrashDump.ExceptionInfo exceptionInfo)
        {
            if (!Platform.IsWindows)
            {
                return(false);
            }
            Process expr_0E = Process.GetCurrentProcess();
            IntPtr  handle  = expr_0E.Handle;
            uint    id      = (uint)expr_0E.Id;

            CrashDump.MiniDumpExceptionInformation miniDumpExceptionInformation;
            miniDumpExceptionInformation.ThreadId          = CrashDump.GetCurrentThreadId();
            miniDumpExceptionInformation.ClientPointers    = false;
            miniDumpExceptionInformation.ExceptionPointers = IntPtr.Zero;
            if (exceptionInfo == CrashDump.ExceptionInfo.Present)
            {
                miniDumpExceptionInformation.ExceptionPointers = Marshal.GetExceptionPointers();
            }
            bool result;

            if (miniDumpExceptionInformation.ExceptionPointers == IntPtr.Zero)
            {
                result = CrashDump.MiniDumpWriteDump(handle, id, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            }
            else
            {
                result = CrashDump.MiniDumpWriteDump(handle, id, fileHandle, (uint)options, ref miniDumpExceptionInformation, IntPtr.Zero, IntPtr.Zero);
            }
            return(result);
        }
Exemple #12
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);
                }
            }
        public static void CreateMiniDump(string fileName = null)
        {
            using (var currentProcess = Process.GetCurrentProcess())
            {
                if (String.IsNullOrEmpty(fileName))
                {
                    fileName = String.Format("Crash_Dump_{0}.dmp", currentProcess.ProcessName, DateTime.Now.ToShortDateString());
                }

                var miniInfo = new MiniDumpExceptionInformation();
                miniInfo.ThreadId          = (uint)Thread.CurrentThread.ManagedThreadId;
                miniInfo.ExceptionPointers = Marshal.GetExceptionPointers();
                miniInfo.ClientPointers    = true;

                using (var fs = new FileStream(Path.Combine(Directory.GetCurrentDirectory(), fileName), FileMode.Create))
                {
                    MiniDumpWriteDump(currentProcess.Handle,
                                      (uint)currentProcess.Id,
                                      fs.SafeFileHandle,
                                      (uint)(Option.WithDataSegs | Option.WithFullMemory | Option.WithHandleData),
                                      ref miniInfo,
                                      IntPtr.Zero,
                                      IntPtr.Zero);
                }
            }
        }
Exemple #14
0
        private static void MiniDumpToFile(string fileToDump, MinidumpTypes dumpType)
        {
            using var fsToDump    = File.Open(fileToDump, FileMode.Create, FileAccess.ReadWrite, FileShare.Write);
            using var thisProcess = Process.GetCurrentProcess();
            var mINIDUMP_EXCEPTION_INFORMATION = new MINIDUMP_EXCEPTION_INFORMATION
            {
                ClientPointers = false,
#if WITH_EXCEPTIONPOINTERS
                ExceptionPointers = Marshal.GetExceptionPointers(),
#else
                ExceptionPointers = IntPtr.Zero,
#endif
                ThreadId = SafeNativeMethods.GetCurrentThreadId(),
            };
            var error = SafeNativeMethods.MiniDumpWriteDump(
                thisProcess.Handle,
                thisProcess.Id,
                fsToDump.SafeFileHandle,
                dumpType,
                ref mINIDUMP_EXCEPTION_INFORMATION,
                IntPtr.Zero,
                IntPtr.Zero);

            if (error > 0)
            {
                DumpMessage?.Invoke(typeof(MiniDump), new MessageEventArgs($"Mini-dumping failed with Code: {error}", "Error!", ErrorLevel.Error));
            }
        }
        public void LocatedWire()
        {
            var source = TestData.GetBodyFromBRep(@"SourceData\Brep\ContourLocatedWire.brep");

            Assume.That(source?.GetBRep() != null);

            var template = new SliceContourComponent()
            {
                Owner         = source,
                LayerCount    = 1,
                ReferenceFace = source.Shape.GetSubshapeReference(SubshapeType.Face, 2)
            };

            Assert.IsTrue(template.Make());
            var path = Path.Combine(TestData.TestDataDirectory, Path.Combine(_BasePath, "LocatedWire_TestResult.svg"));

            try
            {
                Assert.IsTrue(template.Export(path, new SvgExchanger()));
            }
            catch (SEHException)
            {
                var info = ExceptionHelper.GetNativeExceptionInfo(Marshal.GetExceptionPointers());
                TestContext.WriteLine(info.Message);
                throw;
            }

            AssertHelper.IsSameTextFile(Path.Combine(_BasePath, "LocatedWire.svg"), path, AssertHelper.TextCompareFlags.IgnoreFloatPrecision);
        }
Exemple #16
0
        /// <summary>
        /// Дамп записывается в файл с уникальным названием (FileName), который будет храниться в той же директории, что и exe файл.
        /// Перед тем как вызвать MiniDumpWriteDump, инициализируем структуру типа MINIDUMP_EXCEPTION_INFORMATION.
        /// </summary>
        private static void CreateMiniDump()
        {
            using (System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess())
            {
                string FileName = string.Format(@"CRASH_DUMP_{0}_{1}.dmp", DateTime.Today.ToShortDateString(), DateTime.Now.Ticks);

                MINIDUMP_EXCEPTION_INFORMATION Mdinfo = new MINIDUMP_EXCEPTION_INFORMATION();

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

                using (FileStream fs = new FileStream(FileName, FileMode.Create))
                {
                    {
                        MiniDumpWriteDump(
                            process.Handle,
                            (uint)process.Id,
                            fs.SafeFileHandle.DangerousGetHandle(),
                            (Int32)MINIDUMP_TYPE.MiniDumpNormal,
                            ref Mdinfo,
                            IntPtr.Zero,
                            IntPtr.Zero);
                    }
                }
            }
        }
Exemple #17
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);
 }
 public void Dispose()
 {
     Console.WriteLine(
         Marshal.GetExceptionPointers() == IntPtr.Zero
             ? "Disposing test normally."
             : "Disposing test because of an exception.");
 }
Exemple #19
0
        public virtual void Dispose()
        {
            if (_isClosed)
            {
                return;
            }

            switch (_closeType)
            {
            case TransactionCloseType.Commit:
                Commit();
                break;

            case TransactionCloseType.Rollback:
                Rollback();
                break;

            case TransactionCloseType.Auto:
                if (Marshal.GetExceptionPointers() != IntPtr.Zero || Marshal.GetExceptionCode() != 0)
                {
                    Rollback();
                }
                else
                {
                    Commit();
                }
                break;

            default:
                Rollback();
                break;
            }
        }
Exemple #20
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);
            }
        }
Exemple #21
0
        private static bool Write(SafeHandle fileHandle, Option options, bool withException = false)
        {
            using (var currentProcess = Process.GetCurrentProcess())
            {
                var currentProcessHandle = currentProcess.Handle;
                var currentProcessId     = (uint)currentProcess.Id;

                MiniDumpExceptionInformation exp;

                exp.ThreadId          = GetCurrentThreadId();
                exp.ClientPointers    = false;
                exp.ExceptionPointers = IntPtr.Zero;

                if (withException)
                {
                    exp.ExceptionPointers = Marshal.GetExceptionPointers();
                }

                var bRet = exp.ExceptionPointers == IntPtr.Zero
                    ? MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)
                    : MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, ref exp, IntPtr.Zero, IntPtr.Zero);

                return(bRet);
            }
        }
Exemple #22
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);
            }
        }
Exemple #23
0
 private static Exception GetCurrentException()
 {
     if (Marshal.GetExceptionPointers() != IntPtr.Zero || Marshal.GetExceptionCode() != 0)
     {
         return(Marshal.GetExceptionForHR(Marshal.GetExceptionCode()));
     }
     return(null);
 }
Exemple #24
0
            public void AddException(Exception ex)
            {
                exceptionPrt = Marshal.GetExceptionPointers();

                pretendfiles.Add("exception.txt", ex.ToString());

                attributes["visible-error-friendly"] = ex.Message;
            }
 public void Dispose()
 {
     if (!disposed && Marshal.GetExceptionPointers() == IntPtr.Zero)
     {
         disposed = true;
         State.Require(Ending);
     }
 }
Exemple #26
0
        public static void Dump()
        {
            IntPtr pEP = Marshal.GetExceptionPointers();

            CreateDump(
                System.Diagnostics.Process.GetCurrentProcess().Id,
                @"E:\" + AppDomain.GetCurrentThreadId() + ".dmp",
                (Int32)MINIDUMP_TYPE.MiniDumpWithFullMemory,
                AppDomain.GetCurrentThreadId(),
                pEP);
        }
Exemple #27
0
        /// <summary>
        /// Will run VerifyAll on all Moq-parameters
        /// </summary>
        public void Dispose()
        {
            var exceptionOccurred = Marshal.GetExceptionPointers() != IntPtr.Zero || Marshal.GetExceptionCode() != 0;

            if (exceptionOccurred)
            {
                return;
            }

            VerifyAllInstances();
        }
Exemple #28
0
        private void GenerateDump()
        {
            var exceptionInfo = new Dumper.ExceptionInfo
            {
                ThreadId          = GetCurrentThreadId(),
                ExceptionPointers = Marshal.GetExceptionPointers(),
                ClientPointers    = false
            };

            Dumper.Create("dump.dmp", exceptionInfo);
        }
        internal static void WriteDump(string path)
        {
            FileStream file = new FileStream(path, FileMode.Create);

            NativeMethods.MINIDUMP_EXCEPTION_INFORMATION info = new NativeMethods.MINIDUMP_EXCEPTION_INFORMATION();
            info.ClientPointers    = 1;
            info.ExceptionPointers = Marshal.GetExceptionPointers();
            info.ThreadId          = NativeMethods.GetCurrentThreadId();

            NativeMethods.MiniDumpWriteDump(NativeMethods.GetCurrentProcess(), NativeMethods.GetCurrentProcessId(),
                                            file.SafeFileHandle, MiniDumpWithFullMemory, ref info, IntPtr.Zero, IntPtr.Zero);
            file.Close();
        }
Exemple #30
0
        public static bool TryDump(String dmpPath, MiniDumpType dmpType)
        {
            mArgs.path             = dmpPath;
            mArgs.type             = dmpType;
            mMei.ThreadId          = GetCurrentThreadId();
            mMei.ExceptionPointers = Marshal.GetExceptionPointers();
            mMei.ClientPointers    = false;
            Thread t = new Thread(new ThreadStart(MakeDump));

            t.Start();
            t.Join();
            return(mDumpError == 0);
        }