So, supposing I have access to the registers of a program. I have access to esp, ebp and eip. eip is pointing to the next instruction that needs to be executed, ebp is pointing to another frame pointer and esp is pointing to the top of the stack. I understand this, however I don't understand the rest of the stack or how to parse it.
For example, if I would like to get the local variables of a frame, should I just subtract ebp - esp
(knowing that ebp
is a bigger address than esp
) and then go through those addresses and dereference them? Is this the proper way to get the local variables from that particular frame?
Another question, what would be the best way to figure out which function is related to each frame? If I subtract 1 to the ebp
address and then dereference that value, should I be getting the return address "0x804..."? What is the relationship between this address and the function? For example, if Foo() has a high pc address of 0x8045555
and a low pc address of 0x8045550
, is the return address that I would be getting going to be in between these addresses?
Thanks a lot in advanced and let me know if I wasn't clear enough..
NOTE: If someone has a better title suggest it, I didn't find a better one.