Is it possible to call a function and store its return value in the next stack frame?


call foo(); // int foo();
store return value of foo in next stack frame;
call bar(int);

1 Answer 1


You certainly can do such a thing if you control where the values are pushed into the stack, which I guess it's not the case.

If you don't, then it depends on the code of both foo and bar, as they are the ones executing the code. If they are properly written they should be independent and you can't do it.

You can however try to find gadgets which allow you to access the already pushed return value of foo() and try to copy it to the proper place before calling bar().

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .