#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member using System.Collections.Generic; using static Vanara.PInvoke.DbgHelp; using static Vanara.PInvoke.Kernel32; namespace Vanara.PInvoke; /// Functions, structures and constants from wer.dll. public static partial class Wer { /// The type of report store to open. [PInvokeData("werapi.h")] public enum REPORT_STORE_TYPES { /// Undocumented. E_STORE_USER_ARCHIVE = 0, /// Undocumented. E_STORE_USER_QUEUE = 1, /// Opens the store of error reports that have already been sent to Microsoft. E_STORE_MACHINE_ARCHIVE = 2, /// Opens the queue of all error reports on the machine that have not yet been sent to Microsoft. E_STORE_MACHINE_QUEUE = 3, /// Undocumented. E_STORE_INVALID = 4 } /// The consent status. [PInvokeData("werapi.h", MSDNShortId = "1433862e-5cf6-4d31-9fd9-137b7b86ec57")] public enum WER_CONSENT { /// The user was not asked for consent. WerConsentNotAsked = 1, /// The user has approved the submission request. WerConsentApproved = 2, /// The user has denied the submission request. WerConsentDenied = 3, /// The user is always asked to submit the request. WerConsentAlwaysPrompt = 4, } /// Flags used by . [PInvokeData("werapi.h", MSDNShortId = "b40dac44-f7c5-43f0-876d-6f97c26bf461")] [Flags] public enum WER_DUMP { /// If the report is being queued, do not include a heap dump. Using this flag saves disk space. WER_DUMP_NOHEAP_ONQUEUE = 1, /// Undocumented. WER_DUMP_AUXILIARY = 2 } /// A mask that controls which options are valid in . [PInvokeData("werapi.h", MSDNShortId = "6ea32573-ac1a-4f9b-b4ba-b5767927924f")] [Flags] public enum WER_DUMP_MASK : uint { WER_DUMP_MASK_DUMPTYPE = 1 << 0, WER_DUMP_MASK_ONLY_THISTHREAD = 1 << 1, WER_DUMP_MASK_THREADFLAGS = 1 << 2, WER_DUMP_MASK_THREADFLAGS_EX = 1 << 3, WER_DUMP_MASK_OTHERTHREADFLAGS = 1 << 4, WER_DUMP_MASK_OTHERTHREADFLAGS_EX = 1 << 5, WER_DUMP_MASK_PREFERRED_MODULESFLAGS = 1 << 6, WER_DUMP_MASK_OTHER_MODULESFLAGS = 1 << 7, WER_DUMP_MASK_PREFERRED_MODULE_LIST = 1 << 8, } public enum WER_DUMP_TYPE { WerDumpTypeNone = 0, WerDumpTypeMicroDump = 1, WerDumpTypeMiniDump = 2, WerDumpTypeHeapDump = 3, WerDumpTypeTriageDump = 4, WerDumpTypeMax = 5 } /// The identifier of the parameter to be set. [PInvokeData("werapi.h", MSDNShortId = "accf423d-6f03-41e2-b5e9-4a0b630bc918")] public enum WER_P { WER_P0 = 0, WER_P1 = 1, WER_P2 = 2, WER_P3 = 3, WER_P4 = 4, WER_P5 = 5, WER_P6 = 6, WER_P7 = 7, WER_P8 = 8, WER_P9 = 9, } /// Flags for . [PInvokeData("werapi.h", MSDNShortId = "1433862e-5cf6-4d31-9fd9-137b7b86ec57")] [Flags] public enum WER_SUBMIT { /// Honor any recovery registration for the application. For more information, see RegisterApplicationRecoveryCallback. WER_SUBMIT_HONOR_RECOVERY = 1, /// Honor any restart registration for the application. For more information, see RegisterApplicationRestart. WER_SUBMIT_HONOR_RESTART = 2, /// /// Add the report to the WER queue without notifying the user. The report is queued only—reporting (sending the report to /// Microsoft) occurs later based on the user's consent level. /// WER_SUBMIT_QUEUE = 4, /// Show the debug button. WER_SUBMIT_SHOW_DEBUG = 8, /// Add the data registered by WerSetFlags, WerRegisterFile, and WerRegisterMemoryBlock to the report. WER_SUBMIT_ADD_REGISTERED_DATA = 16, /// Spawn another process to submit the report. The calling thread is blocked until the function returns. WER_SUBMIT_OUTOFPROCESS = 32, /// Do not display the close dialog box for the critical report. WER_SUBMIT_NO_CLOSE_UI = 64, /// /// Do not queue the report. If there is adequate user consent the report is sent to Microsoft immediately; otherwise, the report /// is discarded. You may use this flag for non-critical reports. /// /// The report is discarded for any action that would require the report to be queued. For example, if the computer is offline /// when you submit the report, the report is discarded. Also, if there is insufficient consent (for example, consent was /// required for the data portion of the report), the report is discarded. /// /// WER_SUBMIT_NO_QUEUE = 128, /// Do not archive the report. WER_SUBMIT_NO_ARCHIVE = 256, /// The initial UI is minimized and flashing. WER_SUBMIT_START_MINIMIZED = 512, /// /// Spawn another process to submit the report and return from this function call immediately. Note that the contents of the /// pSubmitResult parameter are undefined and there is no way to query when the reporting completes or the completion status. /// WER_SUBMIT_OUTOFPROCESS_ASYNC = 1024, /// /// Bypass data throttling for the report. /// Windows 7 or earlier: This parameter is not available. /// WER_SUBMIT_BYPASS_DATA_THROTTLING = 2048, /// Archive only the parameters; the cab is discarded WER_SUBMIT_ARCHIVE_PARAMETERS_ONLY = 4096, /// Always send the machine ID, regardless of the consent the report was submitted with WER_SUBMIT_REPORT_MACHINE_ID = 8192, /// Bypass power-related throttling (when on battery) WER_SUBMIT_BYPASS_POWER_THROTTLING = 16384, /// Bypass network-related throttling (when on restricted networks) WER_SUBMIT_BYPASS_NETWORK_COST_THROTTLING = 32768 } /// Adds the specified application to the list of applications that are to be excluded from error reporting. /// /// A pointer to a Unicode string that specifies the name of the executable file for the application, including the file name /// extension. The maximum length of this path is MAX_PATH characters. /// /// /// If this parameter is TRUE, the application name is added to the list of excluded applications for all users. Otherwise, it /// is only added to the list of excluded applications for the current user. /// /// /// This function returns S_OK on success or an error code on failure, including the following error code. /// /// /// Return code /// Description /// /// /// E_ACCESSDENIED /// The process does not have permissions to update the list in the registry. See the Remarks section for additional information. /// /// /// /// /// /// If bAllUsers is TRUE, the list of excluded applications is stored under the HKEY_LOCAL_MACHINE registry hive. The calling /// process must have permissions to write to the HKLM registry hive. If bAllUsers is FALSE, the list of excluded applications /// is stored under the HKEY_CURRENT_USER registry hive. /// /// To remove the application from the list of excluded applications, call the WerRemoveExcludedApplication function. /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-weraddexcludedapplication HRESULT WerAddExcludedApplication( // PCWSTR pwzExeName, BOOL bAllUsers ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "ac1ec373-868f-4634-8658-4253d4f5923a")] public static extern HRESULT WerAddExcludedApplication([MarshalAs(UnmanagedType.LPWStr)] string pwzExeName, [MarshalAs(UnmanagedType.Bool)] bool bAllUsers); /// /// Frees up the memory used to store a report key string. This should be called after each successive call to /// WerStoreGetFirstReportKey or WerStoreGetNextReportKey, once the particular report key string has been used and is no longer needed. /// /// The string to be freed (value set to NULL). /// This function does not return a value. // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werfreestring void WerFreeString( PCWSTR pwszStr ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "748AEFD4-3310-4BC1-A3DA-CFACBA31F2FC")] public static extern void WerFreeString(StrPtrUni pwszStr); /// Removes the specified application from the list of applications that are to be excluded from error reporting. /// /// /// A pointer to a Unicode string that specifies the name of the executable file for the application, including the file name /// extension. The maximum length of this path is MAX_PATH characters. /// /// /// This file must have been excluded using the WerAddExcludedApplication function or WerRemoveExcludedApplication fails. /// /// /// /// If this parameter is TRUE, the application name is removed from the list of excluded applications for all users. /// Otherwise, it is only removed from the list of excluded applications for the current user. /// /// /// This function returns S_OK on success or an error code on failure, including the following error code. /// /// /// Return code /// Description /// /// /// E_ACCESSDENIED /// The process does not have access to update the list in the registry. See the Remarks section for additional information. /// /// /// /// /// /// This function removes applications that were added to the excluded applications list using the WerAddExcludedApplication function. /// /// /// If bAllUsers is TRUE, the list of excluded applications is stored under the HKEY_LOCAL_MACHINE registry hive. The calling /// process must have permissions to write to HKLM registry hive. If bAllUsers is FALSE, the list of excluded applications is /// stored under the HKEY_CURRENT_USER registry hive. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werremoveexcludedapplication HRESULT // WerRemoveExcludedApplication( PCWSTR pwzExeName, BOOL bAllUsers ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "e7bab01b-a09c-4b06-a233-34ed63f75857")] public static extern HRESULT WerRemoveExcludedApplication([MarshalAs(UnmanagedType.LPWStr)] string pwzExeName, [MarshalAs(UnmanagedType.Bool)] bool bAllUsers); /// Adds a dump of the specified type to the specified report. /// A handle to the report. This handle is returned by the WerReportCreate function. /// /// A handle to the process for which the report is being generated. This handle must have the STANDARD_RIGHTS_READ and /// PROCESS_QUERY_INFORMATION access rights. /// /// /// A handle to the thread of hProcess for which the report is being generated. If dumpType is WerDumpTypeMicro, this parameter is /// required. For other dump types, this parameter may be NULL. /// /// /// The type of minidump. This parameter can be one of the following values from the WER_DUMP_TYPE enumeration type. /// /// /// Value /// Meaning /// /// /// WerDumpTypeHeapDump /// /// An extended minidump that contains additional data such as the process memory. This type is equivalent to creating a minidump /// with the following options: /// /// /// /// WerDumpTypeMicroDump /// /// A limited minidump that contains only a stack trace. This type is equivalent to creating a minidump with the following options: /// /// /// /// WerDumpTypeMiniDump /// A minidump. This type is equivalent to creating a minidump with the following options: /// /// /// /// A pointer to a WER_EXCEPTION_INFORMATION structure that specifies exception information. /// /// A pointer to a WER_DUMP_CUSTOM_OPTIONS structure that specifies custom minidump options. If this parameter is NULL, the /// standard minidump information is collected. /// /// /// This parameter can be 0 or the following value. /// /// /// Value /// Meaning /// /// /// WER_DUMP_NOHEAP_ONQUEUE /// If the report is being queued, do not include a heap dump. Using this flag saves disk space. /// /// /// /// This function returns S_OK on success or an error code on failure. /// /// Use this function only for generic reporting—it has no effect on operating system crash or no-response reporting. /// /// If the server asks for a mini dump and you specify WerDumpTypeHeapDump for the dumpType parameter, WER will not send the /// heap dump to the Watson server. However, if the server asks for a heap dump and the dumpType is WerDumpTypeMiniDump, WER /// will send the mini dump to the server. Thus, it is recommended that you set dumpType to WerDumpTypeMiniDump. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werreportadddump HRESULT WerReportAddDump( HREPORT // hReportHandle, HANDLE hProcess, HANDLE hThread, WER_DUMP_TYPE dumpType, PWER_EXCEPTION_INFORMATION pExceptionParam, // PWER_DUMP_CUSTOM_OPTIONS pDumpCustomOptions, DWORD dwFlags ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "b40dac44-f7c5-43f0-876d-6f97c26bf461")] public static extern HRESULT WerReportAddDump(HREPORT hReportHandle, HPROCESS hProcess, [Optional] HTHREAD hThread, WER_DUMP_TYPE dumpType, in WER_EXCEPTION_INFORMATION pExceptionParam, in WER_DUMP_CUSTOM_OPTIONS pDumpCustomOptions, WER_DUMP dwFlags); /// Adds a dump of the specified type to the specified report. /// A handle to the report. This handle is returned by the WerReportCreate function. /// /// A handle to the process for which the report is being generated. This handle must have the STANDARD_RIGHTS_READ and /// PROCESS_QUERY_INFORMATION access rights. /// /// /// A handle to the thread of hProcess for which the report is being generated. If dumpType is WerDumpTypeMicro, this parameter is /// required. For other dump types, this parameter may be NULL. /// /// /// The type of minidump. This parameter can be one of the following values from the WER_DUMP_TYPE enumeration type. /// /// /// Value /// Meaning /// /// /// WerDumpTypeHeapDump /// /// An extended minidump that contains additional data such as the process memory. This type is equivalent to creating a minidump /// with the following options: /// /// /// /// WerDumpTypeMicroDump /// /// A limited minidump that contains only a stack trace. This type is equivalent to creating a minidump with the following options: /// /// /// /// WerDumpTypeMiniDump /// A minidump. This type is equivalent to creating a minidump with the following options: /// /// /// /// A pointer to a WER_EXCEPTION_INFORMATION structure that specifies exception information. /// /// A pointer to a WER_DUMP_CUSTOM_OPTIONS structure that specifies custom minidump options. If this parameter is NULL, the /// standard minidump information is collected. /// /// /// This parameter can be 0 or the following value. /// /// /// Value /// Meaning /// /// /// WER_DUMP_NOHEAP_ONQUEUE /// If the report is being queued, do not include a heap dump. Using this flag saves disk space. /// /// /// /// This function returns S_OK on success or an error code on failure. /// /// Use this function only for generic reporting—it has no effect on operating system crash or no-response reporting. /// /// If the server asks for a mini dump and you specify WerDumpTypeHeapDump for the dumpType parameter, WER will not send the /// heap dump to the Watson server. However, if the server asks for a heap dump and the dumpType is WerDumpTypeMiniDump, WER /// will send the mini dump to the server. Thus, it is recommended that you set dumpType to WerDumpTypeMiniDump. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werreportadddump HRESULT WerReportAddDump( HREPORT // hReportHandle, HANDLE hProcess, HANDLE hThread, WER_DUMP_TYPE dumpType, PWER_EXCEPTION_INFORMATION pExceptionParam, // PWER_DUMP_CUSTOM_OPTIONS pDumpCustomOptions, DWORD dwFlags ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "b40dac44-f7c5-43f0-876d-6f97c26bf461")] public static extern HRESULT WerReportAddDump(HREPORT hReportHandle, HPROCESS hProcess, [Optional] HTHREAD hThread, WER_DUMP_TYPE dumpType, in WER_EXCEPTION_INFORMATION pExceptionParam, [In, Optional] IntPtr pDumpCustomOptions, WER_DUMP dwFlags); /// Adds a file to the specified report. /// A handle to the report. This handle is returned by the WerReportCreate function. /// /// A pointer to a Unicode string that contains the full path to the file to be added. This path can use environment variables. The /// maximum length of this path is MAX_PATH characters. /// /// /// The type of file. This parameter can be one of the following values from the WER_FILE_TYPE enumeration type. /// /// /// Value /// Meaning /// /// /// WerFileTypeHeapdump /// An extended minidump that contains additional data such as the process memory. /// /// /// WerFileTypeMicrodump /// A limited minidump that contains only a stack trace. /// /// /// WerFileTypeMinidump /// A minidump file. /// /// /// WerFileTypeOther /// Any other type of file. This file will always get added to the cab (but only if the server asks for a cab). /// /// /// WerFileTypeUserDocument /// /// The document in use by the application at the time of the event. The document is added only if the server is asks for this type /// of document. /// /// /// /// /// /// This parameter can be one or more of the following values. /// /// /// Value /// Meaning /// /// /// WER_FILE_ANONYMOUS_DATA /// The file does not contain personal information that could be used to identify or contact the user. /// /// /// WER_FILE_DELETE_WHEN_DONE /// Automatically delete the file after the report is submitted. /// /// /// /// /// This function returns S_OK on success or an error code on failure, including the following error code. /// /// /// Return code /// Description /// /// /// HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) /// The specified file does not exist. /// /// /// HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED) /// The specified file is a user-document and is stored on an encrypted file-system; this combination is not supported. /// /// /// /// /// Although this function can also be used to add memory dumps (using specific flags) to the error report, the preferred function to /// use for adding memory dumps is WerReportAddDump. You should use this function only if you want to collect the dump yourself and /// then add it to the report. /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werreportaddfile HRESULT WerReportAddFile( HREPORT // hReportHandle, PCWSTR pwzPath, WER_FILE_TYPE repFileType, DWORD dwFileFlags ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "4b2c2060-a193-4168-90fc-afb95c160569")] public static extern HRESULT WerReportAddFile(HREPORT hReportHandle, [MarshalAs(UnmanagedType.LPWStr)] string pwzPath, WER_FILE_TYPE repFileType, WER_REGISTER_FILE_FLAGS dwFileFlags); /// Closes the specified report. /// A handle to the report. This handle is returned by the WerReportCreate function. /// This function returns S_OK on success or an error code on failure. // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werreportclosehandle HRESULT WerReportCloseHandle( HREPORT // hReportHandle ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "b7326003-cd25-4988-9ed4-31c2e030beec")] public static extern HRESULT WerReportCloseHandle(HREPORT hReportHandle); /// Creates a problem report that describes an application event. /// A pointer to a Unicode string that specifies the name of the event. /// /// The type of report. This parameter can be one of the following values from the WER_REPORT_TYPE enumeration type. /// /// /// Value /// Meaning /// /// /// WerReportApplicationCrash 2 /// An error that has caused the application to stop running has occurred. /// /// /// WerReportApplicationHang 3 /// An error that has caused the application to stop responding has occurred. /// /// /// WerReportInvalid 5 /// An error that has called out a return that is not valid has occurred. /// /// /// WerReportKernel 4 /// An error in the kernel has occurred. /// /// /// WerReportCritical 1 /// /// A critical error, such as a crash or non-response, has occurred. By default, processes that experience a critical error are /// terminated or restarted. /// /// /// /// WerReportNonCritical 0 /// /// An error that is not critical has occurred. This type of report shows no UI; the report is silently queued. It may then be sent /// silently to the server in the background if adequate user consent is available. /// /// /// /// /// A pointer to a WER_REPORT_INFORMATION structure that specifies information for the report. /// A handle to the report. If the function fails, this handle is NULL. /// This function returns S_OK on success or an error code on failure. /// /// Use the following functions to specify additional information to be submitted: /// /// WerReportAddDump WerReportAddFile WerReportSetParameter To submit the information, call the WerReportSubmit function. When you /// have finished with the report handle, call the WerReportCloseHandle function. /// /// /// Applications can also indicate that they would like the opportunity to recover data or restart on failure. For more information, /// see Application Recovery and Restart. /// /// To view the reports submitted by your application, go to Windows Quality Online Services. /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werreportcreate HRESULT WerReportCreate( PCWSTR pwzEventType, // WER_REPORT_TYPE repType, PWER_REPORT_INFORMATION pReportInformation, HREPORT *phReportHandle ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)] [PInvokeData("werapi.h", MSDNShortId = "41f68dde-5e43-45a6-8e0b-3ae0c6180e8b")] public static extern HRESULT WerReportCreate(string pwzEventType, WER_REPORT_TYPE repType, in WER_REPORT_INFORMATION pReportInformation, out SafeHREPORT phReportHandle); /// Sets the parameters that uniquely identify an event for the specified report. /// A handle to the report. This handle is returned by the WerReportCreate function. /// /// The identifier of the parameter to be set. This parameter can be one of the following values. /// WER_P0 /// WER_P1 /// WER_P2 /// WER_P3 /// WER_P4 /// WER_P5 /// WER_P6 /// WER_P7 /// WER_P8 /// WER_P9 /// /// /// A pointer to a Unicode string that contains the name of the parameter. If this parameter is NULL, the default name is Px, /// where x matches the integer portion of the value specified in dwparamID. /// /// The parameter value. /// /// This function returns S_OK on success or an error code on failure, including the following error code. /// /// /// Return code /// Description /// /// /// E_HANDLE /// The specified handle is not valid. /// /// /// WER_E_LENGTH_EXCEEDED /// The length of one or more string arguments has exceeded its limit. /// /// /// /// /// Each report supports parameters P0 through P9. This function sets one parameter at a time. If parameter Px is set, then all /// parameters from P0 and Px must be set. /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werreportsetparameter HRESULT WerReportSetParameter( HREPORT // hReportHandle, DWORD dwparamID, PCWSTR pwzName, PCWSTR pwzValue ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "accf423d-6f03-41e2-b5e9-4a0b630bc918")] public static extern HRESULT WerReportSetParameter(HREPORT hReportHandle, WER_P dwparamID, [MarshalAs(UnmanagedType.LPWStr)] string? pwzName, [MarshalAs(UnmanagedType.LPWStr)] string? pwzValue); /// Sets the user interface options for the specified report. /// A handle to the report. This handle is returned by the WerReportCreate function. /// /// /// The user interface element to be customized. This parameter can be one of the following values from the WER_REPORT_UI /// enumeration type. /// /// /// /// Value /// Meaning /// /// /// WerUIAdditionalDataDlgHeader /// The instructions for the additional data dialog box. /// /// /// WerUICloseDlgBody /// The contents of the close dialog box. /// /// /// WerUICloseDlgButtonText /// The text for the button in the close dialog box. /// /// /// WerUICloseDlgHeader /// The main instructions for the close dialog box. /// /// /// WerUICloseText /// The text for the link to just terminate the application. /// /// /// WerUIConsentDlgBody /// The contents of the consent dialog box. /// /// /// WerUIConsentDlgHeader /// The main instructions for the consent dialog box. /// /// /// WerUIIconFilePath /// The icon to be displayed in the consent dialog box. /// /// /// WerUIOfflineSolutionCheckText /// The text for the link to check for a solution when offline. /// /// /// WerUIOnlineSolutionCheckText /// The text for the link to check for a solution when online. /// /// /// /// /// A pointer to a Unicode string that specifies the custom text. For more information, see the description of repUITypeID. /// /// This function returns S_OK on success or an error code on failure. // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werreportsetuioption HRESULT WerReportSetUIOption( HREPORT // hReportHandle, WER_REPORT_UI repUITypeID, PCWSTR pwzValue ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "c8816782-faec-490e-898f-a40df8fb205b")] public static extern HRESULT WerReportSetUIOption(HREPORT hReportHandle, WER_REPORT_UI repUITypeID, [MarshalAs(UnmanagedType.LPWStr)] string pwzValue); /// Submits the specified report. /// A handle to the report. This handle is returned by the WerReportCreate function. /// /// The consent status. This parameter can be one of the following values from the WER_CONSENT enumeration type. /// /// /// Value /// Meaning /// /// /// WerConsentAlwaysPrompt 4 /// The user is always asked to submit the request. /// /// /// WerConsentApproved 2 /// The user has approved the submission request. /// /// /// WerConsentDenied 3 /// The user has denied the submission request. /// /// /// WerConsentMax 5 /// The maximum value for the WER_CONSENT enumeration type. /// /// /// WerConsentNotAsked 1 /// The user was not asked for consent. /// /// /// /// /// This parameter can be one or more of the following values. /// /// /// Value /// Meaning /// /// /// WER_SUBMIT_ADD_REGISTERED_DATA 16 /// Add the data registered by WerSetFlags, WerRegisterFile, and WerRegisterMemoryBlock to the report. /// /// /// WER_SUBMIT_HONOR_RECOVERY 1 /// Honor any recovery registration for the application. For more information, see RegisterApplicationRecoveryCallback. /// /// /// WER_SUBMIT_HONOR_RESTART 2 /// Honor any restart registration for the application. For more information, see RegisterApplicationRestart. /// /// /// WER_SUBMIT_NO_ARCHIVE 256 /// Do not archive the report. /// /// /// WER_SUBMIT_NO_CLOSE_UI 64 /// Do not display the close dialog box for the critical report. /// /// /// WER_SUBMIT_NO_QUEUE 128 /// /// Do not queue the report. If there is adequate user consent the report is sent to Microsoft immediately; otherwise, the report is /// discarded. You may use this flag for non-critical reports. The report is discarded for any action that would require the report /// to be queued. For example, if the computer is offline when you submit the report, the report is discarded. Also, if there is /// insufficient consent (for example, consent was required for the data portion of the report), the report is discarded. /// /// /// /// WER_SUBMIT_OUTOFPROCESS 32 /// Spawn another process to submit the report. The calling thread is blocked until the function returns. /// /// /// WER_SUBMIT_OUTOFPROCESS_ASYNC 1024 /// /// Spawn another process to submit the report and return from this function call immediately. Note that the contents of the /// pSubmitResult parameter are undefined and there is no way to query when the reporting completes or the completion status. /// /// /// /// WER_SUBMIT_QUEUE 4 /// /// Add the report to the WER queue without notifying the user. The report is queued only—reporting (sending the report to Microsoft) /// occurs later based on the user's consent level. /// /// /// /// WER_SUBMIT_SHOW_DEBUG 8 /// Show the debug button. /// /// /// WER_SUBMIT_START_MINIMIZED 512 /// The initial UI is minimized and flashing. /// /// /// WER_SUBMIT_BYPASS_DATA_THROTTLING 2048 /// Bypass data throttling for the report. Windows 7 or earlier: This parameter is not available. /// /// /// WER_SUBMIT_ARCHIVE_PARAMETERS_ONLY 4096 /// /// Archive only the parameters; the cab is discarded. This flag overrides the ConfigureArchive WER setting. Windows 7 or earlier: /// This parameter is not available. /// /// /// /// WER_SUBMIT_REPORT_MACHINE_ID 8192 /// /// Always send the unique, 128-bit computer identifier with the report, regardless of the consent with which the report was /// submitted. See Remarks for additional information. Windows 7 or earlier: This parameter is not available. /// /// /// /// /// /// /// The result of the submission. This parameter can be one of the following values from the WER_SUBMIT_RESULT enumeration type. /// /// /// /// Value /// Meaning /// /// /// WerCustomAction 9 /// Error reporting can be customized. /// /// /// WerDisabled 5 /// Error reporting was disabled. /// /// /// WerDisabledQueue 7 /// Queuing was disabled. /// /// /// WerReportAsync 8 /// The report was asynchronous. /// /// /// WerReportCancelled 6 /// The report was canceled. /// /// /// WerReportDebug 3 /// The Debug button was clicked. /// /// /// WerReportFailed 4 /// The report submission failed. /// /// /// WerReportQueued 1 /// The report was queued. /// /// /// WerReportUploaded 2 /// The report was uploaded. /// /// /// /// This function returns S_OK on success or an error code on failure. /// /// /// After the application calls this function, WER collects the specified data. If the consent parameter is WerConsentApproved, it /// submits the report to Microsoft. If consent is WerConsentNotAsked, WER displays the consent dialog box. To determine the /// submission status, check the pSubmitResult parameter. /// /// In the event of a critical application event, applications that have registered for restart will be restarted. /// The computer identifier is sent with the report when /// /// /// /// The consent used to send the report does not come from the application. For example, the report was submitted with consent status /// set to WerConsentNotAsked. /// /// /// /// The report was submitted with the WER_SUBMIT_REPORT_MACHINE_ID flag set. /// /// /// To view the reports submitted by your application, go to Windows Quality Online Services. /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werreportsubmit HRESULT WerReportSubmit( HREPORT // hReportHandle, WER_CONSENT consent, DWORD dwFlags, PWER_SUBMIT_RESULT pSubmitResult ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "1433862e-5cf6-4d31-9fd9-137b7b86ec57")] public static extern HRESULT WerReportSubmit(HREPORT hReportHandle, WER_CONSENT consent, WER_SUBMIT dwFlags, out WER_SUBMIT_RESULT pSubmitResult); /// Closes the collection of stored reports. /// The error report store to close (previously retrieved with WerStoreOpen). /// This function does not return a value. // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werstoreclose void WerStoreClose( HREPORTSTORE hReportStore ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "C34FBA67-5267-471C-B1AA-87BFC5725831")] public static extern void WerStoreClose(HREPORTSTORE hReportStore); /// Gets a reference to the first report in the report store. /// The error report store (previously retrieved with WerStoreOpen). /// /// A pointer to the report key string. On a successful call, this will point to the retrieved report key. /// /// /// This function returns S_OK on success or an error code on failure, including the following error code. /// /// /// Return code /// Description /// /// /// E_INVALID_ARG /// One of the arguments is not a valid value. /// /// /// ERROR_NO_MORE_FILES /// There are no error reports in the store. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werstoregetfirstreportkey HRESULT WerStoreGetFirstReportKey( // HREPORTSTORE hReportStore, PCWSTR *ppszReportKey ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "E4732B60-BFBE-4916-83A6-5F031D267913")] public static extern HRESULT WerStoreGetFirstReportKey(HREPORTSTORE hReportStore, out StrPtrUni ppszReportKey); /// Gets a reference to the next report in the error report store. /// The error report store (previously retrieved with WerStoreOpen). /// /// A pointer to the report key string. On a successful call, this will point to the retrieved report key. /// /// /// This function returns S_OK on success or an error code on failure, including the following error code. /// /// /// Return code /// Description /// /// /// E_INVALID_ARG /// One of the arguments is not a valid value. /// /// /// ERROR_NO_MORE_FILES /// There are no more error reports in the store. /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werstoregetnextreportkey HRESULT WerStoreGetNextReportKey( // HREPORTSTORE hReportStore, PCWSTR *ppszReportKey ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "781D54A9-6F51-445E-89A8-A0C944081B81")] public static extern HRESULT WerStoreGetNextReportKey(HREPORTSTORE hReportStore, out StrPtrUni ppszReportKey); /// Opens the collection of stored error reports. /// The type of report store to open. See Remarks for details. /// A pointer to a report store. On a successful call, this will point to the retrieved report store. /// /// This function returns S_OK on success or an error code on failure, including the following error code. /// /// /// Return code /// Description /// /// /// E_INVALIDARG /// One of the arguments is not a valid value. /// /// /// /// /// /// A storeType value of E_STORE_MACHINE_QUEUE opens the queue of all error reports on the machine that have not yet been sent /// to Microsoft. A value of E_STORE_MACHINE_ARCHIVE opens the store of error reports that have already been sent. /// /// /// The Windows Error Report (WER) Store is the queue of error reports that have been marked to be sent to Microsoft but have not yet /// been uploaded. The upload of an error report can be postponed under a number of circumstances. The WerStore functions allow /// developers to access the stored reports and query the status of each one. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werstoreopen HRESULT WerStoreOpen( REPORT_STORE_TYPES // repStoreType, PHREPORTSTORE phReportStore ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "FA7E0EC6-00F1-45E2-BE34-D732965FBA15")] public static extern HRESULT WerStoreOpen(REPORT_STORE_TYPES repStoreType, out SafeHREPORTSTORE phReportStore); /// Retrieves metadata about a report in the store. /// The error report store (previously retrieved with WerStoreOpen). /// /// The string identifying which report is being queried (previously retrieved with WerStoreGetFirstReportKey or WerStoreGetNextReportKey). /// /// /// A pointer to the report store metadata in the form of a WER_REPORT_METADATA_V2 structure. The field SizeOfFileNames should /// be set to 0 during the first call. The function updates this field with the required size to hold the file names associated with /// the report. The field FileNames should then be allocated with SizeOfFileNames bytes and the function should be /// called again to get all of the file names. /// /// /// This function returns S_OK on success or an error code on failure, including the following error code. /// /// /// Return code /// Description /// /// /// E_INVALID_ARG /// One of the arguments is not a valid value. /// /// /// ERROR_INSUFFICIENT_BUFFER /// /// There is not enough memory available to retrieve the metadata. In this case, the caller should allocate memory of size /// SizeOfFileNames for the FileNames field, found in the WER_REPORT_METADATA_V2 structure, and call the function again. /// /// /// /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/nf-werapi-werstorequeryreportmetadatav2 HRESULT // WerStoreQueryReportMetadataV2( HREPORTSTORE hReportStore, PCWSTR pszReportKey, PWER_REPORT_METADATA_V2 pReportMetadata ); [DllImport(Lib.Wer, SetLastError = false, ExactSpelling = true)] [PInvokeData("werapi.h", MSDNShortId = "ADF6619C-1F3E-4AFF-9E25-4F6F83D1353C")] public static extern HRESULT WerStoreQueryReportMetadataV2(HREPORTSTORE hReportStore, [MarshalAs(UnmanagedType.LPWStr)] string pszReportKey, out WER_REPORT_METADATA_V2 pReportMetadata); /// Provides a handle to a problem report. [StructLayout(LayoutKind.Sequential)] public struct HREPORT : IHandle { private IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HREPORT(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HREPORT NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HREPORT h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HREPORT(IntPtr h) => new(h); /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HREPORT h1, HREPORT h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HREPORT h1, HREPORT h2) => h1.Equals(h2); /// public override bool Equals(object? obj) => obj is HREPORT h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Provides a handle to a error report store. [StructLayout(LayoutKind.Sequential)] public struct HREPORTSTORE : IHandle { private IntPtr handle; /// Initializes a new instance of the struct. /// An object that represents the pre-existing handle to use. public HREPORTSTORE(IntPtr preexistingHandle) => handle = preexistingHandle; /// Returns an invalid handle by instantiating a object with . public static HREPORTSTORE NULL => new(IntPtr.Zero); /// Gets a value indicating whether this instance is a null handle. public bool IsNull => handle == IntPtr.Zero; /// Performs an explicit conversion from to . /// The handle. /// The result of the conversion. public static explicit operator IntPtr(HREPORTSTORE h) => h.handle; /// Performs an implicit conversion from to . /// The pointer to a handle. /// The result of the conversion. public static implicit operator HREPORTSTORE(IntPtr h) => new(h); /// Implements the operator !=. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator !=(HREPORTSTORE h1, HREPORTSTORE h2) => !(h1 == h2); /// Implements the operator ==. /// The first handle. /// The second handle. /// The result of the operator. public static bool operator ==(HREPORTSTORE h1, HREPORTSTORE h2) => h1.Equals(h2); /// public override bool Equals(object? obj) => obj is HREPORTSTORE h && handle == h.handle; /// public override int GetHashCode() => handle.GetHashCode(); /// public IntPtr DangerousGetHandle() => handle; } /// Specifies custom minidump information to be collected by the WerReportAddDump function. /// /// /// The flags specified in this structure have a direct correlation to flags passed in the MiniDumpCallback callback function (see /// MiniDumpWriteDump) when WER generates the dump file. /// /// /// If the minidump's callback input type is ThreadCallback (see the CallbackType member of MINIDUMP_CALLBACK_INPUT), /// the ThreadWriteFlags member of MINIDUMP_CALLBACK_OUTPUT is set to the flags specified in the /// dwExceptionThreadFlags, dwExceptionThreadExFlags, dwOtherThreadFlags, or dwOtherThreadExFlags /// members. If the callback is for the crashing thread, the dwExceptionThreadFlags or dwExceptionThreadExFlags flags /// are used; otherwise, the dwOtherThreadFlags or dwOtherThreadExFlags flags are used. /// /// /// If the callback input type is ModuleCallback, the ModuleWriteFlags member of MINIDUMP_CALLBACK_OUTPUT is set to the /// flags specified in the dwPreferredModuleFlags or dwOtherModuleFlags members. If the callback is for a module on the /// preferred modules list, the dwPreferredModuleFlags flags are used; otherwise, the dwOtherModuleFlags flags are used. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/werapi/ns-werapi-_wer_dump_custom_options typedef struct // _WER_DUMP_CUSTOM_OPTIONS { DWORD dwSize; DWORD dwMask; DWORD dwDumpFlags; BOOL bOnlyThisThread; DWORD dwExceptionThreadFlags; // DWORD dwOtherThreadFlags; DWORD dwExceptionThreadExFlags; DWORD dwOtherThreadExFlags; DWORD dwPreferredModuleFlags; DWORD // dwOtherModuleFlags; WCHAR wzPreferredModuleList[WER_MAX_PREFERRED_MODULES_BUFFER]; } WER_DUMP_CUSTOM_OPTIONS, *PWER_DUMP_CUSTOM_OPTIONS; [PInvokeData("werapi.h", MSDNShortId = "6ea32573-ac1a-4f9b-b4ba-b5767927924f")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WER_DUMP_CUSTOM_OPTIONS { /// The size of the structure, in bytes. public uint dwSize; /// /// A mask that controls which options are valid in this structure. You can specify one or more of the following values: /// WER_DUMP_MASK_DUMPTYPE /// WER_DUMP_MASK_ONLY_THISTHREAD /// WER_DUMP_MASK_OTHER_MODULESFLAGS /// WER_DUMP_MASK_OTHERTHREADFLAGS /// WER_DUMP_MASK_OTHERTHREADFLAGS_EX /// WER_DUMP_MASK_PREFERRED_MODULE_LIST /// WER_DUMP_MASK_PREFERRED_MODULESFLAGS /// WER_DUMP_MASK_THREADFLAGS /// WER_DUMP_MASK_THREADFLAGS_EX /// public WER_DUMP_MASK dwMask; /// /// The type information to include in the minidump. You can specify one or more of the MINIDUMP_TYPE flags. /// This member is valid only if dwMask contains WER_DUMP_MASK_DUMPTYPE. /// public MINIDUMP_TYPE dwDumpFlags; /// /// If this member is TRUE and dwMask contains WER_DUMP_MASK_ONLY_THISTHREAD, the minidump is to be collected only /// for the calling thread. /// [MarshalAs(UnmanagedType.Bool)] public bool bOnlyThisThread; /// /// The type of thread information to include in the minidump. You can specify one or more of the THREAD_WRITE_FLAGS flags. /// This member is valid only if dwMask contains WER_DUMP_MASK_THREADFLAGS. /// public THREAD_WRITE_FLAGS dwExceptionThreadFlags; /// /// The type of thread information to include in the minidump. You can specify one or more of the THREAD_WRITE_FLAGS flags. /// This member is valid only if dwMask contains WER_DUMP_MASK_OTHERTHREADFLAGS. /// public THREAD_WRITE_FLAGS dwOtherThreadFlags; /// /// The type of thread information to include in the minidump. You can specify one or more of the THREAD_WRITE_FLAGS flags. /// This member is valid only if dwMask contains WER_DUMP_MASK_THREADFLAGS_EX. /// public THREAD_WRITE_FLAGS dwExceptionThreadExFlags; /// /// The type of thread information to include in the minidump. You can specify one or more of the THREAD_WRITE_FLAGS flags. /// This member is valid only if dwMask contains WER_DUMP_MASK_OTHERTHREADFLAGS_EX. /// public THREAD_WRITE_FLAGS dwOtherThreadExFlags; /// /// /// The type of module information to include in the minidump for modules specified in the wzPreferredModuleList member. /// You can specify one or more of the MODULE_WRITE_FLAGS flags. /// /// This member is valid only if dwMask contains WER_DUMP_MASK_PREFERRED_MODULESFLAGS. /// public MODULE_WRITE_FLAGS dwPreferredModuleFlags; /// /// The type of module information to include in the minidump. You can specify one or more of the MODULE_WRITE_FLAGS flags. /// This member is valid only if dwMask contains WER_DUMP_MASK_OTHER_MODULESFLAGS. /// public MODULE_WRITE_FLAGS dwOtherModuleFlags; /// /// /// A list of module names (do not include the path) to which the dwPreferredModuleFlags flags apply. Each name must be /// null-terminated, and the list must be terminated with two null characters (for example, module1.dll\0module2.dll\0\0). /// /// /// To specify that all modules are preferred, set this member to "*\0\0". If you include * in a list with other module names, /// the * is ignored. /// /// This member is valid only if dwMask contains WER_DUMP_MASK_PREFERRED_MODULE_LIST. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string? wzPreferredModuleList; /// A default instance with the size field set. public static readonly WER_DUMP_CUSTOM_OPTIONS Default = new() { dwSize = (uint)Marshal.SizeOf(typeof(WER_DUMP_CUSTOM_OPTIONS)) }; } /// Contains exception information for the WerReportAddDump function. // https://docs.microsoft.com/en-us/windows/win32/api/werapi/ns-werapi-_wer_exception_information typedef struct // _WER_EXCEPTION_INFORMATION { PEXCEPTION_POINTERS pExceptionPointers; BOOL bClientPointers; } WER_EXCEPTION_INFORMATION, *PWER_EXCEPTION_INFORMATION; [PInvokeData("werapi.h", MSDNShortId = "4548068a-e654-40c9-9654-c5178575b42c")] [StructLayout(LayoutKind.Sequential)] public struct WER_EXCEPTION_INFORMATION { /// A pointer to an EXCEPTION_POINTERS structure. public IntPtr pExceptionPointers; /// /// A process (calling process) can provide error reporting functionality for another process (client process). If this member is /// TRUE, the exception pointer is located inside the address space of the client process. If this member is FALSE, /// the exception pointer is located inside the address space of the calling process. /// [MarshalAs(UnmanagedType.Bool)] public bool bClientPointers; } /// Contains information used by the WerReportCreate function. // https://docs.microsoft.com/en-us/windows/win32/api/werapi/ns-werapi-wer_report_information typedef struct _WER_REPORT_INFORMATION // { DWORD dwSize; HANDLE hProcess; WCHAR wzConsentKey[64]; WCHAR wzFriendlyEventName[128]; WCHAR wzApplicationName[128]; WCHAR // wzApplicationPath[MAX_PATH]; WCHAR wzDescription[512]; HWND hwndParent; } WER_REPORT_INFORMATION, *PWER_REPORT_INFORMATION; [PInvokeData("werapi.h", MSDNShortId = "3efe2b43-53ac-48e3-bc39-4a9fe6041fca")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WER_REPORT_INFORMATION { /// The size of this structure, in bytes. public uint dwSize; /// /// A handle to the process for which the report is being generated. If this member is NULL, this is the calling process. /// public HPROCESS hProcess; /// /// The name used to look up consent settings. If this member is empty, the default is the name specified by the pwzEventType /// parameter of WerReportCreate. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string wzConsentKey; /// The display name. If this member is empty, the default is the name specified by pwzEventType parameter of WerReportCreate. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string wzFriendlyEventName; /// The name of the application. If this parameter is empty, the default is the base name of the image file. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string wzApplicationName; /// The full path to the application. [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)] public string wzApplicationPath; /// /// A description of the problem. This description is displayed in Problem Reports and Solutions on Windows Vista or the /// problem reports pane of the Action Center on Windows 7. /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 512)] public string wzDescription; /// A handle to the parent window. public HWND hwndParent; /// A default instance with the size field set. public static readonly WER_REPORT_INFORMATION Default = new() { dwSize = (uint)Marshal.SizeOf(typeof(WER_REPORT_INFORMATION)) }; } /// Contains information about an error report generated by Windows Error Reporting. // https://docs.microsoft.com/en-us/windows/win32/api/werapi/ns-werapi-_wer_report_metadata_v2 typedef struct _WER_REPORT_METADATA_V2 // { WER_REPORT_SIGNATURE Signature; GUID BucketId; GUID ReportId; FILETIME CreationTime; ULONGLONG SizeInBytes; WCHAR // CabId[MAX_PATH]; DWORD ReportStatus; GUID ReportIntegratorId; DWORD NumberOfFiles; DWORD SizeOfFileNames; WCHAR *FileNames; } // WER_REPORT_METADATA_V2, *PWER_REPORT_METADATA_V2; [PInvokeData("werapi.h", MSDNShortId = "037170B1-B2DF-402F-A9E6-48C7693C9A93")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WER_REPORT_METADATA_V2 { /// /// A structure containing the signature of the report. The signature consists of the event name and event parameters present. /// public WER_REPORT_SIGNATURE Signature; /// /// A hash of the signature. Can be used to cross reference with other crash reports with the same signature (currently not implemented). /// public Guid BucketId; /// A locally unique identifier for the report. public Guid ReportId; /// A UTC time stamp of when the report was created. public FILETIME CreationTime; /// /// The size (on disk) of the individual report and its constituent files. This value only counts files directly contained in a report. /// public ulong SizeInBytes; /// [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)] public string CabId; /// The detailed status of the report. Use the ReportStatus decoder to track this bit-field. public uint ReportStatus; /// The integrator ID of the report. public Guid ReportIntegratorId; /// The number of data files included in the report. public uint NumberOfFiles; /// /// The total size of the file name fields, in count of WCHAR s, including the terminating character for each name and one /// more at the end of the record. /// public uint SizeOfFileNames; /// A pointer to hold the names of the files included in the report. It is in the format: FileName001\0FileName002\0\FileName003\0\0. public IntPtr _FileNames; /// The files included in the report. public IEnumerable FileNames => _FileNames.ToStringEnum(CharSet.Unicode, 0, (int)SizeOfFileNames); } [PInvokeData("werapi.h", MSDNShortId = "037170B1-B2DF-402F-A9E6-48C7693C9A93")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WER_REPORT_PARAMETER { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 129)] public string Name; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MAX_PATH)] public string Value; } [PInvokeData("werapi.h", MSDNShortId = "037170B1-B2DF-402F-A9E6-48C7693C9A93")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct WER_REPORT_SIGNATURE { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 65)] public string EventName; [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10)] public WER_REPORT_PARAMETER[] Parameters; } /// Provides a for that is disposed using . public class SafeHREPORT : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. /// /// to reliably release the handle during the finalization phase; otherwise, (not recommended). /// public SafeHREPORT(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } /// Initializes a new instance of the class. private SafeHREPORT() : base() { } /// Performs an implicit conversion from to . /// The safe handle instance. /// The result of the conversion. public static implicit operator HREPORT(SafeHREPORT h) => h.handle; /// protected override bool InternalReleaseHandle() => WerReportCloseHandle(handle).Succeeded; } /// Provides a for that is disposed using . public class SafeHREPORTSTORE : SafeHANDLE { /// Initializes a new instance of the class and assigns an existing handle. /// An object that represents the pre-existing handle to use. /// /// to reliably release the handle during the finalization phase; otherwise, (not recommended). /// public SafeHREPORTSTORE(IntPtr preexistingHandle, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) { } /// Initializes a new instance of the class. private SafeHREPORTSTORE() : base() { } /// Performs an implicit conversion from to . /// The safe handle instance. /// The result of the conversion. public static implicit operator HREPORTSTORE(SafeHREPORTSTORE h) => h.handle; /// protected override bool InternalReleaseHandle() { WerStoreClose(handle); return true; } } }