On Feb 21, 9:13 pm, jameschen <wengerm...@gmail.com> wrote:
> The question is that why ebp-12 is the "this" pointer, how to how?
Like Red said it's implementation-specific. However, many compilers
that I've seen implement class member functions by passing a pointer
to the instance data ("this") to the member functions as a "hidden"
parameter. Similar (sort of) to doing, say, this:
struct Something {
int data;
};
void SomeMemberFunction (Something *s, int param) {
s->data = param;
}
In order to emulate this:
class Something {
int data;
void SomeMemberFunction (int param) {
data = param;
}
};
And so the "this" pointer is passed as a parameter to the member
function on the stack; since that info needs to be available inside
the member function.
Again, that's implementation specific, that's only a general summary,
AFAIK there's nothing standardized about that. I wouldn't rely on it
being at EBP-12 even with the same compiler. It may also depend on
compiler options used, the number of other parameters the function
takes, the calling convention, and many other things that you can't
rely on.
Red Floyd wrote:
> Why do you want to know?
Yes; unless you are just trying to satisfy your curiosity, if you are
considering doing something strange you may want to consider other
simpler methods before doing whatever it is you are doing.
Jason