Todd A. Anderson wrote:
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:e79dv2$nov$1@news.datemas.de...
Todd A. Anderson wrote:
I have a function foo of which I need to get the address. The problem
is that when you say "&foo" (or just foo for that matter), you get the
address of this function's entry in a jump table and not the address
of the function itself. Are there any BKMs for getting the real
address or am I going to have to write a function that looks to see
whether the address is a jump instruction and if so compute the real
address from the jump target?
In C++ terms, when you say 'foo', you get a pointer to the function that
you can use to call it or compare it for equality with another pointer.
There is no other use for it. What would be your definition of the "real
address" and what are you going to do with it? Most likely, there is no
solution to your problem in terms of standard C++.
I believe that if the function is not declared static that all calls to that
function are made via a jump table and that this is how linking/loading
is done. In essence, I have to walk my own stack and determine if
I'm in a particular function and for that I need the real address of the
function and not the address of the jump instruction in the jump table.
The debugger has to do this as well but I need to do it manually. The
reason why is long, complex, and uninteresting. I already wrote a
function in case I needed it that looks at the code address and determines
if it is a jump instruction and if so computes the real function address.
Obviously, this function is architecture dependent which is something I'd
like to avoid but I guess I can't.
I assume you are talking about *member* functions. In general,
functions are not accessed by a jump table, but by direct call.