IOS Reverse development – Simple instructions for theOS installation and configuration

Add a few notes to theOS usage, feeling that much of the information on reverse-engineering on the web is old. Hope that just learn reverse friends can have some reference things.

Configure the Makefile

  • To create the TheOS project, the first step is to configure the Makefile
  1. Configuring environment Variables

Since each project uses the environment variables connected to the phone, you can put the environment variables in the ~/.zprofile file

Command: Open ~/. Zprofile // Configure IP addresses and ports in the. Zprofile file export THEOS_DEVICE_IP = localhost export THEOS_DEVICE_PORT = 10010 source ~/.zprofileCopy the code

There is no need to configure environment variables to connect to the phone in the Makefile.

  • Much of the configuration used in development is done in makefiles
ARCHS = armv7 arm64 // Specify the architecture // import the dynamic library project_FRAMEWORKS = dynamic library project_PRIVATE_FRAMEWORKS = private dynamic libraryCopy the code

I tried to import UIKit, but the frameworks I saw on the web used _FRAMEWORKS, but in my project I was unable to read UIKit, and the compilation failed

_PRIVATE_FRAMEWORKS was successfully imported using _PRIVATE_FRAMEWORKS

wechattweak_PRIVATE_FRAMEWORKS = UIKit


Development and resource import

  • Online is very classic to add two cells to wechat, according to the previous look at the demo, a bunch of errors, basically is OC object type can not be compiled, and the import UIKit problem made a head of garble, finally successfully compiled and installed. Post the code for your reference. Because I just started to learn this, if you find any mistakes or better solutions, please do help to point out, thank you.
tweak.x
#import <UIKit/ uikit. h> I'm going to import #define FRUSERDEFAULTS [NSUserDefaults standardUserDefaults] #define FRWeChatPath(Path) @ "/ Library/PreferenceLoader/Preferences/FRWeChat/" # path % hook FindFriendEntryViewController / / import need to hook controller / / statement about the class, To use the self @ interface FindFriendEntryViewController / / declare the method, Self calls the method to compile - (long long) numberOfSectionsInTableView tableView: (id); @ the end / / orig said keep the implementation of the original method (long long) numberOfSectionsInTableView: (id) tableView {return orig % + 1; } - (long long)tableView:(id)tableView numberOfRowsInSection:(long long)section { if (section ! = [self numberOfSectionsInTableView:tableView] - 1) { return %orig; } return 2; } - (id)tableView:(id)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section ! = [self numberOfSectionsInTableView:tableView] - 1) { return %orig; } NSString *addCellID = (indexPath.row == 0) ? @"autoCellID" : @"exitCellID"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:addCellID]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:addCellID];  cell.backgroundColor = [UIColor whiteColor]; cell.imageView.image = [UIImage imageWithContentsOfFile:FRWeChatPath(skull.png)]; } if (indexPath. Row == 0) {cell.textlabel.text = @" "; UISwitch *st = [[UISwitch alloc] init]; st.on = [FRUSERDEFAULTS boolForKey:@"fr_Switch_key"]; [st addTarget:self action:@selector(clickSt:) forControlEvents:UIControlEventValueChanged]; cell.accessoryView = st; }else if (indexPath. Row == 1){cell.textlabel.text = @" "; } return cell; } - (double)tableView:(id)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section ! = [self numberOfSectionsInTableView:tableView] - 1) { return %orig; } return 44; } - (void)tableView:(id)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.section ! = [self numberOfSectionsInTableView:tableView] - 1) { %orig; return; } [tableView deselectRowAtIndexPath:indexPath animated:YES]; if (indexPath.row) { // exit(0); // Abort (); %new - (void)clickSt:(UISwitch *)st{[FRUSERDEFAULTS setBool:st.isOn forKey:@"fr_Switch_key"]; [FRUSERDEFAULTS synchronize]; } %endCopy the code
  • Compared with the previous online demo, there are three more steps
  1. You need to import UIKit in your Makefile
  2. Import UIKit in your code
  3. To call a method using self, you need to declare the class and the called method to compile
Resources to introduce
  • If you want to use a file like an image to import
  1. Create a Layout folder and place it at the root of your project

  2. Path description for reading resources:

If the file is placed in Layout, the file will be placed in the ~(home) directory of the phone when installed on the phone

Equivalent to layout is the root directory, read the file relative to layout read down can be

Instead of placing files directly into Layout, create folders to separate resources

For example, the image in the example above

Path:

/layout/Library/PreferenceLoader/Preferences/FRWeChat/skull.png

Read:

[UIImage imageWithContentsOfFile:@"/Library/PreferenceLoader/Preferences/FRWeChat/skull.png"];