很简单一段代码:
#import <substrate.h>
extern "C" CFTypeRef MGCopyAnswer(CFStringRef);
MSHook(CFTypeRef, MGCopyAnswer, CFStringRef key)
{
return _MGCopyAnswer(key);
}
%ctor
{
NSString *appID = [[NSBundle mainBundle] bundleIdentifier];
if ( appID && [appID isEqualToString:@"com.test.test"]) //这里的ID是演示用的,可自己修改成目标进程ID
{
NSLog(@"[test] %@ 开始, IOS版本: %.1f...", appID, kCFCoreFoundationVersionNumber);
MSHookFunction(MGCopyAnswer, MSHake(MGCopyAnswer));
}
}
MAKEFILE:
ARCHS = armv7 armv7s arm64
TARGET = iphone:latest:8.0
test2_FRAMEWORKS = UIKit
include theos/makefiles/common.mk
TWEAK_NAME = test2
test2_FILES = Tweak.xm
test2_LIBRARIES = MobileGestalt
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
install.exec "killall -9 SpringBoard"
不管在7系统还是8系统上面必然闪退,注释掉 MSHookFunction(MGCopyAnswer, MSHake(MGCopyAnswer)); 就没事了,求解~