├── .gitignore ├── README.md ├── XposedHookDemo ├── .classpath ├── .project ├── .settings │ ├── org.eclipse.core.resources.prefs │ └── org.eclipse.jdt.core.prefs ├── AndroidManifest.xml ├── assets │ └── xposed_init ├── bin │ ├── AndroidManifest.xml │ ├── XposedHookDemo.apk │ ├── XposedHookLocation.apk │ ├── classes.dex │ ├── jarlist.cache │ ├── res │ │ └── crunch │ │ │ ├── drawable-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ │ └── drawable-xxhdpi │ │ │ └── ic_launcher.png │ └── resources.ap_ ├── gen │ └── cn │ │ └── wjdiankong │ │ └── xposedhook │ │ ├── BuildConfig.java │ │ └── R.java ├── ic_launcher-web.png ├── proguard-project.txt ├── project.properties ├── res │ ├── drawable-hdpi │ │ └── ic_launcher.png │ ├── drawable-mdpi │ │ └── ic_launcher.png │ ├── drawable-xhdpi │ │ └── ic_launcher.png │ ├── drawable-xxhdpi │ │ └── ic_launcher.png │ ├── layout │ │ └── activity_demo.xml │ └── values │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml └── src │ └── cn │ └── wjdiankong │ └── xposedhook │ ├── Main.java │ └── MainActivity.java └── xposed.installer_v33.apk /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xposedhookdemo 2 | Xposed框架Hook案例 3 | -------------------------------------------------------------------------------- /XposedHookDemo/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /XposedHookDemo/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | XposedHookDemo 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.andmore.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.andmore.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | org.eclipse.andmore.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | org.eclipse.andmore.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /XposedHookDemo/.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /XposedHookDemo/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate 4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 5 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 6 | org.eclipse.jdt.core.compiler.compliance=1.7 7 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 8 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 9 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 10 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 | org.eclipse.jdt.core.compiler.source=1.7 13 | -------------------------------------------------------------------------------- /XposedHookDemo/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 35 | 36 | 39 | 42 | 45 | 46 | 49 | 50 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /XposedHookDemo/assets/xposed_init: -------------------------------------------------------------------------------- 1 | cn.wjdiankong.xposedhook.Main 2 | -------------------------------------------------------------------------------- /XposedHookDemo/bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 35 | 36 | 39 | 42 | 45 | 46 | 49 | 50 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /XposedHookDemo/bin/XposedHookDemo.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/bin/XposedHookDemo.apk -------------------------------------------------------------------------------- /XposedHookDemo/bin/XposedHookLocation.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/bin/XposedHookLocation.apk -------------------------------------------------------------------------------- /XposedHookDemo/bin/classes.dex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/bin/classes.dex -------------------------------------------------------------------------------- /XposedHookDemo/bin/jarlist.cache: -------------------------------------------------------------------------------- 1 | # cache for current jar dependency. DO NOT EDIT. 2 | # format is 3 | # Encoding is UTF-8 4 | -------------------------------------------------------------------------------- /XposedHookDemo/bin/res/crunch/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/bin/res/crunch/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /XposedHookDemo/bin/res/crunch/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/bin/res/crunch/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /XposedHookDemo/bin/res/crunch/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/bin/res/crunch/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /XposedHookDemo/bin/res/crunch/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/bin/res/crunch/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /XposedHookDemo/bin/resources.ap_: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/bin/resources.ap_ -------------------------------------------------------------------------------- /XposedHookDemo/gen/cn/wjdiankong/xposedhook/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package cn.wjdiankong.xposedhook; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /XposedHookDemo/gen/cn/wjdiankong/xposedhook/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package cn.wjdiankong.xposedhook; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class dimen { 14 | /** Default screen margins, per the Android Design guidelines. 15 | */ 16 | public static final int activity_horizontal_margin=0x7f040000; 17 | public static final int activity_vertical_margin=0x7f040001; 18 | } 19 | public static final class drawable { 20 | public static final int ic_launcher=0x7f020000; 21 | } 22 | public static final class id { 23 | public static final int imei=0x7f070000; 24 | public static final int location=0x7f070001; 25 | } 26 | public static final class layout { 27 | public static final int activity_demo=0x7f030000; 28 | } 29 | public static final class string { 30 | public static final int action_settings=0x7f050002; 31 | public static final int app_name=0x7f050000; 32 | public static final int current_location=0x7f050005; 33 | public static final int hello_world=0x7f050001; 34 | public static final int save_location=0x7f050003; 35 | public static final int tip=0x7f050004; 36 | } 37 | public static final class style { 38 | /** Base application theme. 39 | Customize your theme here. 40 | */ 41 | public static final int AppTheme=0x7f060000; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /XposedHookDemo/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/ic_launcher-web.png -------------------------------------------------------------------------------- /XposedHookDemo/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /XposedHookDemo/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-23 15 | -------------------------------------------------------------------------------- /XposedHookDemo/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /XposedHookDemo/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /XposedHookDemo/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /XposedHookDemo/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/XposedHookDemo/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /XposedHookDemo/res/layout/activity_demo.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 22 | 23 | -------------------------------------------------------------------------------- /XposedHookDemo/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /XposedHookDemo/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | XposedHookDemo 5 | Hello world! 6 | Settings 7 | Save location 8 | Select longtitue and latitude by click, long press, double click the map 9 | Current location: 10 | 11 | 12 | -------------------------------------------------------------------------------- /XposedHookDemo/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /XposedHookDemo/src/cn/wjdiankong/xposedhook/Main.java: -------------------------------------------------------------------------------- 1 | package cn.wjdiankong.xposedhook; 2 | 3 | import java.lang.reflect.Method; 4 | import java.lang.reflect.Modifier; 5 | 6 | import android.location.Location; 7 | import android.location.LocationListener; 8 | import android.location.LocationManager; 9 | import android.util.Log; 10 | import de.robv.android.xposed.IXposedHookLoadPackage; 11 | import de.robv.android.xposed.XC_MethodHook; 12 | import de.robv.android.xposed.XposedBridge; 13 | import de.robv.android.xposed.XposedHelpers; 14 | import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam; 15 | 16 | public class Main implements IXposedHookLoadPackage { 17 | 18 | private void hook_method(String className, ClassLoader classLoader, String methodName, 19 | Object... parameterTypesAndCallback){ 20 | try { 21 | XposedHelpers.findAndHookMethod(className, classLoader, methodName, parameterTypesAndCallback); 22 | } catch (Exception e) { 23 | XposedBridge.log(e); 24 | } 25 | } 26 | 27 | private void hook_methods(String className, String methodName, XC_MethodHook xmh){ 28 | try { 29 | Class clazz = Class.forName(className); 30 | for (Method method : clazz.getDeclaredMethods()) 31 | if (method.getName().equals(methodName) 32 | && !Modifier.isAbstract(method.getModifiers()) 33 | && Modifier.isPublic(method.getModifiers())) { 34 | XposedBridge.hookMethod(method, xmh); 35 | } 36 | } catch (Exception e) { 37 | XposedBridge.log(e); 38 | } 39 | } 40 | 41 | @Override 42 | public void handleLoadPackage(final LoadPackageParam lpp) throws Throwable{ 43 | 44 | Log.i("jw", "pkg:"+lpp.packageName); 45 | 46 | hook_method("android.telephony.TelephonyManager", lpp.classLoader, "getDeviceId", new XC_MethodHook() { 47 | @Override 48 | protected void afterHookedMethod(MethodHookParam param) throws Throwable { 49 | Log.i("jw", "hook getDeviceId..."); 50 | Object obj = param.getResult(); 51 | Log.i("jw", "imei args:"+obj); 52 | param.setResult("jiangwei"); 53 | } 54 | }); 55 | 56 | //定位 57 | hook_methods("android.location.LocationManager", "getLastKnownLocation", new XC_MethodHook(){ 58 | @Override 59 | protected void afterHookedMethod(MethodHookParam param) throws Throwable { 60 | Log.i("jw", "hook getLastKnownLocation..."); 61 | Location l = new Location(LocationManager.PASSIVE_PROVIDER); 62 | double lo = -10000d; //经度 63 | double la = -10000d; //纬度 64 | l.setLatitude(la); 65 | l.setLongitude(lo); 66 | param.setResult(l); 67 | } 68 | }); 69 | 70 | hook_methods("android.location.LocationManager", "requestLocationUpdates", new XC_MethodHook() { 71 | @Override 72 | protected void afterHookedMethod(MethodHookParam param) throws Throwable { 73 | 74 | Log.i("jw", "hook requestLocationUpdates..."); 75 | 76 | if (param.args.length == 4 && (param.args[0] instanceof String)) { 77 | LocationListener ll = (LocationListener)param.args[3]; 78 | Class clazz = LocationListener.class; 79 | Method m = null; 80 | for (Method method : clazz.getDeclaredMethods()) { 81 | if (method.getName().equals("onLocationChanged")) { 82 | m = method; 83 | break; 84 | } 85 | } 86 | 87 | try { 88 | if (m != null) { 89 | Object[] args = new Object[1]; 90 | Location l = new Location(LocationManager.PASSIVE_PROVIDER); 91 | double lo = -10000d; //经度 92 | double la = -10000d; //纬度 93 | l.setLatitude(la); 94 | l.setLongitude(lo); 95 | args[0] = l; 96 | m.invoke(ll, args); 97 | } 98 | } catch (Exception e) { 99 | XposedBridge.log(e); 100 | } 101 | } 102 | } 103 | }); 104 | 105 | } 106 | 107 | } 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /XposedHookDemo/src/cn/wjdiankong/xposedhook/MainActivity.java: -------------------------------------------------------------------------------- 1 | package cn.wjdiankong.xposedhook; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.app.Activity; 5 | import android.content.Context; 6 | import android.location.Location; 7 | import android.location.LocationListener; 8 | import android.location.LocationManager; 9 | import android.os.Bundle; 10 | import android.telephony.TelephonyManager; 11 | import android.util.Log; 12 | import android.widget.TextView; 13 | 14 | /** 15 | * 演示地图缩放,旋转,视角控制 16 | */ 17 | public class MainActivity extends Activity { 18 | 19 | private LocationManager locationManager; 20 | 21 | private TextView locationTxt, imeiTxt; 22 | 23 | @SuppressLint("NewApi") 24 | @Override 25 | public void onCreate(Bundle savedInstanceState) { 26 | super.onCreate(savedInstanceState); 27 | setContentView(R.layout.activity_demo); 28 | 29 | locationTxt = (TextView)findViewById(R.id.location); 30 | imeiTxt = (TextView)findViewById(R.id.imei); 31 | 32 | //获取地理位置管理器 33 | locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 34 | //获取Location 35 | Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); 36 | if(location!=null){ 37 | //不为空,显示地理位置经纬度 38 | showLocation(location); 39 | } 40 | //监视地理位置变化 41 | locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3000, 1, locationListener); 42 | 43 | TelephonyManager telephonyManager = (TelephonyManager) this.getSystemService(Context.TELEPHONY_SERVICE); 44 | String imei = telephonyManager.getDeviceId(); 45 | imeiTxt.setText("imei:"+imei); 46 | 47 | } 48 | 49 | /** 50 | * 显示地理位置经度和纬度信息 51 | * @param location 52 | */ 53 | private void showLocation(Location location){ 54 | String locationStr = "纬度:" + location.getLatitude() + ",经度:" + location.getLongitude(); 55 | locationTxt.setText(locationStr); 56 | Log.i("jw", "location:"+locationStr); 57 | } 58 | 59 | /** 60 | * LocationListern监听器 61 | * 参数:地理位置提供器、监听位置变化的时间间隔、位置变化的距离间隔、LocationListener监听器 62 | */ 63 | 64 | LocationListener locationListener = new LocationListener() { 65 | 66 | @Override 67 | public void onStatusChanged(String provider, int status, Bundle arg2) { 68 | 69 | } 70 | 71 | @Override 72 | public void onProviderEnabled(String provider) { 73 | 74 | } 75 | 76 | @Override 77 | public void onProviderDisabled(String provider) { 78 | 79 | } 80 | 81 | @Override 82 | public void onLocationChanged(Location location) { 83 | //如果位置发生变化,重新显示 84 | showLocation(location); 85 | 86 | } 87 | }; 88 | 89 | } 90 | -------------------------------------------------------------------------------- /xposed.installer_v33.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fourbrother/xposedhookdemo/2c1c9ea63dddf3ef2e0afcb606d7409066c9c1f8/xposed.installer_v33.apk --------------------------------------------------------------------------------