I'm playing with the stack and function's call parameters. What I want to achieve here is to get the value of variable parameters directly using the stack.
It works (or seems to work) fine when I don't use variable parameters. Here is what is working:
void test(int a, int b)
{
unsigned char *ptr;
int i;
ptr = (unsigned char*)&a;
for (i = 0; i < 4; i++)
{
printf("%d,", *ptr);
}
}
That works, I can retrieve the value of b; The same code using
void test(int a, ...);
as function's prototype doesn't work.
I cant understand what's going on here.
Can you help me? Thanks !
Edit: Ok, then it seeems there is no stable and reliable way to do that kind of stuff on my own. Lets say that in the callee function I know the data size (but not the type) of variable argument, is there a way to grab them ?