Logos Official Address

Logos Official Address

Logos Official Address

An introduction to Logos syntax in common use

1. %hook Specify the name of the class that needs a hook, ending with %end.
%hook ViewController -(void)viewDidLoad{ %orig; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@" hint "message:@" I'm coming" Delegate :nil CancelButtonTitle :@" hello "otherButtonTitles:@" ok ", nil]; [alert show]; } %endCopy the code

Example code is to hook the viewDidLoad function of the ViewController class, perform the original operation, and then display the popbox.

2. %logUsed to printlogInput the information tosyslogIn the format% log ([(< type > < expr >,...)] ).
%hook ViewController -(void)viewDidLoad{ %orig; / / the original operation on % log ((nsstrings *) @ "iOSRE", (nsstrings *) @ "Debug"); } %endCopy the code
3. %origExecution ishookThe original code of the function, similar to super.methodFunction, if removed, the original code will not execute. You can also use this function to change the arguments of the original function:

%hook SBLockScreenDateViewController

-(void)setCustomSubtitleText:(id)arg1 withColor:(id)arg2{

%orig(@"hello I am hibo",arg2);

}

%end

Copy the code
4. %group
  1. This directive is used to group % hooks. %group is followed by the group name.

  2. The %group must also end with %end and can contain more than one %hook.

  3. All % hooks that didn’t belong to a custom group were implicitly grouped into the %group_ungrouped grouped.

5. %init

This directive is used to initialize a %group. A group cannot take effect until it is initialized. Init must be executed in a hook.

6. %ctor

Tweak constructor, used to initialize, if not explicitly defined, Theos will automatically generate a %ctor in which it calls %init(_ungrouped).

Ctor % {% init (_ungrouped)}.Copy the code
7. %dtor

Tweak constructor to do the finishing. If the definition is not displayed, Theos automatically generates a %dtor.

8. %new

This directive is used to add a new function to an existing class. Same as class_addMethod in Runtime.


%hook ViewController

%new

-(void)newMethod{

}

%end

Copy the code
9. %c

This directive is used to get the name of a class, similar to objc_getClass.

Using it directly will cause an error with make

-(void)btnClick{ %orig; // call a newMethod [[[ViewControlle alloc] init] newMethod]; }Copy the code

It should be used like this:


[[[%c(ViewController) alloc ] init] newMethod];

Copy the code

Ps: In the jailbroken phone, we can know the desktop program springboard. app of Apple device. After breaking the shell, we can get the corresponding header file of SpringBoard. From the header file we can roughly guess what the class and its methods are doing, so we can also change some of the other displays, change the desktop time text, color, battery status, power, of course, these may not be useful, we just use this way to further understand the reverse.


End