废话不多说~~~// 目标测试代码
#import
@interface PiaoPiao : NSObject
+(NSString *)GetRegName;
@end
@implementation PiaoPiao
+(id)GetRegName {
return @"PiaoPiao";
}
@end
int main(int argc, const char * argv[]) {
@autoreleasepool {
// insert code here...
NSLog(@"RegName=%@", [PiaoPiao GetRegName]);
}
return 0;
}// Hook代码
%config(generator=internal) // ★★加上这句★★
%hook PiaoPiao
+(id)GetRegName {
return @"Hooked!!!";
}
%end
%ctor {
NSLog(@"!!!!!!inject success!!!!!!!");
}
然后还要设置一下Xcode
编译后测试:
OK!又找到了熟悉的感觉有木有~~~