This is probably a very basic question. I've read about canaries, and how they work in theory. You have a global variable that you set to a random number in the prolog of a function, do your function, and then verify its authenticity in the epilog.
void foobar(int a, int b)
{
prolog();
int c = a;
int d = b;
char *buffer[40];
strcpy(stupidcopy);
epilog();
}
What I don't understand is, how do I place something on the stack in prolog? Like, if I call prolog, and tell it to save a local variable, it'll be on stack, but when we get out of prolog(), won't it be popped? How can I save the canary on stack? Do I need to modify esp using assembly code to do this?