Hi!
Suppose I have a program counter, and the thread context (Esp, Ebp, Eip etc.),
Can I get the frame pointer of the frame the PC belongs to somehow (in C++)?
thanks:)
Frame pointer + Program Counter
In general, no. Omitting the frame pointer is one of the more common optimizations performed in x86 code.
Quote:Original post by SiCrane
In general, no. Omitting the frame pointer is one of the more common optimizations performed in x86 code.
ok, but I'm talking about a program that runs in debug mode or does have frame pointers.
Quote:Original post by Sneftel
Conventionally, the frame pointer is EBP.
ok, and if I want to access the SECOND frame pointer directly (I have all the data from my first post), can I do it?
It's supposed to be stored somewhere too, right?
Often it's stored at the bottom of the stack frame, so EBP is pointing to it. But just like EBP being used as the frame pointer, that's by custom only. It doesn't matter to the calling convention, and AFAIK isn't defined by it. To the called function, even if it is going to use EBP as its frame pointer, EBP is just another register to be saved.
Quote:Original post by Sneftel
Often it's stored at the bottom of the stack frame, so EBP is pointing to it. But just like EBP being used as the frame pointer, that's by custom only. It doesn't matter to the calling convention, and AFAIK isn't defined by it. To the called function, even if it is going to use EBP as its frame pointer, EBP is just another register to be saved.
but the EBP points the top stack frame, doesn't it? I need the one below it...
Quote:Original post by IdovQuote:Original post by Sneftel
Often it's stored at the bottom of the stack frame, so EBP is pointing to it. But just like EBP being used as the frame pointer, that's by custom only. It doesn't matter to the calling convention, and AFAIK isn't defined by it. To the called function, even if it is going to use EBP as its frame pointer, EBP is just another register to be saved.
but the EBP points the top stack frame, doesn't it? I need the one below it...
It can point anywhere you please, it's merely a register whose purpose is to point to a stack location.
It often acts as a temporary, to save the current height of the stack. It is therefore set at the beginning of a function, and 'popped' at the end. The ESP is the current height of the stack (the position you're working at).
Quote:
It can point anywhere you please, it's merely a register whose purpose is to point to a stack location.
It often acts as a temporary, to save the current height of the stack. It is therefore set at the beginning of a function, and 'popped' at the end. The ESP is the current height of the stack (the position you're working at).
I think we have a little misunderstanding here. :)
I can only READ the data, I really don't want to change anything there.
Quote:Original post by IdovExactly. EBP is (often) saved at the base of the stack frame.
but the EBP points the top stack frame, doesn't it? I need the one below it...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement