Skip to content

Latest commit

 

History

History
233 lines (209 loc) · 12.7 KB

flex_explained.md

File metadata and controls

233 lines (209 loc) · 12.7 KB

How Do You Create a Tweak?

Why Should We Know About FLEX?

FLEX makes it significantly easier to debug your tweak, look through different classes and their properties without dumping their headers, and a whole lot more.

FLEX's Menu

Menu Tab
> --- Process and Events --- <

📡 Network History
Shows the network history of the device.
⚠ System Log
Similar to the Console app on macOS, shows logs from os_log/NSLog.
🚦 NSProcessInfo.processInfo
Shows information about the current process.
💩 Heap Objects
Allows the finding of objects which are currently in the heap.
🔎 Address Explorer
Allows the user to find objects at certain memory addresses. For example, a memory address could be 0x03a61efb and it would store an object. This object's methods could then be hooked for the desired outcome.
📚 Runtime Browser
Allows the user to browse the Objective-C runtime. Extremely useful if one wants to find classes, methods, etc. in there.

Keyboard Button: *
Allows the selection of specific dylibs and frameworks to browse.
Keyboard Button: *.
Allows the user to browse specific class names in the runtime.
> ---- App Shortcuts ---- <

📁 Browse Bundle Directory
Allows the user to browse the contents of the current NSBundle. Contents may include .plist files, images, localizations, etc.
📁 Browse Container Directory
Allows the user to browse the contents of the current NSBundle container, e.g. /var/mobile/Containers/Data/Application/container_id.
📦 NSBundle.mainBundle
Allows the user to look at information about the NSBundle in the current app.
💾 Preferences
Allows the user to look at the NSUserDefaults of the current app.
🔑 Keychain
Shows the keychain for the current app.
🚀 UIApplication.sharedApplication
Gives access to methods, properties, etc from UIApplication through it’s sharedApplication’s singleton.
🎟️ App Delegate
Gets the current app delegate.
🔑 Key Window
Fetches the current key window.
🌴 Root View Controller
Fetches the current root view controller.
🍪 Cookies
Gets the cookies in the current app.
> ---- Miscellaneous ---- <

📋 UIPasteboard.generalPasteboard
Gets the current clipboard. The current pasteboard is UIPasteboard's generalPasteboard property.
💻 UIScreen.mainScreen
Shows information about the primary screen instance of UIScreen for the device.
📱 UIDevice.currentDevice
Shows information about the current device.
📡 NSURLSession.sharedSession
Shows information about the current instance of __NSURLSessionLocal.
⏳ NSURLCache.sharedURLCache
Gets information about NSURLCache.
🔔 NSNotificationCenter.defaultCenter
Fetches the instance of NSNotificationCenter.
📎 UIMenuController.sharedMenuController
Fetches information about the current UIMenuController.
🗄️ NSFileManager.defaultManager
Gets the current NSFileManager.defaultManager instance.
🌎 NSTimeZone.systemTimeZone
Gets the current timezone, stored in the NSTimeZone class
🗣️ NSLocale.currentLocale
Gets the current instance of NSLocale.
📆 NSCalendar.currentCalendar
Gets the current instance of the calendar, stored in the NSCalendar class.
🏃 NSRunLoop.mainRunLoop
Gets the current NSRunLoop.
🧵 NSThread.mainThread
Gets the current thread in the NSThread class.
📚 NSOperationQueue.mainQueue
Gets the current main queue for NSOperationQueue.
Views Tab


When the view tab is pressed, this is what pops up. The popup conveys the view hierarchy of the current UIWindow. The more to the right the view is, the more views it is under. Pressing the button allows a look at the view's information, opening up the window that looks like this:

Let's break it all down.
========================
The top title of the window is the name of the selected view. It can be hooked with proper interfacing. In this case, the hooking would look like:
%hook UIScrollView
// the hooked methods
%end

Next, there is a searchbar where you can search for any information about the instance of the class that you need.
After that, there is a tabview where FLEX displays all the superclasses for the current class. In the above screenshot, UIScrollView is a subclass of UIView which is a subclass of UIResponder, which in turn is a sublcass of NSObject.
In the next area, called the DESCRIPTION area, some basic information about the class is displayed. The information shown, which looks like:
<UIScrollView:0x108832a00; frame = (0 0; 390 375);
clipsToBounds = YES; gestureRecognizers = <NSArray:
0x2830faeb0>; layer = <CALayer: 0x283efcbc0>;
contentOffset: {0, 0}; contentSize: {1813, 0};
adjustedContentInset: {0, 0, 0, 0}>
  • <UIScrollView:0x108832a00; -> This is the class view and its tag, which can be hooked using viewWithTag:
  • frame = (0 0; 390 375); -> This is the frame of the instance following a format of x, y, width and height
  • clipsToBounds = YES; -> This shows whether the instance of the class allows its subviews to clip its bounds
  • gestureRecognizers = <NSArray: 0x2830faeb0>; -> This shows the gestureRecognizers on the instance of the class.
  • layer = <CALayer: 0x283efcbc0>; -> Gets the current .layer properrty of the instance of the view.
  • contentOffset: {0, 0}; -> This is a property which UIScrollView has, which is "the point at which the origin of the content view is offset from the origin of the scroll view."

Next, we have the "SHORTCUTS" section of the view. In here, we have some basic/common properties for the tweak. For example, the first shortcut is the Nearest View Controller shortcut, having the view controller that the view resides in. These properties are different for different views.

Further ahead, we have the "PROPERTIES" section. This section contains all the @property's for the tweak, not just the basic ones. It also contains their values. You may be able to change some of them as well by tapping the ⓘ button to temporarily set the @property to adifferent value.

After that, there is the "IVARS" section. This section contains all the instance variables for the object.

Below that, there is the "METHODS" section, which contains all the instance methods that the object has. Note that this contains the methods for the specific subclass that the selected object pertains to, not all the methods which it inherits from its superclass. To check the methods which it inherits from its superclass, you'd need to go to the tabview and select its superclass.

In addition, there is a section below that which contains the class methods for the object. These are different with respect to the instance methods because they are on the class itself, not an instance of the class.

Next, there's the "CLASS HIERARCHY" section. This is pretty much the same thing as the top tabbar with the various subclasses and superclasses.

After that, we have the "PROTOCOLS" section. This includes all the protocols that the view conforms to.

Next, there is some miscellaneous information about the object inside of the "MISCELLANEOUS" section.

Finally, the very last section is the "OBJECT GRAPH" section. This section allows you to browse all the objects that reference the current object in their code.

Select Button
Allows you to select a view on the screen and look at its values. Usually, you will need to select something that will not be selected upon the first tap. In order to select the thing that you want to select, you will need to move the view that is covering your target view and keep repeating that until you get to the correct view.

Another function of this button is the following: if you hold down on the button, you will be able to select what window FLEX is displayed on, allowing for the selection of typically unselectable items. For instance, items relating to keyboard (such as UIKeyboardDockView) are typically not able to be selected via FLEX because the keyboard is on a higher window level. Adjusting FLEX's window level to be above the keyboard's window level allows you to select the keyboard.

Recent Button
Allows you to go to the most recent selected item.

Previous Page (Avoiding layoutSubviews)

Next Page (Adapting for rootless)