Exemplo n.º 1
0
 private static void SubmitReport(Exception uncaughtException)
 {
     lock (WindowsErrorReporting.reportCreationLock)
     {
         if (uncaughtException == null)
         {
             throw new ArgumentNullException(nameof(uncaughtException));
         }
         WindowsErrorReporting.ReportInformation reportInformation = new WindowsErrorReporting.ReportInformation();
         reportInformation.dwSize              = Marshal.SizeOf((object)reportInformation);
         reportInformation.hProcess            = WindowsErrorReporting.hCurrentProcess;
         reportInformation.hwndParent          = WindowsErrorReporting.hwndMainWindow;
         reportInformation.wzApplicationName   = WindowsErrorReporting.applicationName;
         reportInformation.wzApplicationPath   = WindowsErrorReporting.applicationPath;
         reportInformation.wzConsentKey        = (string)null;
         reportInformation.wzDescription       = (string)null;
         reportInformation.wzFriendlyEventName = (string)null;
         WindowsErrorReporting.ReportHandle reportHandle;
         WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerReportCreate("PowerShell", WindowsErrorReporting.ReportType.WerReportCritical, reportInformation, out reportHandle));
         using (reportHandle)
         {
             WindowsErrorReporting.SetBucketParameters(reportHandle, uncaughtException);
             WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerReportAddDump(reportHandle, WindowsErrorReporting.hCurrentProcess, IntPtr.Zero, WindowsErrorReporting.DumpType.MiniDump, IntPtr.Zero, IntPtr.Zero, (WindowsErrorReporting.DumpFlags) 0));
             WindowsErrorReporting.SubmitResult result = WindowsErrorReporting.SubmitResult.ReportFailed;
             WindowsErrorReporting.SubmitFlags  flags  = WindowsErrorReporting.SubmitFlags.HonorRecovery | WindowsErrorReporting.SubmitFlags.HonorRestart | WindowsErrorReporting.SubmitFlags.AddRegisteredData | WindowsErrorReporting.SubmitFlags.OutOfProcess;
             if (WindowsErrorReporting.unattendedServerMode)
             {
                 flags |= WindowsErrorReporting.SubmitFlags.Queue;
             }
             WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerReportSubmit(reportHandle, WindowsErrorReporting.Consent.NotAsked, flags, out result));
             Environment.Exit((int)result);
         }
     }
 }
Exemplo n.º 2
0
 private static void SetBucketParameter(
     WindowsErrorReporting.ReportHandle reportHandle,
     WindowsErrorReporting.BucketParameterId bucketParameterId,
     string value)
 {
     WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerReportSetParameter(reportHandle, bucketParameterId, bucketParameterId.ToString(), value));
 }
Exemplo n.º 3
0
 internal static void RegisterWindowsErrorReporting(bool unattendedServer)
 {
     lock (WindowsErrorReporting.registrationLock)
     {
         if (WindowsErrorReporting.registered || !WindowsErrorReporting.IsWindowsErrorReportingAvailable())
         {
             return;
         }
         WindowsErrorReporting.FindStaticInformation();
         WindowsErrorReporting.unattendedServerMode = unattendedServer;
         if (unattendedServer)
         {
             WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerSetFlags(WindowsErrorReporting.ReportingFlags.Queue));
         }
         else
         {
             WindowsErrorReporting.HandleHResult(WindowsErrorReporting.NativeMethods.WerSetFlags((WindowsErrorReporting.ReportingFlags) 0));
         }
         AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(WindowsErrorReporting.CurrentDomain_UnhandledException);
         WindowsErrorReporting.registered            = true;
     }
 }