Logos

作者: king_jensen | 来源:发表于2018-12-31 21:23 被阅读10次

    Logos语法其实是CydiaSubstruct框架提供的一组宏定义。便于开发者使用宏进行HOOK操作。语法简单,功能强大且稳定。

    Logos语法

    Logos语法分为三大类:

    Block level

    这一类型的指令会开辟一个代码块,以%end结束。
    %group、%hook、% subclass 、 %end

    Top level

    这个TopLevel指令不放在BlockLevel中。
    %config、%hookf、%ctor、%dtor

    Function level

    这一块的指令就放在方法中。
    %init、%class、%c、%orig、%log

    Logos使用

    #import <UIKit/UIKit.h>
    
    @interface ViewController:UIViewController
    
    + (void)JN_HOOK;
    
    @end
    
    %group group1
    %hook ViewController
    
    - (void)click:(id)sender {
        NSLog(@"group1");
        %orig;
    }
    
    %new
    - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
        NSLog(@"点击屏幕");
        [%c(ViewController) JN_HOOK];
    }
    %new
    + (void)JN_HOOK {
         %log;
         NSLog(@"类方法");
    }
    %end
    %end
    
    %group group2
    %hook ViewController
    - (void)click:(id)sender {
    NSLog(@"group2");
    }
    %end
    %end
    
    %ctor {
        if([UIDevice currentDevice].systemVersion.doubleValue >= 11) {
            %init(group1);
        }else {
            %init(group2);
        }
    }
    

    相关文章

      网友评论

          本文标题:Logos

          本文链接:https://www.haomeiwen.com/subject/qgywlqtx.html