情景: 我用class-dump-z 解析出一个NSString的加密算法, 如:
@interface NSString (HMAC)
-(id)hexEncodedString;
@end
我们知道一般如果一个要hook一个类的方法,通常是在xxx.xm文件里
%hook AppDelegate
-(BOOL)application:(id)application didFinishLaunchingWithOptions:(id)options
{
%orig;
UIAlertView *alert = [UIAlertView alloc] initWithTitle:@"application" message:@"start" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
return YES;
}
%end
但是这里我这样写:
%hook NSString
-(id)hexEncodedString
{
id result = %orig;
UIAlertView *alert = [UIAlertView alloc] initWithTitle:@"hexEncodedString" message:result delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
return result;
}
%end
就log不出result来。google上搜了一下,好像都没有提到这种情况下该如何hook,希望在这里能得到解答。