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); } } }
internal static extern int WerReportSubmit(WindowsErrorReporting.ReportHandle reportHandle, WindowsErrorReporting.Consent consent, WindowsErrorReporting.SubmitFlags flags, out WindowsErrorReporting.SubmitResult result);