vendredi 8 mai 2020

How to call a function with types known at runtime

After loading a dynamic library and GetProcAddress, one typically get a function pointer of type void*. To call the function, when doing it at compile time, one would cast the pointer into the correct pointer type needed.

However, if the type is not known at compile time but at runtime instead, and there's many possibilities of the type. In this scenario, it seems one would need to "Call" the function manually, aka, update the stack and registers according to the ABI.

The question is: Is there any open source code that takes care of this in common platforms and ABI? If not, how do I implement one myself?

The Microsoft abi documentations have some things on the cdecl and other conventions, and it seems 32bit and 64bit are different. Is ABI on Linux the same or something else?





Aucun commentaire:

Enregistrer un commentaire