1

Good morning,

Is it possible, using dyld interposition feature, to interpose this kind of C function ? 

typedef struct aStructure {
    IOReturn (*aCfunction)(void *self, UInt32 integer); // self is a 
                                                        // pointer to aStructure
} aStructure;

How the function is called:

aStructure **myStruct = ......;

(*myStruct)->aCfunction(myStruct, 1);
hmjd
  • 120,187
  • 20
  • 207
  • 252
b1onic
  • 239
  • 2
  • 14
  • have you figured this out? i have similar question: https://stackoverflow.com/questions/53535716/interpose-c-struct-function-pointer-macos – danylokos Nov 29 '18 at 09:30

1 Answers1

0

Probably only possible if you can figure out where the actual function is, and interpose that.

There will be code to initialize the function pointer field in the structure to point at an actual function and I guess that's where you need to change things.

Also, you calling line is slighly off, it needs to be

(*myStruct)->aCfunction(*myStruct, 1);
unwind
  • 391,730
  • 64
  • 469
  • 606
  • after some gdb magic, it appears that these C function pointers are wrappers for C++ methods. It's going to be easier now. Nonetheless, I'm right about the function call (I follow Apple docs ) – b1onic Aug 24 '12 at 19:38