<application android:allowBackup="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name" android:theme="@style/AppTheme"android:name=".MainApplication"> <!-- Xposed --> <meta-dataandroid:name="xposedmodule" android:value="true" /> <meta-dataandroid:name="xposedminversion" android:value="42+" /> <meta-data android:name="xposeddescription"android:value="GameAssistant" /> <activityandroid:name="com.netease.ga.view.MainActivity"android:theme="@android:style/Theme.NoTitleBar.Fullscreen"><intent-filter> <actionandroid:name="android.intent.action.MAIN" /> <categoryandroid:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activityandroid:name=".view.MyGamesActivity"android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/><activity android:name=".view.PluginsActivity" /> <activityandroid:name=".view.MoreActivity" /> <receiverandroid:name=".receiver.MyReceiver" /> </application>
XposedBridgeApi-<version>.jar
from the first post of this XDA thread. Copy it into a subfolder called lib
. Then right-click on it and select Build Path => Add to Build Path. The <version>
from the file name is the one you insert asxposedminversion
in the manifest.Make sure that the API classes are not included (but only referenced) in your compiled APK, otherwise you will get an
IllegalAccessError
. Files in thelibs
(with "s") folder are automatically included by Eclipse, so don't put the API file there.
package com.netease.ga; import android.app.Activity; import android.content.Context;import android.content.SharedPreferences; import android.os.Build; importandroid.os.Bundle; import android.util.Log; import java.lang.reflect.Method; importdalvik.system.DexClassLoader; import de.robv.android.xposed.IXposedHookLoadPackage;import de.robv.android.xposed.XC_MethodHook; importde.robv.android.xposed.callbacks.XC_LoadPackage; import staticde.robv.android.xposed.XposedHelpers.findAndHookMethod; import staticde.robv.android.xposed.XposedHelpers.findClass; /** * Created by sing on 14-9-17. * desc: */ public class XposedXXHook implements IXposedHookLoadPackage { private staticfinal String TAG = "XposedXXHook"; private static final String TARGET_PACKAGE = "com.example.helloapplication"; private static final String TARGET_CLASS = "com.example.helloapplication.MainActivity"; private static final String TARGET_FUNCTION = "onCreate"; //private SharedPreferences sp; /** * * @param param *@throws Throwable */ @Override public voidhandleLoadPackage(XC_LoadPackage.LoadPackageParam param) throws Throwable { String packageName = param.packageName; Log.d(TAG, "handleLoadPackage: " + packageName); if(packageName.equals(TARGET_PACKAGE) == false) { return; } Log.d(TAG,"handleLoadPackage: star hook"); XC_MethodHook.Unhook unhook = findAndHookMethod(TARGET_CLASS, param.classLoader, TARGET_FUNCTION, Bundle.class, newXC_MethodHook() { @Override protected void beforeHookedMethod(MethodHookParam param)throws Throwable { Log.d(TAG, "[handleLoadPackage]beforeHookedMethod"); } @Overrideprotected void afterHookedMethod(MethodHookParam param) throws Throwable { Log.d(TAG,"[handleLoadPackage]afterHookedMethod: " + param.thisObject.toString()); String plugApkPath = "/data/data/com.netease.ga/app_plugin/lianmengplug.apk"; String plugSoPath = "/data/data/com.netease.ga/app_plugin/libxxlianmeng_mm.so"; String dexOutputDir = "/data/data/" + TARGET_PACKAGE + "/cache"; ClassLoader localClassLoader = ClassLoader.getSystemClassLoader(); DexClassLoader localDexClassLoader = new DexClassLoader(plugApkPath, dexOutputDir, null, localClassLoader); java.lang.Class<?> plugClass = localDexClassLoader.loadClass("com.xxAssistant.UI.UniversalUI"); Method mInit = plugClass.getDeclaredMethod("init", Activity.class, String.class); mInit.invoke(null, param.thisObject, plugSoPath); } }); if (unhook!=null) { Log.d(TAG,"handleLoadPackage: hook ok"); }else{ Log.d(TAG, "handleLoadPackage: hook failed"); } } }
findAndHookMethod(TARGET_CLASS, param.classLoader, TARGET_FUNCTION, newXC_MethodHook(){...});
findAndHookMethod(TARGET_CLASS, param.classLoader, TARGET_FUNCTION, Bundle.class, newXC_MethodHook(){...});