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

  • SEARCH
  • Home
  • 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 6807733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:52:06+00:00 2026-05-26T19:52:06+00:00

How do I get the absolute address of a member function in C++? (I

  • 0

How do I get the absolute address of a member function in C++? (I need this for thunking.)

Member function pointers don’t work because I can’t convert them to absolute addresses (void *) — I need to know the address of the actual function in memory, not simply the address relative to the type.

  • 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-26T19:52:07+00:00Added an answer on May 26, 2026 at 7:52 pm

    There exists a syntax to get the address of the member function in MSVC (starting from MSVC 2005 IMHO). But it’s pretty tricky. Moreover, the obtained pointer is impossible to cast to other pointer type by conventional means. Though there exists a way to do this nevertheless.

    Here’s the example:

    // class declaration
    class MyClass
    {
    public:
        void Func();
        void Func(int a, int b);
    };
    
    // get the pointer to the member function
    void (__thiscall MyClass::* pFunc)(int, int) = &MyClass::Func;
    
    // naive pointer cast
    void* pPtr = (void*) pFunc; // oops! this doesn't compile!
    
    // another try
    void* pPtr = reinterpret_cast<void*>(pFunc); // Damn! Still doesn't compile (why?!)
    
    // tricky cast
    void* pPtr = (void*&) pFunc; // this works
    

    The fact that conventional cast doesn’t work, even with reinterpret_cast probably means that MS doesn’t recommend this casting very strongly.

    Nevertheless you may do this. Of course this is all implementation-dependent, you must know the appropriate calling convention to do the thunking + have appropriate assembler skills.

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

Sidebar

Related Questions

I need to get Absolute path to Folder in Assets. Some like this for
I need to get the absolute value of an NSDecimalNumber without loss of precision.
How can I consistently get the absolute, fully-qualified root or base url of the
How can I get the full/absolute URL (e.g. https://example.com/some/path ) in Django without the
How i can get absolute position of my object selected by autocomplete. When i
Pointers cannot be persisted directly to file, because they point to absolute addresses. To
I'm a little perplexed. How can I programmatically get the absolute URI to a
I have a web app and I need to get absolute path of a
in file.php : call()... How to get absolute path of file.php inside call() ?
How do you get the absolute value of a number in vb.net? Is there

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.