Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

The introduction

Yesterday, I explained how to set up a private Cydia source to deploy plug-ins in bulk. Today, I’ll talk about how to merge independent tweak into the same deb.

I. Tweak standalone files to the same deb

When setting up a private Cydia source, I found that the deb package had a very simple directory structure, which led to the idea of merging multiple tweaks.

A DEB package is essentially a compressed file that contains specific directories and files.

The DPKG will copy all files and directories in the layout directory, which is the root directory of the device.

  1. To merge tweak into the same deb package, simply adddylibAnd the correspondingplistPut the file in the Layout directory.
 5 files changed, 3 insertions(+), 1 deletion(-)
 create mode 100755 Layout/Library/MobileSubstrate/DynamicLibraries/SBLockScreenViewController.dylib
 create mode 100644 Layout/Library/MobileSubstrate/DynamicLibraries/SBLockScreenViewController.plist

Copy the code
  1. Make %init group according to processName in %ctor

%ctor must be placed last, otherwise the group cannot be found

%ctor
{
	if[[[[NSProcessInfo processInfo] processName] isEqualToString:@"knWeChat"])
		%init(wxHook);

	if[[[[NSProcessInfo processInfo] processName] isEqualToString:@"SpringBoard"])
		%init(sbHook);
}




Copy the code

II. Fundamentals: Logos Grammar

2.1 %ctor

  1. Tweak constructor to do the initialization If the definition is not shown, Theos automatically generates a %ctor and calls %init(_ungrouped) init.

  2. %ctor can be used to initialize % groups and perform operations such as MSHookFunction

2.2% of the group

  1. This directive is used to group % hooks for easy code management and conditional initialization, and must end with %end.

  2. A % group can contain multiple % hooks. All % hooks that didn’t belong to a custom group were implicitly grouped into the % group_ungrouped grouped.

2.3 %init

This directive is used to initialize a % group and must be called within %hook or % ctor; If there is an argument, the specified group is initialized. If there is no argument, _ungrouped is initialized.

The corresponding %group will only work if % init is called!

2.4% of the property

If you want to use global variables, I recommend you try this familiarity.

  1. Add a property to a %subclass just like you would with @property to a normal Objective-C subclass as well as adding new properties to existing classes within %hook.

  2. %property (nonatomic|assign|retain|copy|weak|strong|getter|setter) Type name;

2.5% ttf_subclass

  1. Subclass block – the class is created at runtime and populated with methods. ivars are not yet supported (use associated objects).

  2. The %new specifier is needed for a method that doesn’t exist in the superclass. To instantiate an object of the new class, you can use the %c operator.

  3. Can be inside a %group block.

see also

For more, check out # Applets: iOS Reverse, which presents valuable information only for you, focusing on the mobile technology research field.