Get a Pointer to a Memberfunction





1.00/5 (1 vote)
This shows you how to cast a Pointer to a Memberfunction to any Pointer Type you whish.
In my actual project, I needed a way to get a
void*
to a Memberfunction
but the compiler would just throw cast errors at me. So I just used the way in which the compiler implemented these calls.
void* p; __asm MOV eax,offset MyClass::MyFunction __asm MOV p,eaxor as Macro:
#define MEMBERPTR(f,v) __asm MOV eax,offset f \ __asm MOV v,eaxThis will give you the correct address of virtual and normal member functions. Tested on MSVC++ 2008. Might be different on other Compilers!