Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>#include &lt;stdio.h&gt; struct Class { virtual void AFunction( void ) { printf("1"); } }; struct AClass : public Class { virtual void AFunction( void ) { printf("2"); } }; typedef void (AClass::*FxPtr)(void); int main( void ) { union { FxPtr pf; int rf[2]; }; pf = &amp;AClass::AFunction; printf( "sizeof(pf)=%i\n", sizeof(pf) ); printf( "%08X\n", pf ); printf( "%08X %08X\n", rf[0], rf[1] ); /* error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function. Say '&amp;AClass::AFunction' AClass a; FxPtr qf = &amp;a.AFunction; printf( "sizeof(qf)=%i\n", sizeof(qf) ); */ }; </code></pre> <p>Its easy to access vtable, but not so simple to identify the function by its address.<br> Some options:<br> 1) Parse the .map file, load, and look up the class name by typeid (or by VMT instance from map), then function address by its name.<br> 2) Write a static function calling a given virtual method for given object, see how it looks in asm, and retrieve the function's offset in vtable from its code, then read the address<br></p> <pre><code>?adr_CFunction@Class@@SIXPAU1@@Z PROC ; Class::adr_CFunction, COMDAT ; _This$ = ecx ; 8 : static void adr_CFunction( Class* This ) { This-&gt;CFunction(); } mov eax, DWORD PTR [ecx] mov edx, DWORD PTR [eax+8] jmp edx ?adr_CFunction@Class@@SIXPAU1@@Z ENDP ; Class::adr_CFunction </code></pre> <p>3) There're nifty options like "/Gh enable _penter function call", which allow to retrieve addresses of all functions, after the call though, but before the function actually does anything. Then .map can be used to identify the function by the trace.<br></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload