Let's say I have the class definition:
class MyType
{
public:
doSomething(int nNumber, char *szText);
}
I want to create the typedef to have a pointer to that function. However, that function requires use of the this pointer. Where is the this pointer situated, and does it depend on the calling convention?
typedef (* pDoSomethingFunc)(int, char*, MyType*) PDSFUNC;
typedef (* pDoSomethingFunc)(MyType*, int, char*) PDSFUNC;
Or is it something else?
AFAIK you can't really have a pointer to a non-static member function; the compiler won't let you. If you want to try to hack it, though, member functions using thiscall pass the pointer in ecx and member functions using the c calling convention (which you really only need on member functions if you want to use varargs) pass it as an extra parameter.
class MyType
{
public:
int doSomething(int nNumber, char *szText);
};
typedef int (MyType::* PDSFUNC)(int, char*);
...
MyType* bleh;
PDSFUNC p;
int a;
char* b;
...
(bleh->*p)(a, b);
I keep this in Misc.txt because it's hard to remember. Enjoy. :)
Thanks Yoni!