Theos tweak MSHookFunction

#import "substrate.h"

static FILE * (*s_orig_fopen) ( const char * filename, const char * mode );
static FILE * my_fopen ( const char * filename, const char * mode ){
    return s_orig_fopen(filename, mode);
}

static void entry(void)  __attribute__ ((constructor));
static void entry(void) {
    MSHookFunction(fopen, my_fopen, &s_orig_fopen);
}

OR

#import "substrate.h"

static FILE * (*s_orig_fopen) ( const char * filename, const char * mode );
static FILE * my_fopen ( const char * filename, const char * mode ){
    return s_orig_fopen(filename, mode);
}

%ctor {
    MSHookFunction(fopen, my_fopen, &s_orig_fopen);
}
原文地址:https://www.cnblogs.com/qq378829867/p/4150604.html