3

I followed http://brandontreb.com/beginning-jailbroken-ios-development-building-and-deployment to make a tweak. but after i done successfully with the helloworld tweak.
I hook the fopen using MSHookFunction
and then i meet a linking error

Making all for tweak hw...
 Preprocessing Tweak.xm...
 Compiling Tweak.xm...
 Linking tweak hw...
Undefined symbols for architecture armv7:
  "_MSHookFunction", referenced from:
      global constructors keyed to Tweak.xm.mmin Tweak.xm.51941273.o
ld: symbol(s) not found for architecture armv7
collect2: ld returned 1 exit status
make[2]: *** [.theos/obj/hw.dylib.ba964c90.unsigned] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [hw.all.tweak.variables] Error 2

this is Tweak.xm

#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);
}

does anyone know how to fix it?

1 Answers1

0

You can try this:

#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);
}
Nikola C
  • 315
  • 1
  • 3
  • 11