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
The VirtualQueryEx method's 3rd parameter is MEMORY_BASIC_INFORMATION* and is not an array. Per the docs, only one struct is expected.
But the metadata attributes it with [NativeArrayInfo(BytesParamIndex = 3)] as if it were an array, leading to CsWin32 projecting it as Span<MEMORY_BASIC_INFORMATION>.
The 4th parameter is supposed to be the length of the struct (just one of them). Capturing this with an attribute (similar to NativeArrayInfo but without the array implication) would allow projections to drop the 4th parameter and auto-fill with the calculated size of the struct, as we're doing now while incorrectly treating it like an array.
The text was updated successfully, but these errors were encountered:
Searching the metadata for other uses of BytesParamIndex I ran across ReadCabinetState which also is incorrectly tagged with an array parameter that is actually a single struct, just like VirtualQueryEx's case.
Same for SHGetFileInfoA and SHGetFileInfoW.
The only valid cases of BytesParamIndex I have found so far is for void* and byte* parameters. Which suggests maybe a pattern the header parser can use to detect whether the pointer parameter really is an array or not.
It seems like if I find I need to use BytesParamIndex, I should use a different attribute that just means how big in bytes the pointer points to. That would work for any types, including MEMORY_BASIC_INFORMATION*, void*, and byte*.
The
VirtualQueryEx
method's 3rd parameter isMEMORY_BASIC_INFORMATION*
and is not an array. Per the docs, only one struct is expected.But the metadata attributes it with
[NativeArrayInfo(BytesParamIndex = 3)]
as if it were an array, leading to CsWin32 projecting it asSpan<MEMORY_BASIC_INFORMATION>
.The 4th parameter is supposed to be the length of the struct (just one of them). Capturing this with an attribute (similar to
NativeArrayInfo
but without the array implication) would allow projections to drop the 4th parameter and auto-fill with the calculated size of the struct, as we're doing now while incorrectly treating it like an array.The text was updated successfully, but these errors were encountered: