https://github.com/alexzielenski/ZKSwizzle
和theos一样好用啊,哈哈~~~
// // main.m // ZKSwizzle_Test // // Created by piaoyun on 2016/10/10. // Copyright © 2016年 chinapyg. All rights reserved. // #import <Foundation/Foundation.h> @interface TRegisterClass : NSObject + (NSString *)getRegName; + (NSString *)getRegCode; @end @implementation TRegisterClass + (NSString *)getRegName { return @"WwW.ChinaPYG.CoM"; } + (NSString *)getRegCode { return @"88888888"; } @end int main(int argc, const char * argv[]) { @autoreleasepool { // insert code here... NSLog(@"RegName: %@", [TRegisterClass getRegName]); NSLog(@"RegCode: %@", [TRegisterClass getRegCode]); } return 0; }
// // inject.m // inject // // Created by piaoyun on 2016/10/10. // Copyright © 2016年 chinapyg. All rights reserved. // #import "ZKSwizzle.h" @interface TRegisterClass : NSObject + (NSString *)getRegName; + (NSString *)getRegCode; @end // 应用方法1 #if 0 hook(TRegisterClass) + (NSString *)getRegName { return [ZKOrig(NSString *) stringByAppendingString:@" Hooked!!"]; } + (NSString *)getRegCode { return [ZKOrig(NSString *) stringByAppendingString:@" Hooked!!"]; } endhook #endif // 应用方法2 ZKSwizzleInterface($_Piao_TRegisterClass, TRegisterClass, NSObject); @implementation $_Piao_TRegisterClass + (NSString *)getRegName { return [ZKOrig(NSString *) stringByAppendingString:@" Hooked!!"]; } + (NSString *)getRegCode { return [ZKOrig(NSString *) stringByAppendingString:@" Hooked!!"]; } @end
发表评论