sylveon / member_thunk

Dynamically creates executable code to allow C callbacks to call C++ member functions without the need for a user data parameter
MIT License
13 stars 2 forks source link

x86 support #4

Closed sylveon closed 4 years ago

sylveon commented 4 years ago

What calling conventions should we support?

sylveon commented 4 years ago

__cdecl and __stdcall generate both

mov eax, {function}
mov DWORD PTR [esp-4], {this}
jmp eax

__vectorcall and __fastcall however generate

mov eax, {function}
mov ecx, {this}
jmp eax

Can use partial template specialization to use a single class to support all conventions.

__clrcall not supported because managed callers can use Marshal.GetFunctionPointerForDelegate. __thiscall not supported because it only applies to member functions to begin with.