Example #1
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);
        }
Example #2
0
        public static void Create()
        {
            DateTime localTime = DateTime.Now.ToLocalTime();

            string[] str = new string[] { "TerrariaServer", Main.versionNumber, " ", localTime.Year.ToString("D4"), "-", localTime.Month.ToString("D2"), "-", localTime.Day.ToString("D2"), " ", localTime.Hour.ToString("D2"), "_", localTime.Minute.ToString("D2"), "_", localTime.Second.ToString("D2"), ".dmp" };
            CrashDump.Create(string.Concat(str));
        }
Example #3
0
 public static void Inititialize()
 {
     Console.WriteLine("Error Logging Enabled.");
     AppDomain.CurrentDomain.FirstChanceException += delegate(object sender, FirstChanceExceptionEventArgs exceptionArgs)
     {
         if (LogAllExceptions && 0 == 0)
         {
             string text2 = exceptionArgs.Exception.ToString();
             Console.Write("================\r\n" + $"{DateTime.Now}: First-Chance Exception\r\nThread: {Thread.CurrentThread.ManagedThreadId} [{Thread.CurrentThread.Name}]\r\nCulture: {Thread.CurrentThread.CurrentCulture.Name}\r\nException: {text2}\r\n" + "================\r\n\r\n");
         }
         if (DumpOnException)
         {
             CrashDump.WriteException(CrashDump.Options.WithIndirectlyReferencedMemory, DumpPath);
         }
     };
     AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs exceptionArgs)
     {
         string text = exceptionArgs.ExceptionObject.ToString();
         Console.Write("================\r\n" + $"{DateTime.Now}: Unhandled Exception\r\nThread: {Thread.CurrentThread.ManagedThreadId} [{Thread.CurrentThread.Name}]\r\nCulture: {Thread.CurrentThread.CurrentCulture.Name}\r\nException: {text}\r\n" + "================\r\n");
         if (DumpOnCrash)
         {
             CrashDump.WriteException(CrashDumpOptions, DumpPath);
         }
     };
 }
Example #4
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));
        }
Example #5
0
        public static void Create(string path)
        {
            bool flag = Program.LaunchParameters.ContainsKey("-fulldump");

            using (FileStream fileStream = File.Create(path))
            {
                Process currentProcess = Process.GetCurrentProcess();
                CrashDump.MiniDumpWriteDump(currentProcess.Handle, currentProcess.Id, fileStream.SafeFileHandle.DangerousGetHandle(), flag ? CrashDump.MINIDUMP_TYPE.MiniDumpWithFullMemory : CrashDump.MINIDUMP_TYPE.MiniDumpWithIndirectlyReferencedMemory, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            }
        }
Example #6
0
        public static void CreateFull()
        {
            DateTime localTime = DateTime.Now.ToLocalTime();

            using (FileStream fileStream = File.Create("DMP-FULL Terraria " + Main.versionNumber + " " + localTime.Year.ToString("D4") + "-" + localTime.Month.ToString("D2") + "-" + localTime.Day.ToString("D2") + " " + localTime.Hour.ToString("D2") + "_" + localTime.Minute.ToString("D2") + "_" + localTime.Second.ToString("D2") + ".dmp"))
            {
                Process currentProcess = Process.GetCurrentProcess();
                CrashDump.MiniDumpWriteDump(currentProcess.Handle, currentProcess.Id, fileStream.SafeFileHandle.DangerousGetHandle(), CrashDump.MINIDUMP_TYPE.MiniDumpWithFullMemory, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
            }
        }
Example #7
0
        private static bool Write(CrashDump.Options options, CrashDump.ExceptionInfo exceptionInfo, string outputDirectory)
        {
            if (!Platform.get_IsWindows())
            {
                return(false);
            }
            string path = Path.Combine(outputDirectory, CrashDump.CreateDumpName());

            if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }
            using (FileStream fileStream = File.Create(path))
                return(CrashDump.Write((SafeHandle)fileStream.SafeFileHandle, options, exceptionInfo));
        }
Example #8
0
        // Token: 0x06000976 RID: 2422 RVA: 0x003B6054 File Offset: 0x003B4254
        private static bool Write(CrashDump.Options options, CrashDump.ExceptionInfo exceptionInfo, string outputDirectory)
        {
            if (!Platform.IsWindows)
            {
                return(false);
            }
            string arg_23_0 = Path.Combine(outputDirectory, CrashDump.CreateDumpName());

            if (!Directory.Exists(outputDirectory))
            {
                Directory.CreateDirectory(outputDirectory);
            }
            bool result;

            using (FileStream fileStream = File.Create(arg_23_0))
            {
                result = CrashDump.Write(fileStream.SafeFileHandle, options, exceptionInfo);
            }
            return(result);
        }
Example #9
0
 public static void Inititialize()
 {
     Console.WriteLine("Error Logging Enabled.");
     AppDomain.CurrentDomain.FirstChanceException += (EventHandler <FirstChanceExceptionEventArgs>)((sender, exceptionArgs) =>
     {
         if (!CrashWatcher.LogAllExceptions)
         {
             return;
         }
         Console.Write("================\r\n" + string.Format("{0}: First-Chance Exception\r\nThread: {1} [{2}]\r\nCulture: {3}\r\nException: {4}\r\n", (object)DateTime.Now, (object)Thread.CurrentThread.ManagedThreadId, (object)Thread.CurrentThread.Name, (object)Thread.CurrentThread.CurrentCulture.Name, (object)exceptionArgs.Exception.ToString()) + "================\r\n\r\n");
     });
     AppDomain.CurrentDomain.UnhandledException += (UnhandledExceptionEventHandler)((sender, exceptionArgs) =>
     {
         Console.Write("================\r\n" + string.Format("{0}: Unhandled Exception\r\nThread: {1} [{2}]\r\nCulture: {3}\r\nException: {4}\r\n", (object)DateTime.Now, (object)Thread.CurrentThread.ManagedThreadId, (object)Thread.CurrentThread.Name, (object)Thread.CurrentThread.CurrentCulture.Name, (object)exceptionArgs.ExceptionObject.ToString()) + "================\r\n");
         if (!CrashWatcher.DumpOnCrash)
         {
             return;
         }
         CrashDump.WriteException(CrashWatcher.CrashDumpOptions, CrashWatcher.DumpPath);
     });
 }
Example #10
0
 // Token: 0x06000974 RID: 2420 RVA: 0x003B5FE3 File Offset: 0x003B41E3
 public static bool Write(CrashDump.Options options, string outputDirectory = ".")
 {
     return(CrashDump.Write(options, CrashDump.ExceptionInfo.None, outputDirectory));
 }
Example #11
0
        public static void Create()
        {
            DateTime localTime = DateTime.Now.ToLocalTime();

            CrashDump.Create("Terraria " + Main.versionNumber + " " + localTime.Year.ToString("D4") + "-" + localTime.Month.ToString("D2") + "-" + localTime.Day.ToString("D2") + " " + localTime.Hour.ToString("D2") + "_" + localTime.Minute.ToString("D2") + "_" + localTime.Second.ToString("D2") + ".dmp");
        }
		private static extern bool MiniDumpWriteDump(IntPtr hProcess, int ProcessId, IntPtr hFile, CrashDump.MINIDUMP_TYPE DumpType, IntPtr ExceptionParam, IntPtr UserStreamParam, IntPtr CallackParam);