2

I have heard that there is a %group feature in theos. From what I have understood about this I guess it is for applying lots of hooks if a condition is set true or when you want to easily enable or disable it instead of using if(). Is what I am saying true? And how can I use this feature if a condition is met? Please help me as I really need this feature as i have lots of ifs and else in my code and it would be a lot easier to just use %group instead of all that! Any advice is greatly appreciated!

iHackerMe
  • 581
  • 2
  • 5
  • 17

2 Answers2

2

I found an answer;

  1. You can use %group thegroupname before a %hook but remember to put two %end's after.
  2. In your %ctor you can call %init(thegroupname); when needed.

Hope this helps someone! Btw, the %init() function can be used anywhere, even inside %hook.

%group MessagesApp

%hook CLASS_TO_HOOK

- (id)FUNC_TO_HOOK {
    return %orig;
}

%end

%end //Don't forget your second end.

%ctor {
    if (TRUE) {
        %init(MessagesApp);
    }
}
Johann Burgess
  • 580
  • 6
  • 17
iHackerMe
  • 581
  • 2
  • 5
  • 17
0

Adding answer to further clarify, use like this:

%group iOS8
   %hook IOS8_SPECIFIC_CLASS
          // your code here
   %end // end hook
%end // end group ios8

%group iOS9
   %hook IOS9_SPECIFIC_CLASS
          // your code here
   %end // end hook
%end // end group ios9


%ctor {
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0) {
        %init(iOS9);
    } else {
        %init(iOS8);
    }
}
Wolf
  • 991
  • 1
  • 9
  • 12