关闭

Hooking 学习1

712人阅读 评论(0) 收藏 举报
#import <objc/runtime.h>

 

typedef void (*UIWebView_loadRequest__IMP)(UIWebView* self, SEL _cmd, NSURLRequest *request);

static UIWebView_loadRequest__IMP original_UIWebView_loadRequest;

void replaced_UIWebView_loadRequest(UIWebView* self, SEL _cmd, NSURLRequest *request){
    
    original_UIWebView_loadRequest(self, _cmd, request);
    
    
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"提示信息"
                          message:@"成功"
                          delegate:self
                          cancelButtonTitle:nil
                          otherButtonTitles:@"确定", nil];
    [alert show];
    // TODO:
    
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
   
    Method method = class_getInstanceMethod(NSClassFromString(@"UIWebView"), @selector(loadRequest:));
    
    original_UIWebView_loadRequest = method_setImplementation(method, replaced_UIWebView_loadRequest);
    
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
    return YES;
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:106456次
    • 积分:2084
    • 等级:
    • 排名:第19037名
    • 原创:88篇
    • 转载:121篇
    • 译文:0篇
    • 评论:6条
    最新评论