Parameter passing methods
Posted: Wed Jan 09, 2008 9:07 am
I have always wondered about the most effective methods of passing parameters.
To begin with, is it right to pass, say 2 parameters through the stack with:
Then, once our function gets its result, is it right to get rid of these stack elements with the following?
What about for a variable number of parameters?
Another question is, wouldn't using the stack for parameter passing make some more vulnerable our kernel to stack overflows in case a serious nesting needs to take place?
Which other considerations to pass parameters are there? It's specially because having to handle each parameter with an inverse addressing into the stack seems to be very bloated, even more when one needs to push further elements, which of course will change the position of the passed parameters.
To begin with, is it right to pass, say 2 parameters through the stack with:
Code: Select all
push dword param2
push dword param1
Code: Select all
ret 2
Another question is, wouldn't using the stack for parameter passing make some more vulnerable our kernel to stack overflows in case a serious nesting needs to take place?
Which other considerations to pass parameters are there? It's specially because having to handle each parameter with an inverse addressing into the stack seems to be very bloated, even more when one needs to push further elements, which of course will change the position of the passed parameters.