VirtualBox

Changeset 106809 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Oct 31, 2024 2:37:43 PM (6 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165710
Message:

VBox/com/defs.h,Main/VirtualBoxErrorInfoImpl.h: Use uuidof(iface) instead of IID_##iface on windows to get interface IDs in VBOX_SCRIPTABLE_IMPL and friends to avoid trouble with IEventSource clashing with an interface known to Windows SDK's Uuid.lib. The library reordering in r165553 triggered this issue. jiraref:VBP-1253

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/com/defs.h

    r106061 r106809  
    563563// use this macro to implement scriptable interfaces
    564564#ifdef RT_OS_WINDOWS
    565 #define VBOX_SCRIPTABLE_IMPL(iface)                                          \
    566     public ATL::IDispatchImpl<iface, &IID_##iface, &LIBID_VirtualBox,        \
     565/* 2024-10-31 bird: Avoid using IID_xxxx here, because our IID_IEventSource is
     566   non-unique and defined differently by the the Windows SDK's Uuid.lib.  This
     567   manifested as 0x8002802b/TYPE_E_ELEMENTNOTFOUND trouble in vbox.py when
     568   setting up event listening for a newly started test VM.  The cause was a
     569   linking library reordering, causing the IID_IEventSource symbol to be picked
     570   from Uuid.lib rather than VBoxCOM.lib.
     571
     572   To work around this particular issue and avoid any future issues, we will
     573   switch to using the compiler builtin __uuidof() to get the interface ID. The
     574   compiler will create readonly variables with names using the UUID value
     575   itself, on the format _GUID_xxxxxxxx_xxxx_xxxx_xxxx_xxxxxxxxxxxx.  This will
     576   effectively eliminate any duplicate interface-name clashes with the system,
     577   provided nobody uses the IID_xxxx constants. */
     578# define VBOX_SCRIPTABLE_IMPL(iface) \
     579    public ATL::IDispatchImpl<iface, /*&IID_##iface*/ &__uuidof(iface), &LIBID_VirtualBox, \
    567580                              kTypeLibraryMajorVersion, kTypeLibraryMinorVersion>
    568581
    569 #define VBOX_SCRIPTABLE_DISPATCH_IMPL(iface)                                 \
     582# define VBOX_SCRIPTABLE_DISPATCH_IMPL(iface)                                \
    570583    STDMETHOD(QueryInterface)(REFIID riid, void **ppObj)                     \
    571584    {                                                                        \
    572         if (riid == IID_##iface)                                             \
     585        if (riid == /*IID_##iface*/ __uuidof(iface))                         \
    573586        {                                                                    \
    574587            *ppObj = (iface *)this;                                          \
     
    592605    }
    593606#else
    594 #define VBOX_SCRIPTABLE_IMPL(iface)                    \
     607# define VBOX_SCRIPTABLE_IMPL(iface) \
    595608    public iface
    596 #define VBOX_SCRIPTABLE_DISPATCH_IMPL(iface)
     609# define VBOX_SCRIPTABLE_DISPATCH_IMPL(iface)
    597610#endif
    598611
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette