Cydia Substrate is a code modification platform. It can modify the code of any main process, whether it is written in Java or C/C++ (native code). Xposed only supports HOOKing java functions in app_process, so Cydia Substrate is a powerful and practical HOOK tool. Official website: http://www.cydiasubstrate.com/ Demo address: https://github.com/zencodex/cydia-android-hook Official tutorial: http://www.cydiasubstrate.com/id/20cf4700-6379-4a14-9bc2-853fde8cc9d1 SDK download address: http://asdk.cydiasubstrate.com/zips/cydia_substrate-r2.zip Introduction to several important APIs of SubstrateMS.hookClassLoadFunction prototype: void hookClassLoad(String name, MS.ClassLoadHook hook); This method implements notification when the specified class is loaded. Because a class can be loaded at any time, Substrate provides a method to detect when the class of interest to the user is loaded.
MS.hookMethodThis API allows developers to provide a callback function to replace the original method. This callback function is an object that implements the MS.MethodHook interface and is a typical anonymous inner class. It contains an invoked function. Function prototype: void hookMethod(Class _class, Member member, MS.MethodHook hook, MS.MethodPointer old); void hookMethod(Class _class, Member member, MS.MethodAlteration alteration); Parameter Description (one)
(two)
Developers are advised to use the second method, which is simpler to use and less error-prone, and does not require a separate instance of the MS.MethodPointer class. How to useThe following example uses the official website to illustrate how to use cydia substrate. This example is to change the color of multiple interface components to violet. Need to install: http://www.cydiasubstrate.com/download/com.saurik.substrate.apk Step 1: Create an empty Android project. Since the created project will be loaded as a plug-in, no activity is required. Copy the substrate-api.jar in the SDK to the project/libs folder. Step 2: Configure the Manifest file (1) Requires the specified permission: cydia.permission.SUBSTRATE (2) Add a meta tag with name cydia.permission.SUBSTRATE and value .Main, the class name created in the next step.
Step 2: Create a class named Main. The class contains a static method initialize. When the plug-in is loaded, the code in this method will run to complete some necessary initialization work.
Step 3: In order to implement HOOK and modify the code in the target class, we need to get an instance of the target class, such as resources in the example.
Step 4: Modify the original code through the MS.MethodHook instance. In order to call the method in the original code, we need to create an instance of the MS.MethodPointer class, which can run the original code at any time. Here we change all green colors to violet by calling and modifying the original code of the resources object in the original code.
After installing and running, I found that many font colors have changed after restarting the system. As shown in the following figure: The code of MS.hookMethod in the example can be changed to:
SMS monitoring exampleIn the following example, we implement the SMS monitoring function and print out the sender, recipient, and content of the SMS:
The result after running is: |
<<: How to implement Touch ID verification in iOS 8 using Swift
>>: 10 Tips to Improve the Value of Programmers in the Workplace
As a product of Toutiao, Xigua Video has been aro...
Recently, a NIO owner reported on a forum that he...
Practical course on sharing good products with sh...
If there is a way to make an event more effective...
As the most popular entry-level coupe, the mid-te...
A few days ago, a plastic back cover model of wha...
Zhiji Auto recently announced that the cumulative...
D.Phone : : : : : : : : : : : : : : :...
Zeng Shen's exquisite ni product performance ...
Generally speaking, pain is an uncomfortable feel...
Today I will give you some of my humble opinions ...
[51CTO.com original article] The launch of the fi...
February 14th is a special day for lovers all ove...
Some keywords have bids of more than 20 yuan, and...
Crispy on the outside and tender on the inside, g...