常用的HOOK方式

1、Method Swizzling

    Method originalMethod = class_getInstanceMethod([self class], originalSelector);
    Method swizzledMethod = class_getInstanceMethod([self class], swizzledSelector);
    
    BOOL didAddMethod =
    class_addMethod([self class],
                    originalSelector,
                    method_getImplementation(swizzledMethod),
                    method_getTypeEncoding(swizzledMethod));
    
    if (didAddMethod) {
        class_replaceMethod([self class],
                            swizzledSelector,
                            method_getImplementation(originalMethod),
                            method_getTypeEncoding(originalMethod));
    } else {
        method_exchangeImplementations(originalMethod, swizzledMethod);
    }

2、消息转发:Aspects

https://github.com/steipete/Aspects

3、通过fishhook:除了可以hook c函数,fishhook+汇编还可以hook objc_msgSend实现全打点.

https://github.com/facebook/fishhook

4、Cydia Substrate

5、通过libffi:饿了么开源的Stinger

https://github.com/eleme/Stinger

相关文章:

  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2021-12-15
  • 2021-06-04
  • 2022-12-23
猜你喜欢
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2021-09-03
  • 2022-12-23
  • 2021-05-14
相关资源
相似解决方案