c++ - Using DYLD interposing to interpose class functions -
i have succesfully using dyld -macosx- interpose standard c functions third party application, getting important information workarounds does. need replace function of class.
the function want override qstring::append(..., ..., ...), each time string appended -the whole application uses qstring-, find out.
is there way? here's code have.
// libinterposers.c #include <stdio.h> #include <stdint.h> #include <unistd.h> #include <fcntl.h> #include <stdarg.h> #include <dlfcn.h> #include <stdlib.h>  typedef struct interpose_s {     void *new_func;     void *orig_func; } interpose_t;  int my_open(const char *, int, mode_t); int my_close(int); void* my_malloc(size_t);  static const interpose_t interposers[] \     __attribute__ ((section("__data, __interpose"))) = {         { (void *)my_open,  (void *)open  },         { (void *)my_close, (void *)close },         { (void *)my_malloc, (void *)malloc },     };  int my_open(const char *path, int flags, mode_t mode) {     int ret = open(path, flags, mode);     printf("--> %d = open(%s, %x, %x)\n", ret, path, flags, mode);     return ret; }  int my_close(int d) {     int ret = close(d);     printf("--> %d = close(%d)\n", ret, d);     return ret; }  void* my_malloc(size_t size) {     void *ret = malloc(size);     //fprintf(stderr, "reserva de memoria");     return ret; }   thank much
c++ name mangling. means member function qstring::mid() looks __znk7qstring3mideii linker. run nm(1) command on library interposing on see symbols.
Comments
Post a Comment