Before we introduced the xposed framework of rovo89 on Githu, we also described how to use the xposed framework to
Login hijacking, and ad injection.
But, after a lot of friends are asking me, this xposed framework is really good to use. But there is a
A huge drawback is the need for root privileges. Many devices do not have root privileges, there is no need for root
Permission of the hook frame.
The answer is, OK. is the current Alibab open source framework, dexposed framework.
GitHub Address: https://github.com/alibaba/dexposed
Dexposed
Its official introduction is as follows:
It is based on the root community's well-known open source project xposed transformation stripped down the root section, evolving to serve the application itself
The AOP framework and open source under the Apache 2.0 protocol.
Xposed is a project developed and managed by XDA Community users rovo89, which modifies the Android
Dalvik run-time zygote process, using xposed
Bridge injects third-party code into the method call of the Android application, implementing a non-intrusive run-time dynamic
Ability to modify system and application behavior.
The principle of dexposed is also very simple, as it is mentioned in the introduction. It's the xposed framework that stripped down the root section.
Function.
Not familiar with the xposed principle, you can see here
http://blog.csdn.net/yzzst/article/details/47659987
Without root privileges, the xposed framework cannot replace the app_process, and of course the entire system cannot be
-level application is injected. Of course, there is no problem with the self-procedure itself.
At present, the main application scenarios of dexposed are as follows:
- AOP Programming
- Insert piles (e.g. test, performance monitoring, etc.)
- Online Hot Patches
- SDK hooking to provide a better development experience
AOP is aspect oriented
Programming abbreviation, meaning: aspect-oriented programming, through the pre-compilation method and run-time dynamic agent implementation process
A technique for uniform maintenance of sequential functions.
See here, a lot of small partners are estimated to have doubts, I can't do login hijacking, can't inject ads
The What am I going to do with you? /(ㄒoㄒ)/~
AOP programming, online hot patches
Yes, the main functionality of the dexposed framework is also provided as an AOP framework for use. So, before we
Also introduced the Android plug-in implementation method. Here we use the dexposed framework to implement, the plug-in model will
will be much simpler.
First, the dexposed framework also provides a similar approach to the xposed framework.
/** * Whether the system supports hooks */ Public Static synchronized Boolean candexposed(context context)/** * Find and hook a specified method * @param the Clazz class Class * @param methodName Hook method name * @param Parametertypesandcallback parameter and return callback * @return * * Public static Unhook findandhookmethod(Class<?> clazz, String MethodName, Object... parametertypesandcallback)
Online Hot Patch Instance
How to make a hot patch online? Here we take the demo of Alibaba as an example.
As in the mainline version, we have a ShowDialog method. has been released. However, it was suddenly found that there was a
Point bugs or sudden demand, we are not able to understand the release of the update.
- Here we can load the plug-in on the line by the way we said before Dexclassloader path.apk
。
2. Through the dexposed framework, dynamically hook and replace the ShowDialog function method in the mainline version.
The specific logic is as follows:
See above the effect of the diagram, I believe you have a certain understanding of dexposed online hot patches.
We don't have to do too much of it here.
Of course, you might think of a lot of application directions that use hot patches, such as:
- Bug Patch Fix
- Plug-in Features
- Wait a minute
Dexposed frame principle is very simple, function is not powerful. But it's really practical. I also recommend the big
Used by Android developers, especially startups. It's a wall crack recommendation!!
The following are the logical implementations in the main project and patch engineering. Here, children's shoes can be compared to look at.
If you have a dynamic use of Dexclassloader loading an APK code there are still questions. You can clone a bit.
Dexposed the source of learning learning.
Of course, it is recommended that you go to my blog to see, Android plug-in principle.
Address: http://blog.csdn.net/yzzst/article/details/45582315
The definition of Mainactivity ShowDialog method in main project
Public class mainactivity extends Activity { //.......... Some missing code. Private void ShowDialog() {Alertdialog.builder Builder =NewAlertdialog.builder ( This); Builder.settitle ("Dexposed Sample"). Setmessage ("Please clone Patchsample project to generate APK, and copy it to \"/android/data/com.taobao.dexposed/cache/patch.apk \""). Setpositivebutton ("OK",NewDialoginterface.onclicklistener () { Public void OnClick(Dialoginterface Dialog,intWhichbutton) {}}). Create (). Show (); }}
Online hot Patches, code in PATH.APK
/** * Plug-in patch class * / Public class dialogpatch implements ipatch { @Override Public void Handlepatch(FinalPatchparam arg0)throwsThrowable {//Get the ClassLoader of the main programClass<?> CLS =NULL;Try{//Get the Mainactivity class for the main programCls= Arg0.context.getClassLoader (). LoadClass ("Com.taobao.dexposed.MainActivity"); }Catch(ClassNotFoundException e) {E.printstacktrace ();return; }//Hook and replace the ShowDialog method in MainactivityDexposedbridge.findandhookmethod (CLS,"ShowDialog",NewXc_methodreplacement () {@Override protectedObjectReplacehookedmethod(Methodhookparam param)throwsThrowable {//Eject a plugin in the dialogActivity mainactivity = (activity) Param.thisobject; Alertdialog.builder Builder =NewAlertdialog.builder (mainactivity); Builder.settitle ("Dexposed Sample"). Setmessage ("The dialog is shown from Patch apk!"). Setpositivebutton ("OK",NewDialoginterface.onclicklistener () { Public void OnClick(Dialoginterface Dialog,intWhichbutton) {}}). Create (). Show ();return NULL; } }); }}
/*
* @author Zhoushengtao (Zhou San)
* @since August 26, 2015 0:08:22
* @weixin stchou_zst
* @blog http://blog.csdn.net/yzzst
* @ Exchange Learning QQ Group: 341989536
* @ Private qq:445914891
/
Copyright NOTICE: Reprint please mark: Http://blog.csdn.net/yzzst. This article for Bo Master original article, without Bo Master permission not reproduced.
Can I hook without root? --depoxsed Framework Demo