我想调用MobileKeyBag库的MKBUnlockDevice函数.
先贴代码
extern "C" int MKBUnlockDevice(NSData* passcode, int flags);
%ctor{
NSString *passcode = [NSString stringWithFormat:@"%04d",1234];
NSData *data = [passcode dataUsingEncoding:NSUTF8StringEncoding];
int ret = MKBUnlockDevice(data,0);
NSLog(@"ret:%d",ret);
}
Marakfile文件
DataProtection_PRIVATEFRAMEWORKS = MobileKeyBag
这样编译的话会报错
Making all for tweak DataProtection...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Linking tweak DataProtection...
Undefined symbols for architecture armv7:
"_MKBUnlockDevice", referenced from:
_logosLocalCtor_e8d54f5f() in Tweak.xm.770c41e6.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [obj/DataProtection.dylib.ba964c90.unsigned] Error 1
make[1]: *** [internal-library-all_] Error 2
make: *** [DataProtection.all.tweak.variables] Error 2
我目前的解决办法是这样
int (*_MKBUnlockDevice)(NSData*,int) = (int(*)(NSData*,int))MSFindSymbol(NULL, "_MKBUnlockDevice");
问题:
私有库的C函数不能声明了之后直接调用吗,我使用公开库的C函数的话,是可以直接声明了直接调用的,不需要MSFindSymbol