The following three methods can make code execute before main function:
All +load methods
All C++ static initializers
All C/C++ attribute(constructor) functions
Problems with Code Executing Before main Function
Cannot Patch
Cannot audit time consumption
Calling UIKit related methods causes some classes to initialize early
Executes on main thread, completely blocking execution
...
First addition: static initializers in title should actually be called C++ static initializers and C/C++ __attribute__(constructor) functions.
Use MachOView to open a MachO file, in most cases will see this section __mod_init_func .
...
iOS has the following four methods to conveniently execute code in premain stage:
1. Objective C class's +load method
2. C++ static initializer
3. C/C++ __attribute__(constructor) functions
4. The above three methods in dynamic libraries
...
Larger projects need reasonable file directory hierarchy organization.
During reverse engineering WeChat, often see some “output log” method calls, and with complete paths. For example:
...
Phenomenon
MachOView viewing Facebook’s executable file, found FBInjectable and fbsessiongks data segments, this article explores fbsessiongks data segment’s generation and usage.
...
Phenomenon
MachOView viewing Facebook’s executable file, found FBInjectable and fbsessiongks data segments, this article explores FBInjectable data segment’s generation and usage.
...
Phenomenon
When using MachOView to view Facebook’s iOS binary file, found several Sections different from most other Apps.
Image below is Facebook:
Image below is WeChat:
...
class-dump outputs so many header files, supotato can form a simple classification report based on header files’ first 2 characters. Can also guess which third-party libraries (CocoaPods) are used.
Source code
...
Background
Last weekend two days with friend (two person team) participated in segmentfault and angelhack’s hackathon, Beijing station. Theme was “Renaissance”.
Saturday after simple opening, and simple API presentation (too simple). Officially started brainstorming at 2pm. Provided SDKs: agoria’s video call SDK and wacom’s WILL SDK.
Based on this we had an idea:
Video drawing teaching. agoria provides video functionality, wacom provides drawing tablet functionality. Since both SDKs have demos, should be able to assemble quickly.
Anonymous video. Randomly connect with another party who opens the App.
Anonymous interest video. Select interests built into App, can video with all users entering this interest.
However, we always felt these ideas “lack creativity”. Video SDK claims 30 minute integration, WILL SDK should also be easy to use. Wouldn’t everyone do this video functionality? Simple video calls might not be creative?
...