dlr
dlr copied to clipboard
Variant Interop Bug
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.
https://github.com/dotnet/winforms/pull/3197#discussion_r423937631
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 theMS-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.
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). |
Thanks for the report. It seems like .NET runtime has similar SetAsByref methods, would these also be incorrect?
Yes, I'll drop them a note as well. Thanks for the hint.