You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I gen code for the WER_REPORT_INFORMATION struct, the size returned by Marshal.SizeOf() is incorrect. I believe what's happening is it's treating the internal strings as 1-byte per char instead of 2-bytes per char, leading to a size ~50% what it should be.
Here's what's generated:
internalpartialstructWER_REPORT_INFORMATION{/// <summary>The size of this structure, in bytes.</summary>internaluintdwSize;/// <summary>A handle to the process for which the report is being generated. If this member is <b>NULL</b>, this is the calling process.</summary>internal win32.Foundation.HANDLE hProcess;/// <summary>The name used to look up consent settings. If this member is empty, the default is the name specified by the <i>pwzEventType</i> parameter of <a href="https://docs.microsoft.com/windows/desktop/api/werapi/nf-werapi-werreportcreate">WerReportCreate</a>.</summary>internal__char_64wzConsentKey;/// <summary>The display name. If this member is empty, the default is the name specified by <i>pwzEventType</i> parameter of <a href="https://docs.microsoft.com/windows/desktop/api/werapi/nf-werapi-werreportcreate">WerReportCreate</a>.</summary>internal__char_128wzFriendlyEventName;/// <summary>The name of the application. If this parameter is empty, the default is the base name of the image file.</summary>internal__char_128wzApplicationName;/// <summary>The full path to the application.</summary>internal__char_260wzApplicationPath;/// <summary>A description of the problem. This description is displayed in <b>Problem Reports and Solutions</b> on Windows Vista or the problem reports pane of the <b>Action Center</b> on Windows 7.</summary>internal__char_512wzDescription;/// <summary>A handle to the parent window.</summary>internal win32.Foundation.HWND hwndParent;
...}
When I call Marshal.SizeOf(reportInformation), it returns 1120.
When I try to call WerReportCreate with this struct, it returns E_INVALIDARG.
Expected behavior
The SizeOf call should return 2204 (or 2208 due to 8-byte packing).
Repro steps
NativeMethods.txt content:
WerReportCreate
NativeMethods.json content (if present):
Any of your own code that should be shared?
WER_REPORT_INFORMATIONreportInformation=default;
reportInformation.dwSize =(uint)Marshal.SizeOf(reportInformation);
reportInformation.hProcess =(HANDLE)IntPtr.Zero;
reportInformation.hwndParent =(HWND)IntPtr.Zero;"A functional problem was detected and logs were collected for further investigation.".AsSpan().CopyTo(reportInformation.wzDescription.AsSpan());"Diagnostic Tracing".AsSpan().CopyTo(reportInformation.wzFriendlyEventName.AsSpan());
Marshal.ThrowExceptionForHR(PInvoke.WerReportCreate(
eventType,
WER_REPORT_TYPE.WerReportCritical,
reportInformation,outnint reportHandle));
Context
CsWin32 version: 0.1.506-beta
Target Framework: .NET 6.0
The text was updated successfully, but these errors were encountered:
Actual behavior
When I gen code for the
WER_REPORT_INFORMATION
struct, the size returned byMarshal.SizeOf()
is incorrect. I believe what's happening is it's treating the internal strings as 1-byte per char instead of 2-bytes per char, leading to a size ~50% what it should be.Here's what's generated:
And here's the native struct:
When I call
Marshal.SizeOf(reportInformation)
, it returns 1120.When I try to call WerReportCreate with this struct, it returns E_INVALIDARG.
Expected behavior
The SizeOf call should return 2204 (or 2208 due to 8-byte packing).
Repro steps
NativeMethods.txt
content:NativeMethods.json
content (if present):Context
The text was updated successfully, but these errors were encountered: