Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variant Interop Bug #227

Open
weltkante opened this issue May 13, 2020 · 3 comments
Open

Variant Interop Bug #227

weltkante opened this issue May 13, 2020 · 3 comments

Comments

@weltkante
Copy link

While reviewing the WinForms implementation of VARIANT interop I was comparing with various implementations found on the web and I noticed you are treating VT_INT/VT_UINT as IntPtr/UIntPtr.

The resolution in the WinForms PR was that VT_INT/VT_UINT need to be 4 byte, even though the C/C++ headers are a bit ambigous the spec is clear and its also what native code is doing.

Just leaving you this as a note in case you want to fix your implementation.

dotnet/winforms#3197 (comment)

In the headers (wtypes.h) it is written up as such:

/*
...
 *  VT_INT              [V][T][P][S]  signed machine int
 *  VT_UINT             [V][T]   [S]  unsigned machine int
*/

But... things like VariantCopyInd() always treat them as a 4 byte value. This aligns with the MS-OAUT specification which states:

VT_INT:
Context Description
V, S, T Either the specified type, or the type of the element or contained field MUST be a 4-byte signed integer.

VT_UINT:
Context Description
V, S, T Either the specified type, or the type of the element or contained field MUST be a 4-byte unsigned integer.

@hughbe
Copy link

hughbe commented May 13, 2020

Also looking at documentation for PROPVARIANT (https://docs.microsoft.com/en-us/windows/win32/api/propidlbase/ns-propidlbase-propvariant)

VT_INT 22 intVal 4-byte signed integer value (equivalent to VT_I4).
VT_UINT 23 uintVal 4-byte unsigned integer (equivalent to VT_UI4).

@slozier
Copy link
Contributor

slozier commented May 13, 2020

Thanks for the report. It seems like .NET runtime has similar SetAsByref methods, would these also be incorrect?

@weltkante
Copy link
Author

Yes, I'll drop them a note as well. Thanks for the hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants