Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ : Getting function virtual 'address' with member function pointer
    primarykey
    data
    text
    <p>This question is similar to <a href="https://stackoverflow.com/questions/3068144/print-address-of-virtual-member-function">Print address of virtual member function</a></p> <p>I would like to retrieve the memory location of a function (in runtime), using a member function pointer. The goal is to log them, and do a post-mortem analysis, using 'ln' in WinDbg to retrieve which function it was, using PDB symbols.</p> <p>I can't use stack walking since I am not yet into the function I want to log. (and I do not want to modify billions of functions to return me their address...).</p> <p>Short sample:</p> <pre><code>class AClass { public : virtual AFunction(){;} }; typedef void (AClass::*FxPtr)( void ); [...] AClass oAClass; AClass* pSelf = &amp;oAClass; FxPtr pf = &amp;AClass::AFunction; DWORD nFctAddress = ??? </code></pre> <p>Anyone has an idea how I can retrieve the address ?</p> <pre><code>&amp;(pSelf-&gt;*pf) </code></pre> <p>gives 'error C2298: '&amp;' : illegal operation on pointer to member function expression'</p> <p>I know that member function pointers are 'weird' structures, but since I know the 'this', is there a way to look-up the potentially virtual function from the vtable ?</p> <p>Regards,</p> <p>refs: </p> <ul> <li><a href="http://www.codeproject.com/kb/cpp/FastDelegate.aspx" rel="nofollow noreferrer">Member Function Pointers</a></li> <li><a href="http://blogs.msdn.com/b/oldnewthing/archive/2004/02/09/70002.aspx" rel="nofollow noreferrer">Pointers to member functions are very strange animals</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload