This question is similar to Print address of virtual member function
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.
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...).
Short sample:
class AClass
{
public :
virtual AFunction(){;}
};
typedef void (AClass::*FxPtr)( void );
[...]
AClass oAClass;
AClass* pSelf = &oAClass;
FxPtr pf = &AClass::AFunction;
DWORD nFctAddress = ???
Anyone has an idea how I can retrieve the address ?
&(pSelf->*pf)
gives 'error C2298: '&' : illegal operation on pointer to member function expression'
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 ?
Regards,
refs: