Address of function is not actual code address

Posted by mrjoltcola on Stack Overflow See other posts from Stack Overflow or by mrjoltcola
Published on 2010-03-21T00:35:05Z Indexed on 2010/03/21 0:41 UTC
Read the original article Hit count: 493

Filed under:
|
|

Debugging some code in Visual Studio 2008 (C++), I noticed that the address in my function pointer variable is not the actual address of the function itself. This is an extern "C" function.

int main() {
   void (*printaddr)(const char *) = &print; // debug shows printaddr == 0x013C1429

}

Address: 0x013C4F10
void print() {
  ...
}

The disassembly of taking the function address is:

   void (*printaddr)(const char *) = &print;
013C7465 C7 45 BC 29 14 3C 01 mov         dword ptr [printaddr],offset print (13C1429h) 

What am I missing?

© Stack Overflow or respective owner

Related posts about c++

Related posts about assembly