Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 460585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:53:18+00:00 2026-05-12T22:53:18+00:00

ATL provides a bunch of macros for creating so-called COM maps – chains of

  • 0

ATL provides a bunch of macros for creating so-called COM maps – chains of rules of how the QueryInterface() call behaves on a given object. The map begins with BEGIN_COM_MAP and ends with END_COM_MAP. In between the the following can be used (among others):

  • COM_INTERFACE_ENTRY, COM_INTERFACE_ENTRY2 – to ask C++ to simply cast this class to the corresponding COM interface
  • COM_INTERFACE_ENTRY_FUNC – to ask C++ to call a function that will retrieve the interface

Now the problem is I want to use COM_INTERFACE_ENTRY_FUNC for every interface I expose so that I can log all the calls – I believe it will help me debugging my component when it is deployed in the field. The implementation of CComObjectRootBase::InternalQueryInterface contains an ATLASSERT:

ATLASSERT(pEntries->pFunc == _ATL_SIMPLEMAPENTRY);

which implies that the following is allright:

BEGIN_COM_MAP
    COM_INTERFACE_ENTRY( IMyInterface1 )
    COM_INTERFACE_ENTRY_FUNC( __uuidof(IMyInterface2), 0, OnQueryMyInterface2 )
END_COM_MAP

since here the first entry results in _ATL_SIMPLEMAPENTRY type entry but the following is not:

BEGIN_COM_MAP
    COM_INTERFACE_ENTRY_FUNC( __uuidof(IMyInterface1), 0, OnQueryMyInterface1 )
    COM_INTERFACE_ENTRY_FUNC( __uuidof(IMyInterface2), 0, OnQueryMyInterface2 )
END_COM_MAP

since here the entry type will not be _ATL_SIMPLEMAPENTRY.

This makes no sense at all. Why am I enforced into having a “please, C++, do the static_cast” entry as the first entry of the COM map?

Upd: Resolved after many more hour of debugging, answer added.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:53:18+00:00Added an answer on May 12, 2026 at 10:53 pm

    Inside ATL there’s AtlInternalQueryInterface() that actually does scan the COM map. Inside it there’s this code:

    if (InlineIsEqualUnknown(iid)) // use first interface
    {
        IUnknown* pUnk = (IUnknown*)((INT_PTR)pThis+pEntries->dw);
        // call AddRef on pUnk, copy it to ppvObject, return S_OK
    }
    

    this code actually relies on the first entry of the table being of _ATL_SIMPLEMAPENTRY type since it expects that _ATL_INTMAP_ENTRY::dw stores an offset from the current object this pointer to the necessary interface. In the use cited in the question if the first entry is this one:

    COM_INTERFACE_ENTRY_FUNC( __uuidof(IMyInterface1), 0, OnQueryMyInterface1 )
    

    the entry will be of wrong type, but the _ATL_INTMAP_ENTRY::dw will be zero (second parameter to the macro) and the code will happily work each time returning this pointer as IUnknown*. But if the second macro parameter which corresponds to a pass this value into the function specified as the third parameter variable is not zero the program will use that value as the offset and could run into undefined behaviour.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 246k
  • Answers 246k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This would probably be easier to just create a DataTable,… May 13, 2026 at 8:33 am
  • Editorial Team
    Editorial Team added an answer You're setting the attribute value with an expression, not a… May 13, 2026 at 8:33 am
  • Editorial Team
    Editorial Team added an answer I don't think so. The Google App Engine secure sandbox… May 13, 2026 at 8:33 am

Related Questions

ATL provides a bunch of macros for creating so-called COM maps - chains of
or a VB6 - compatible - collection object. We provide hooks into our .net
I have a 3rd party DLL that needs to be loaded dynamically using LoadLibrary()
I'm at a loss to explain what seems to be mis-addressing within the char[]
I'm trying to force an existing native C++ ATL in-proc COM server into a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.