0

Im trying to detour a member function in a binary executable. I only know the function signature and the VA of the method. With the help of the 'method' sample, included in Detours Express 3.0, I came up with this:

class Detour
{
public:
    void mine_target(const char* text)
    {
        printf("text = %s\n", text);
        (this->*real_target)(text);
    }

    static void (Detour::*real_target)(const char* text);
};

void (Detour::*real_target)(const char* text) 
    = (void (Detour::*)(const char*))0x401010;

Which gives me the error:

error C2440: 'type cast' : cannot convert from 'int' to 'void (__thiscall Detour:: *)(const char *)'
             There are no conversions from integral values to pointer-to-member values
grasshopper
  • 31
  • 1
  • 2

1 Answers1

1

Techniques of intercepting/hooking functions won't work on pointers-to-members. Depending on your compiler and class design (inheritance structure), a number of additional bytes are needed to represent class data for such pointers - something not necessary with free function pointers.

Scott Jones
  • 2,880
  • 13
  • 19