Got it

Yes, I found an interesting solution to using different calling conventions dynamically inside the program:

void a() {}

int main() {
void (*myfunc)(void) __attribute__((stdcall));
myfunc = a;

You effectively declare your function pointers and add the special __attribute__ notation to mark a specific flag used by the compiler. In case of calling conventions, you can simply add the desired convention as a word. Replacing the "stdcall" convention with "cdecl" does give no warning (opposed to the code above), since cdecl is the standard C calling convention. Quite interesting, indeed. So what's still left is to figure out how to pass parameters based on C code. I thought about exploiting variadic parameters, but these require atleast one other parameter. Too bad! As of standard cdecl calls, this is the only way to randomly put stuff on the stack. Shit. *sigh* Ok, it seems that this idea totally sucks and that I don't really know how figure out a solution without leaving C. Fuck it, seriously. Maybe writing the bytecode executer completely using assembler? This would limit me to a single architecture in the beginning. But atleast I'd be able to code them without problems.

Hmpf. Stuck again. I better really leave this for a few days.

No comments: