Using xposed installer to implement Android hooks

Source: Internet
Author: User
Tags throwable

Use xposed installer to implement Android hooks, the article reference the official tutorial, there are changes.

1, install xposed installer frame apk to the mobile phone, the phone must root;

2, code writing;

Declared in the manifest file:

<application Android:allowbackup= "true" android:icon= "@drawable/ic_launcher" android: Label= "@string/app_name" android:theme= "@style/apptheme" > <meta-data android:name= " Xposedmodule " android:value=" true "/> <meta-data android:name=" Xposeddescription "an Droid:value= "Easy example which changes the color of all app"/> <meta-data android:name= "Xposedmi Nversion " android:value="/></application> "

Add xposed library file to Libs; Create a new Main.java class with the following code:

 Public classMainImplementsixposedhookloadpackage,ixposedhookzygoteinit{@Override Public voidInitzygote (Startupparam Startupparam)throwsthrowable {hookrescolor (); }    voidHookrescolor () {Xposedhelpers.findandhookmethod (Resources.class,                "GetColor", Integer.type,Newxc_methodreplacement () {@OverrideprotectedObject replacehookedmethod (methodhookparam param)throwsthrowable {Object color=Xposedbridge.invokeoriginalmethod (Param.method, Param.thisobject, Param.args); if(ColorinstanceofInteger) {Integer new_name=(Integer) color; returnNew_name & ~0X0000FF00 | 0x00ff0000; }                        return NULL ;    }                }); } @Override Public voidHandleloadpackage (Loadpackageparam Lpparam)throwsthrowable {hookclock (Lpparam); }    voidHookclock (Loadpackageparam lpparam) {if(!lpparam.packagename.equals ("Com.android.systemui"))            return; Xposedhelpers.findandhookmethod ("Com.android.systemui.statusbar.policy.Clock", Lpparam.classloader,"Updateclock",NewXc_methodhook () {@Overrideprotected voidAfterhookedmethod (methodhookparam param)throwsthrowable {System.out.println ("Replacehookedmethod---updateclock"); XposedBridge.log ("Replacehookedmethod---updateclock-->>"); TextView TV=(TextView) param.thisobject; String text=Tv.gettext (). toString (); Tv.settext (Text+ ":)--");                    Tv.settextcolor (color.red);    }                }); }

add a name of xposed_init files to the assets directory, the file content is "Com.app.xposed.example.Main", which is the full package name of the Main class above.

Right-click on the project to choose the properties, in the Java Build path to remove the check option (here a bit of pit, must be removed check, otherwise after running no effect, do not know if it is related to the development environment),

To run the project, the effect is as follows:

So it seems that xposed, like Cydia substrate, needs to rely on Java reflection, and if the code is confusing or encrypted, is this framework useful?

Using xposed installer 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.