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