コード例 #1
0
        private static bool Write(SafeHandle fileHandle, DumpTypeFlag dumpTypeFlag)
        {
            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;
            exp.ExceptionPointers = Marshal.GetExceptionPointers();

            var bRet = false;

            try
            {
                if (exp.ExceptionPointers == IntPtr.Zero)
                {
                    bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)dumpTypeFlag,
                                             IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
                }
                else
                {
                    bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)dumpTypeFlag,
                                             ref exp, IntPtr.Zero, IntPtr.Zero);
                }
            }
            catch (DllNotFoundException)
            {
                Logger.Warning(
                    "dbghelp.dll was not found inside the application folder, the system path or SDK folder. Minidump was not generated. If you are not planning on using the minidump feature, you can disable it with the Configurator tool.");
                return(false);
            }

            if (!bRet)
            {
                Logger.Error(
                    "Cannot write the minidump. MiniDumpWriteDump (dbghelp.dll) function returned error code: " +
                    Marshal.GetLastWin32Error());
                return(false);
            }
            return(true);
        }
コード例 #2
0
ファイル: DumpWriter.cs プロジェクト: dakahler/alloclave
		private static bool Write(SafeHandle fileHandle, DumpTypeFlag dumpTypeFlag)
		{
			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;
			exp.ExceptionPointers = Marshal.GetExceptionPointers();

			bool bRet = false;

			try
			{
				if (exp.ExceptionPointers == IntPtr.Zero)
				{
					bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)dumpTypeFlag, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
				}
				else
				{
					bRet = MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)dumpTypeFlag, ref exp, IntPtr.Zero, IntPtr.Zero);
				}
			}
			catch (DllNotFoundException)
			{
				Logger.Warning("dbghelp.dll was not found inside the application folder, the system path or SDK folder. Minidump was not generated. If you are not planning on using the minidump feature, you can disable it with the Configurator tool.");
				return false;
			}

			if (!bRet)
			{
				Logger.Error("Cannot write the minidump. MiniDumpWriteDump (dbghelp.dll) function returned error code: " + Marshal.GetLastWin32Error());
				return false;
			}
			else
			{
				return true;
			}
		}