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 you know, phosphorus is found in DNA and cell ...
2014 was a special year for the domestic communic...
Since 2017, the fuel cell industry has begun to d...
According to German Manager Magazine, BMW's s...
As most young users believe, no matter how manufa...
Drinking culture has a long history in China. Eve...
Since entering the 21st century, the rise of fema...
May 16th of every year is the International Day o...
After the APP is launched, promoting the product ...
The first thing I want to share is a very mainstr...
This article will be divided into three parts. Th...
serial number Chinese content 1.1 When developing...
If you were to ask: In the current liquor market,...
Proper use of push can help product operators ach...
CCTV News: From entering the Chinese space statio...