Using Cydia substrate to implement Android hooks

Source: Internet
Author: User

Using Cydia substrate to implement Android hooks, the article comes from an official tutorial.

1, install Cydia substrate frame apk, the phone must be root.

2, code writing;

In the manifest file, declare the following:

<application        android:allowbackup= "true"        android:icon= "@drawable/ic_launcher"         Android:label= "@string/app_name"        android:theme= "@style/apptheme" >        <meta-  Data            android:name= "Com.saurik.substrate.main"            android:value= ". Main "/></application><uses-permission android:name=" Cydia.permission.SUBSTRATE "/>

The code for the main class is as follows:

 Public classMain { Public Static voidInitialize () {hooksaygoer (); }        Static voidHookrescolor () {ms.hookclassload ("Android.content.res.Resources",                NewMS. Classloadhook () {@Override Public voidClassloaded (class<?>Resources) {Method GetColor=NULL; Try{GetColor= Resources.getdeclaredmethod ("GetColor", Integer.type); } Catch(nosuchmethodexception e) {e.printstacktrace (); }                        if(GetColor! =NULL) {Ms.hookmethod (Resources,getcolor,NewMs. Methodalteration<resources, integer>() {                                         PublicInteger invoked (resources resources, Object ... args) throwsThrowable {returninvoke (resources, args)& ~0X0000FF00 | 0x00ff0000;                        }                                    });    }                    }                }); }    }

where Initialize () is equivalent to the entry function, the code is implemented as follows:

Personal feeling cydia substrate is based on class loading, method invocation, key or dependent on Java reflection, Android system source readable can certainly be modified, if it is a third-party program code obfuscation or encryption, then Java reflection Invalidation, this framework is also useful?

Using Cydia substrate to implement Android hooks

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.