what is xposed
Xposed is a special Android application. By replacing the files such as app_process witch under system\bin\Process to control the zygote process, so as to control all the app processes on the mobile phone; the disadvantage is that it can't hook the functions in the so application
how to install xposed
refer to Install xposed for Android phone
a demo for xposed
- create a new Android project
- modify(alter, change? I dont konw..)the AndroidManifest,xml
<!-- Whether it is an xposed module. Xposed judges whether it is a module based on this
<meta-data
android:name="xposedmodule"
android:value="true" />
<!-- The module description -->
<meta-data
android:name="xposeddescription"
android:value="xposed demo" />
<!-- The minimum version supported is 30-->
<meta-data
android:name="xposedminversion"
android:value="30" />
3.add dependency
open buile.gradle (module:app)File, add the following code in it:
compileOnly 'de.robv.android.xposed:api:82'
compileOnly 'de.robv.android.xposed:api:82:sources'
IXposedHookLoadPackage
Create a new Java class(MainIntercept) and implements Ixposedhookloadpackage and override the handleloadpackage methodxposed_init
Create an assets under Src/Mian, add xposed_init under it,, the code inside is your hook class package name + class nameRewrite the Mainactivity code as follows:
public class MainActivity extends BaseActivity
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
............
textView.setText(getText());
............
}
private String getText(){
return "-----ha ha !!-----";
}
}
6.change the code in MainIntercept:
public class MainIntercept implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
if(!lpparam.packageName.equals("com.xxx.xxx")) return;
XposedHelpers.findAndHookMethod("com.xxx.xxx.xxx.MainActivity", lpparam.classLoader, "getText", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
param.setResult("----I was changed-----");
}
});
}
}
7.Rebuild, select the app in xposedinstaller and restart it
8.after restart the app,When this method is executed,you will see the result is '----I was changed-----' instead of '-----ha ha !!-----'
Top comments (0)