This combines calls to {@link #findMethodExact(Class, String, Object...)} and
192 | * {@link XposedBridge#hookMethod}.
193 | *
194 | *
The method must be declared or overridden in the given class, inherited
195 | * methods are not considered! That's because each method implementation exists only once in
196 | * the memory, and when classes inherit it, they just get another reference to the implementation.
197 | * Hooking a method therefore applies to all classes inheriting the same implementation. You
198 | * have to expect that the hook applies to subclasses (unless they override the method), but you
199 | * shouldn't have to worry about hooks applying to superclasses, hence this "limitation".
200 | * There could be undesired or even dangerous hooks otherwise, e.g. if you hook
201 | * {@code SomeClass.equals()} and that class doesn't override the {@code equals()} on some ROMs,
202 | * making you hook {@code Object.equals()} instead.
203 | *
204 | *
There are two ways to specify the parameter types. If you already have a reference to the
205 | * {@link Class}, use that. For Android framework classes, you can often use something like
206 | * {@code String.class}. If you don't have the class reference, you can simply use the
207 | * full class name as a string, e.g. {@code java.lang.String} or {@code com.example.MyClass}.
208 | * It will be passed to {@link #findClass} with the same class loader that is used for the target
209 | * method, see its documentation for the allowed notations.
210 | *
211 | *
Primitive types, such as {@code int}, can be specified using {@code int.class} (recommended)
212 | * or {@code Integer.TYPE}. Note that {@code Integer.class} doesn't refer to {@code int} but to
213 | * {@code Integer}, which is a normal class (boxed primitive). Therefore it must not be used when
214 | * the method expects an {@code int} parameter - it has to be used for {@code Integer} parameters
215 | * though, so check the method signature in detail.
216 | *
217 | *
As last argument to this method (after the list of target method parameters), you need
218 | * to specify the callback that should be executed when the method is invoked. It's usually
219 | * an anonymous subclass of {@link XC_MethodHook} or {@link XC_MethodReplacement}.
220 | *
221 | *
Example
222 | *
223 | * // In order to hook this method ...
224 | * package com.example;
225 | * public class SomeClass {
226 | * public int doSomething(String s, int i, MyClass m) {
227 | * ...
228 | * }
229 | * }
230 | *
231 | * // ... you can use this call:
232 | * findAndHookMethod("com.example.SomeClass", lpparam.classLoader, String.class, int.class, "com.example.MyClass", new XC_MethodHook() {
233 | * @Override
234 | * protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
235 | * String oldText = (String) param.args[0];
236 | * Log.d("MyModule", oldText);
237 | *
238 | * param.args[0] = "test";
239 | * param.args[1] = 42; // auto-boxing is working here
240 | * setBooleanField(param.args[2], "great", true);
241 | *
242 | * // This would not work (as MyClass can't be resolved at compile time):
243 | * // MyClass myClass = (MyClass) param.args[2];
244 | * // myClass.great = true;
245 | * }
246 | * });
247 | *
248 | *
249 | * @param className The name of the class which implements the method.
250 | * @param classLoader The class loader for resolving the target and parameter classes.
251 | * @param methodName The target method name.
252 | * @param parameterTypesAndCallback The parameter types of the target method, plus the callback.
253 | * @throws NoSuchMethodError In case the method was not found.
254 | * @throws ClassNotFoundError In case the target class or one of the parameter types couldn't be resolved.
255 | * @return An object which can be used to remove the callback again.
256 | */
257 | public static XC_MethodHook.Unhook findAndHookMethod(String className, ClassLoader classLoader, String methodName, Object... parameterTypesAndCallback) {
258 | return findAndHookMethod(findClass(className, classLoader), methodName, parameterTypesAndCallback);
259 | }
260 | ```
261 |
262 | 优化后代码如下:
263 | ```kotlin
264 | private fun hookBeat() {
265 | XposedHelpers.findAndHookMethod("com.tencent.mm.ui.chatting.view.AvatarImageView",
266 | classLoader,
267 | "setOnDoubleClickListener",
268 | "com.tencent.mm.plugin.story.api.i\$a",
269 | object : XC_MethodReplacement() {
270 | override fun replaceHookedMethod(param: MethodHookParam?): Any {
271 | xlog("replace double click")
272 | return ""
273 | }
274 | })
275 | }
276 | ```
277 |
278 | 接下来分析下为什么也可以直接传String类型的类的名称,我们跟进`findAndHookMethod`找用到`parameterTypesAndCallback`参数的方法,
279 | 会发现它最终又会调用`findMethodExact`如下:
280 | ```java
281 | public static XC_MethodHook.Unhook findAndHookMethod(Class> clazz, String methodName, Object... parameterTypesAndCallback) {
282 | if (parameterTypesAndCallback.length == 0 || !(parameterTypesAndCallback[parameterTypesAndCallback.length-1] instanceof XC_MethodHook))
283 | throw new IllegalArgumentException("no callback defined");
284 |
285 | XC_MethodHook callback = (XC_MethodHook) parameterTypesAndCallback[parameterTypesAndCallback.length-1];
286 | Method m = findMethodExact(clazz, methodName, getParameterClasses(clazz.getClassLoader(), parameterTypesAndCallback));
287 |
288 | return XposedBridge.hookMethod(m, callback);
289 | }
290 | ```
291 |
292 | 继续看`getParameterClasses`方法如下,可以看到首先判断了如果type如果为空抛异常,如果为`XC_MethodHook`则不往下执行,
293 | 如果为`Class`则强转为Class,如果为`String`则调用`findClass((String) type, classLoader)`找到Class,方法最后返回Class,
294 | 所以`parameterTypesAndCallback`也可以直接传包名+类名:
295 | ```java
296 | private static Class>[] getParameterClasses(ClassLoader classLoader, Object[] parameterTypesAndCallback) {
297 | Class>[] parameterClasses = null;
298 | for (int i = parameterTypesAndCallback.length - 1; i >= 0; i--) {
299 | Object type = parameterTypesAndCallback[i];
300 | if (type == null)
301 | throw new ClassNotFoundError("parameter type must not be null", null);
302 |
303 | // ignore trailing callback
304 | if (type instanceof XC_MethodHook)
305 | continue;
306 |
307 | if (parameterClasses == null)
308 | parameterClasses = new Class>[i+1];
309 |
310 | if (type instanceof Class)
311 | parameterClasses[i] = (Class>) type;
312 | else if (type instanceof String)
313 | parameterClasses[i] = findClass((String) type, classLoader);
314 | else
315 | throw new ClassNotFoundError("parameter type must either be specified as Class or String", null);
316 | }
317 |
318 | // if there are no arguments for the method
319 | if (parameterClasses == null)
320 | parameterClasses = new Class>[0];
321 |
322 | return parameterClasses;
323 | }
324 | ```
325 |
326 |
327 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.72'
5 | repositories {
6 | google()
7 | jcenter()
8 |
9 | }
10 | dependencies {
11 | classpath 'com.android.tools.build:gradle:4.0.0'
12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
13 | // NOTE: Do not place your application dependencies here; they belong
14 | // in the individual module build.gradle files
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | maven { url 'https://jitpack.io' }
23 | }
24 | }
25 |
26 | task clean(type: Delete) {
27 | delete rootProject.buildDir
28 | }
29 |
--------------------------------------------------------------------------------
/buildsystem/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/buildsystem/debug.keystore
--------------------------------------------------------------------------------
/buildsystem/default.properties:
--------------------------------------------------------------------------------
1 | # keystore
2 | keyAlias= androiddebugkey
3 | keyPassword= android
4 | storeFile= ../buildsystem/debug.keystore
5 | storePassword= android
6 |
7 | # other
8 | JPUSH_APPKEY =
9 |
10 | #测试的
11 | UMENG_APPKEY_DEV =
12 | #正式的
13 | UMENG_APPKEY =
14 |
15 | BUGLY_KEY_DEV =
16 | BUGLY_KEY =
17 |
18 | #sentry
19 | SENTRY_DSN_DEV =
20 | SENTRY_DSN =
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/demo/README.md:
--------------------------------------------------------------------------------
1 | # Xposed系列之Demo上手指南及源码解析(一)
2 |
3 | 先附上Demo代码地址:https://github.com/xbdcc/CXposed/tree/master/demo
4 |
5 | ## Xposed简介
6 | 百度百科介绍:
7 | > Xposed框架(Xposed Framework)是一套开源的、在Android高权限模式下运行的框架服务,可以在不修改APK文件的情况下影响程序运行(修改系统)的框架服务,基于它可以制作出许多功能强大的模块,且在功能不冲突的情况下同时运作。`
8 |
9 | ## Xposed相关工具
10 | - [Xposed Installer](https://github.com/rovo89/XposedInstaller/):为安装在手机上的Xposed的主体运行框架,
11 | 手机需要Root权限安装Xposed框架,可以管理Xposed模块
12 | - [VirtualXposed](https://github.com/android-hacker/VirtualXposed):一个简单的应用程序,无需root用户即可使用Xposed,解锁引导程序或修改系统映像等
13 | - [太极](https://github.com/taichi-framework/TaiChi):一个带有或不带有Root/BL锁的Xposed模块框架,支持Android 5.0〜10
14 |
15 | 三个工具首页分别长这样:
16 |
17 | Xposed Installer|VirtualXposed|太极
18 | :-:|:-:|:-:
19 | ||
20 |
21 |
22 | ## Xposed Demo
23 |
24 | ### 新建项目配置Xposed环境
25 | - 首先创建创建一个Android Studio项目,然后New一个Module,我们要使用Xposed就需要引入Xposed库,在`build.gradle`加入
26 | ```
27 | compileOnly 'de.robv.android.xposed:api:82'
28 | ```
29 | - 然后在`AndroidManifest.xml`的`application`节点下加入如下配置
30 |
31 | ```xml
32 |
35 |
38 |
41 | ```
42 |
43 | ### 编写Hook代码
44 |
45 | - 新建一个类,里面写一些方法和变量后面使用,如`DemoClass`:
46 | ```kotlin
47 | class DemoClass {
48 |
49 | private val name = "carlos"
50 |
51 | fun printlnName() {
52 | log("name is:$name")
53 | }
54 |
55 | companion object {
56 |
57 | @JvmStatic
58 | fun printlnHelloWorld() {
59 | log("hello world!")
60 | }
61 |
62 | }
63 |
64 | }
65 | ```
66 |
67 | - 接下来新建一个继承自`IXposedHookLoadPackage`的类,如:
68 | ```kotlin
69 | class MainHook : IXposedHookLoadPackage {
70 |
71 | override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
72 | }
73 |
74 | }
75 |
76 | ```
77 |
78 | - 使用`XposedHelpers`调用APP的方法,使用到的就是反射,Java反射也能实现该功能
79 | ```kotlin
80 | private fun hookDemoClass(lpparam: XC_LoadPackage.LoadPackageParam) {
81 | // 通过类加载器加载DemoClass类
82 | val hookClass = lpparam.classLoader.loadClass("com.carlos.cxposed.demo.DemoClass") ?: return
83 | // 通过XposedHelpers调用静态方法printlnHelloWorld
84 | XposedHelpers.callStaticMethod(hookClass, "printlnHelloWorld")
85 | // 获取DemoClass的类对象
86 | val demoClass = hookClass.newInstance()
87 | // 获取私有字段name
88 | val field = hookClass.getDeclaredField("name")
89 | // 私有字段name访问属性改为公有
90 | field.isAccessible = true
91 | // 给字段name赋值为"xbd"
92 | field.set(demoClass, "xbd")
93 | // 通过XposedHelpers调用非静态方法printlnName
94 | XposedHelpers.callMethod(hookClass.newInstance(), "printlnName")
95 | }
96 | ```
97 |
98 | - 然后在`MainActivity`中增加方法被Hook,如:
99 | ```kotlin
100 | class MainActivity : AppCompatActivity() {
101 |
102 | override fun onCreate(savedInstanceState: Bundle?) {
103 | super.onCreate(savedInstanceState)
104 | setContentView(R.layout.activity_main)
105 | log(getLog())
106 | }
107 |
108 | private fun getLog() : String {
109 | return "hello world"
110 | }
111 |
112 | fun click(view: View) {
113 | log("click")
114 | }
115 |
116 | }
117 | ```
118 |
119 | - 在`MainHook`中增加如下代码对`MainActivity`的`getLog`和`click`方法进行Hook:
120 | ```kotlin
121 | private fun hookMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) {
122 | val hookClass = lpparam.classLoader.loadClass("com.carlos.cxposed.demo.MainActivity")
123 |
124 | XposedHelpers.findAndHookMethod(hookClass, "getLog", object : XC_MethodHook() {
125 | override fun beforeHookedMethod(param: MethodHookParam?) {
126 | xlog("hook before getLog")
127 | // 修改方法返回值
128 | param?.result = "this is a hook message."
129 | }
130 |
131 | override fun afterHookedMethod(param: MethodHookParam?) {
132 | xlog("hook after getLog")
133 | }
134 | })
135 |
136 | XposedHelpers.findAndHookMethod(hookClass, "click", View::class.java,
137 | object : XC_MethodReplacement() {
138 | override fun replaceHookedMethod(param: MethodHookParam?): Any {
139 | xlog("hook replace click")
140 | val thisObject = param?.thisObject ?: return ""
141 | // 修改textView的显示内容
142 | val activity = thisObject as Activity
143 | val textView = activity.findViewById(R.id.textview)
144 | textView.text = "carlos"
145 | return ""
146 | }
147 | })
148 |
149 | }
150 | ```
151 |
152 | - 最后在`main`下新建`assets`目录,在里面创建`xposed_init`文件(文件名必须是这个,后面介绍为什么必须为这个),文件里面就可以添加我们刚刚的类了,如:
153 | ```
154 | com.carlos.cxposed.demo.MainHook
155 | ```
156 |
157 | - 模拟器安装好`Xposed Installer`后,运行项目,可以看出来弹出框:
158 | 
159 | 点击重启或软重启生效,然后执行操作可以看到打印日志如下,Hook成功:
160 | ```
161 | 07-06 22:28:43.470 3965-3965/? I/Xposed: MainHook->MainHook->hook an app start:com.carlos.cxposed.demo
162 | 07-06 22:28:43.472 3965-3965/? D/MainHook->: hello world!
163 | 07-06 22:28:43.472 3965-3965/? D/MainHook->: name is:xbd
164 | 07-06 22:28:45.352 3965-3965/com.carlos.cxposed.demo I/Xposed: MainHook->hook before getLog
165 | 07-06 22:28:45.352 3965-3965/com.carlos.cxposed.demo I/Xposed: MainHook->hook after getLog
166 | 07-06 22:28:45.352 3965-3965/com.carlos.cxposed.demo D/MainHook->: this is a hook message.
167 | 07-06 22:28:51.193 3965-3965/com.carlos.cxposed.demo I/Xposed: MainHook->hook replace click
168 | ```
169 |
170 | ## Xposed原理
171 | Xposed还有C库,我们这里简单分析下我们引用的他的Java层`de.robv.android.xposed:api:82`,看下我们用到的两个类`XposedHelpers`和`XposedBridge`的源码
172 |
173 | ### XposedBridge解析
174 |
175 | - 首先找个入口,就从我们Hook类实现的`IXposedHookLoadPackage`接口开始吧,我们查看到该接口被`Xposed`自己的jar包调用的有如下几个地方:
176 | 
177 |
178 | - 跟进去new出这个接口的地方,调用到的代码块如下:
179 | ```java
180 | hookLoadPackage(new IXposedHookLoadPackage.Wrapper((IXposedHookLoadPackage) moduleInstance));
181 | ```
182 |
183 | - 跟进`hookLoadPackage`方法,可以看到这里将该接口添加到集合里存起来了
184 | ```java
185 | public static void hookLoadPackage(XC_LoadPackage callback) {
186 | synchronized (sLoadedPackageCallbacks) {
187 | sLoadedPackageCallbacks.add(callback);
188 | }
189 | }
190 | ```
191 |
192 | - 继续回来看`hookLoadPackage`方法,可以看到他是被`XposedBridge`的`loadModule`方法调用:
193 | ```java
194 | /**
195 | * Load a module from an APK by calling the init(String) method for all classes defined
196 | * in assets/xposed_init.
197 | */
198 | private static void loadModule(String apk) {
199 | log("Loading modules from " + apk);
200 |
201 | if (!new File(apk).exists()) {
202 | log(" File does not exist");
203 | return;
204 | }
205 |
206 | ClassLoader mcl = new PathClassLoader(apk, BOOTCLASSLOADER);
207 | InputStream is = mcl.getResourceAsStream("assets/xposed_init");
208 | if (is == null) {
209 | log("assets/xposed_init not found in the APK");
210 | return;
211 | }
212 |
213 | BufferedReader moduleClassesReader = new BufferedReader(new InputStreamReader(is));
214 | try {
215 | String moduleClassName;
216 | while ((moduleClassName = moduleClassesReader.readLine()) != null) {
217 | moduleClassName = moduleClassName.trim();
218 | if (moduleClassName.isEmpty() || moduleClassName.startsWith("#"))
219 | continue;
220 |
221 | try {
222 | log (" Loading class " + moduleClassName);
223 | Class> moduleClass = mcl.loadClass(moduleClassName);
224 |
225 | if (!IXposedMod.class.isAssignableFrom(moduleClass)) {
226 | log (" This class doesn't implement any sub-interface of IXposedMod, skipping it");
227 | continue;
228 | } else if (disableResources && IXposedHookInitPackageResources.class.isAssignableFrom(moduleClass)) {
229 | log (" This class requires resource-related hooks (which are disabled), skipping it.");
230 | continue;
231 | }
232 |
233 | final Object moduleInstance = moduleClass.newInstance();
234 | if (isZygote) {
235 | if (moduleInstance instanceof IXposedHookZygoteInit) {
236 | IXposedHookZygoteInit.StartupParam param = new IXposedHookZygoteInit.StartupParam();
237 | param.modulePath = apk;
238 | param.startsSystemServer = startsSystemServer;
239 | ((IXposedHookZygoteInit) moduleInstance).initZygote(param);
240 | }
241 |
242 | if (moduleInstance instanceof IXposedHookLoadPackage)
243 | hookLoadPackage(new IXposedHookLoadPackage.Wrapper((IXposedHookLoadPackage) moduleInstance));
244 |
245 | if (moduleInstance instanceof IXposedHookInitPackageResources)
246 | hookInitPackageResources(new IXposedHookInitPackageResources.Wrapper((IXposedHookInitPackageResources) moduleInstance));
247 | } else {
248 | if (moduleInstance instanceof IXposedHookCmdInit) {
249 | IXposedHookCmdInit.StartupParam param = new IXposedHookCmdInit.StartupParam();
250 | param.modulePath = apk;
251 | param.startClassName = startClassName;
252 | ((IXposedHookCmdInit) moduleInstance).initCmdApp(param);
253 | }
254 | }
255 | } catch (Throwable t) {
256 | log(t);
257 | }
258 | }
259 | } catch (IOException e) {
260 | log(e);
261 | } finally {
262 | try {
263 | is.close();
264 | } catch (IOException ignored) {}
265 | }
266 | }
267 | ```
268 |
269 | - 通过这里可以得知,他是会找APK下`assets/xposed_init`是否存在,如果不存在则会打印日志并且`return`返回不往下执行了,所以前面说的`文件名必须为xposed_init`是因为这里做了判断,如果不按规则来则Hook都会无效
270 | ```java
271 | InputStream is = mcl.getResourceAsStream("assets/xposed_init");
272 | if (is == null) {
273 | log("assets/xposed_init not found in the APK");
274 | return;
275 | }
276 | ```
277 |
278 | - 继续往上跟会发现`loadModule`方法被`loadModules`调用,而`loadModules`被`main`函数调用,也就是Java的主函数入口,代码如下:
279 | ```java
280 | protected static void main(String[] args) {
281 | // Initialize the Xposed framework and modules
282 | try {
283 | SELinuxHelper.initOnce();
284 | SELinuxHelper.initForProcess(null);
285 |
286 | runtime = getRuntime();
287 | if (initNative()) {
288 | XPOSED_BRIDGE_VERSION = getXposedVersion();
289 | if (isZygote) {
290 | startsSystemServer = startsSystemServer();
291 | initForZygote();
292 | }
293 |
294 | loadModules();
295 | } else {
296 | log("Errors during native Xposed initialization");
297 | }
298 | } catch (Throwable t) {
299 | log("Errors during Xposed initialization");
300 | log(t);
301 | disableHooks = true;
302 | }
303 |
304 | // Call the original startup code
305 | if (isZygote)
306 | ZygoteInit.main(args);
307 | else
308 | RuntimeInit.main(args);
309 | }
310 | ```
311 |
312 | - 接下来我们看`MainHook`里我们用到的`XposedHelpers.callStaticMethod`和`XposedHelpers.callMethod`,
313 | 可以看到他们调用到的方法都是`callMethod`,而在其内部调用了`findMethodBestMatch`方法,
314 | 最终通过`invoke(obj, args)`反射来执行Hook的方法:
315 | ```java
316 | public static Object callMethod(Object obj, String methodName, Object... args) {
317 | try {
318 | return findMethodBestMatch(obj.getClass(), methodName, args).invoke(obj, args);
319 | } catch (IllegalAccessException e) {
320 | // should not happen
321 | XposedBridge.log(e);
322 | throw new IllegalAccessError(e.getMessage());
323 | } catch (IllegalArgumentException e) {
324 | throw e;
325 | } catch (InvocationTargetException e) {
326 | throw new InvocationTargetError(e.getCause());
327 | }
328 | }
329 | ```
330 |
331 | - 我们继续看`XposedHelpers.findAndHookMethod`,可以看到调用的是`XposedHelpers`的findAndHookMethod方法,将方法传入的最后一个对象转为`XC_MethodHook`,
332 | 接着通过`findMethodExact`方法传入最后一个参数前的所有参数,在`findMethodExact`方法内部又通过反射`clazz.getDeclaredMethod`找出具体的方法,
333 | 并且设置该方法访问权限为公有,所有`XposedHelpers.findAndHookMethod`公有私有方法都能Hook
334 | ```java
335 | public static XC_MethodHook.Unhook findAndHookMethod(Class> clazz, String methodName, Object... parameterTypesAndCallback) {
336 | if (parameterTypesAndCallback.length == 0 || !(parameterTypesAndCallback[parameterTypesAndCallback.length-1] instanceof XC_MethodHook))
337 | throw new IllegalArgumentException("no callback defined");
338 |
339 | XC_MethodHook callback = (XC_MethodHook) parameterTypesAndCallback[parameterTypesAndCallback.length-1];
340 | Method m = findMethodExact(clazz, methodName, getParameterClasses(clazz.getClassLoader(), parameterTypesAndCallback));
341 |
342 | return XposedBridge.hookMethod(m, callback);
343 | }
344 | ```
345 |
346 | - 接着来看看刚刚的`XposedBridge.hookMethod`,可以看到该方法内部最终通过`hookMethodNative`调用了Native层的Hook方法。
347 | 继续跟`XposedBridge.hookMethod`,会发现他又是被`hookResources`方法调用,而`hookResources`是被`initForZygote`方法调用,
348 | 而刚刚我们知道在`main`函数里调用了`initForZygote`方法,接下来我们就再看下`initForZygote`方法
349 |
350 | - 首先我们看到该类中有一个main方法入口,主要看其中的`initForZygote`和`loadModules`方法,我们看下其中这段代码,
351 | 可以看到他主要是Hook了`ActivityThread`类的`handleBindApplication`这个方法,
352 | 而我们看下`ActivityThread`的源码就会发现`handleBindApplication`里面调用了`mInstrumentation.callApplicationOnCreate(app)`,
353 | 其实就是`Application`的`onCreate`,所以在`Application`的`onCreate`方法前Xposed就做了Hook拦截执行自己的方法
354 |
355 | ```java
356 | // normal process initialization (for new Activity, Service, BroadcastReceiver etc.)
357 | findAndHookMethod(ActivityThread.class, "handleBindApplication", "android.app.ActivityThread.AppBindData", new XC_MethodHook() {
358 | protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
359 | ActivityThread activityThread = (ActivityThread) param.thisObject;
360 | ApplicationInfo appInfo = (ApplicationInfo) getObjectField(param.args[0], "appInfo");
361 | String reportedPackageName = appInfo.packageName.equals("android") ? "system" : appInfo.packageName;
362 | SELinuxHelper.initForProcess(reportedPackageName);
363 | ComponentName instrumentationName = (ComponentName) getObjectField(param.args[0], "instrumentationName");
364 | if (instrumentationName != null) {
365 | XposedBridge.log("Instrumentation detected, disabling framework for " + reportedPackageName);
366 | disableHooks = true;
367 | return;
368 | }
369 | CompatibilityInfo compatInfo = (CompatibilityInfo) getObjectField(param.args[0], "compatInfo");
370 | if (appInfo.sourceDir == null)
371 | return;
372 |
373 | setObjectField(activityThread, "mBoundApplication", param.args[0]);
374 | loadedPackagesInProcess.add(reportedPackageName);
375 | LoadedApk loadedApk = activityThread.getPackageInfoNoCheck(appInfo, compatInfo);
376 | XResources.setPackageNameForResDir(appInfo.packageName, loadedApk.getResDir());
377 |
378 | LoadPackageParam lpparam = new LoadPackageParam(sLoadedPackageCallbacks);
379 | lpparam.packageName = reportedPackageName;
380 | lpparam.processName = (String) getObjectField(param.args[0], "processName");
381 | lpparam.classLoader = loadedApk.getClassLoader();
382 | lpparam.appInfo = appInfo;
383 | lpparam.isFirstApplication = true;
384 | XC_LoadPackage.callAll(lpparam);
385 |
386 | if (reportedPackageName.equals(INSTALLER_PACKAGE_NAME))
387 | hookXposedInstaller(lpparam.classLoader);
388 | }
389 | });
390 | ```
391 |
--------------------------------------------------------------------------------
/demo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 | android {
5 | compileSdkVersion 28
6 |
7 |
8 | defaultConfig {
9 | applicationId "com.carlos.cxposed.demo"
10 | minSdkVersion 15
11 | targetSdkVersion 28
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
16 |
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31 | implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
32 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
33 | testImplementation 'junit:junit:4.12'
34 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
35 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
36 |
37 | compileOnly 'de.robv.android.xposed:api:82'
38 | }
39 |
--------------------------------------------------------------------------------
/demo/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/demo/src/androidTest/java/com/carlos/cxposed/demo/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.carlos.cxposed.demo
2 |
3 | import androidx.test.InstrumentationRegistry
4 | import androidx.test.runner.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Github: https://github.com/xbdcc/.
13 | * Instrumented test, which will execute on an Android device.
14 | *
15 | * See [testing documentation](http://d.android.com/tools/testing).
16 | */
17 | @RunWith(AndroidJUnit4::class)
18 | class ExampleInstrumentedTest {
19 | @Test
20 | fun useAppContext() {
21 | // Context of the app under test.
22 | val appContext = InstrumentationRegistry.getTargetContext()
23 | assertEquals("com.carlos.test", appContext.packageName)
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
23 |
26 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/demo/src/main/assets/xposed_init:
--------------------------------------------------------------------------------
1 | com.carlos.cxposed.demo.MainHook
2 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/carlos/cxposed/demo/DemoClass.kt:
--------------------------------------------------------------------------------
1 | package com.carlos.cxposed.demo
2 |
3 | /**
4 | * _ooOoo_
5 | * o8888888o
6 | * 88" . "88
7 | * (| -_- |)
8 | * O\ = /O
9 | * ____/`---'\____
10 | * .' \\| |// `.
11 | * / \\||| : |||// \
12 | * / _||||| -:- |||||- \
13 | * | | \\\ - /// | |
14 | * | \_| ''\---/'' | |
15 | * \ .-\__ `-` ___/-. /
16 | * ___`. .' /--.--\ `. . __
17 | * ."" '< `.___\_<|>_/___.' >'"".
18 | * | | : `- \`.;`\ _ /`;.`/ - ` : | |
19 | * \ \ `-. \_ __\ /__ _/ .-` / /
20 | * ======`-.____`-.___\_____/___.-`____.-'======
21 | * `=---='
22 | * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
23 | * 佛祖保佑 永无BUG
24 | * 佛曰:
25 | * 写字楼里写字间,写字间里程序员;
26 | * 程序人员写程序,又拿程序换酒钱。
27 | * 酒醒只在网上坐,酒醉还来网下眠;
28 | * 酒醉酒醒日复日,网上网下年复年。
29 | * 但愿老死电脑间,不愿鞠躬老板前;
30 | * 奔驰宝马贵者趣,公交自行程序员。
31 | * 别人笑我忒疯癫,我笑自己命太贱;
32 | * 不见满街漂亮妹,哪个归得程序员?
33 | */
34 |
35 | /**
36 | * Github: https://github.com/xbdcc/.
37 | * Created by Carlos on 2020/7/6.
38 | */
39 | class DemoClass {
40 |
41 | private val name = "carlos"
42 |
43 | fun printlnName() {
44 | log("name is:$name")
45 | }
46 |
47 | companion object {
48 |
49 | @JvmStatic
50 | fun printlnHelloWorld() {
51 | log("hello world!")
52 | }
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/carlos/cxposed/demo/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.carlos.cxposed.demo
2 |
3 | import android.os.Bundle
4 | import android.view.View
5 | import androidx.appcompat.app.AppCompatActivity
6 |
7 | /**
8 | * _ooOoo_
9 | * o8888888o
10 | * 88" . "88
11 | * (| -_- |)
12 | * O\ = /O
13 | * ____/`---'\____
14 | * .' \\| |// `.
15 | * / \\||| : |||// \
16 | * / _||||| -:- |||||- \
17 | * | | \\\ - /// | |
18 | * | \_| ''\---/'' | |
19 | * \ .-\__ `-` ___/-. /
20 | * ___`. .' /--.--\ `. . __
21 | * ."" '< `.___\_<|>_/___.' >'"".
22 | * | | : `- \`.;`\ _ /`;.`/ - ` : | |
23 | * \ \ `-. \_ __\ /__ _/ .-` / /
24 | * ======`-.____`-.___\_____/___.-`____.-'======
25 | * `=---='
26 | * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
27 | * 佛祖保佑 永无BUG
28 | * 佛曰:
29 | * 写字楼里写字间,写字间里程序员;
30 | * 程序人员写程序,又拿程序换酒钱。
31 | * 酒醒只在网上坐,酒醉还来网下眠;
32 | * 酒醉酒醒日复日,网上网下年复年。
33 | * 但愿老死电脑间,不愿鞠躬老板前;
34 | * 奔驰宝马贵者趣,公交自行程序员。
35 | * 别人笑我忒疯癫,我笑自己命太贱;
36 | * 不见满街漂亮妹,哪个归得程序员?
37 | */
38 |
39 | /**
40 | * Github: https://github.com/xbdcc/.
41 | * Created by Carlos on 2019/1/22.
42 | */
43 | class MainActivity : AppCompatActivity() {
44 |
45 | override fun onCreate(savedInstanceState: Bundle?) {
46 | super.onCreate(savedInstanceState)
47 | setContentView(R.layout.activity_main)
48 | log(getLog())
49 | }
50 |
51 | private fun getLog(): String {
52 | return "hello world"
53 | }
54 |
55 | fun click(view: View) {
56 | log("click")
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/carlos/cxposed/demo/MainHook.kt:
--------------------------------------------------------------------------------
1 | package com.carlos.cxposed.demo
2 |
3 | import android.app.Activity
4 | import android.util.Log
5 | import android.view.View
6 | import android.widget.TextView
7 | import de.robv.android.xposed.*
8 | import de.robv.android.xposed.callbacks.XC_LoadPackage
9 |
10 | /**
11 | * _ooOoo_
12 | * o8888888o
13 | * 88" . "88
14 | * (| -_- |)
15 | * O\ = /O
16 | * ____/`---'\____
17 | * .' \\| |// `.
18 | * / \\||| : |||// \
19 | * / _||||| -:- |||||- \
20 | * | | \\\ - /// | |
21 | * | \_| ''\---/'' | |
22 | * \ .-\__ `-` ___/-. /
23 | * ___`. .' /--.--\ `. . __
24 | * ."" '< `.___\_<|>_/___.' >'"".
25 | * | | : `- \`.;`\ _ /`;.`/ - ` : | |
26 | * \ \ `-. \_ __\ /__ _/ .-` / /
27 | * ======`-.____`-.___\_____/___.-`____.-'======
28 | * `=---='
29 | * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
30 | * 佛祖保佑 永无BUG
31 | * 佛曰:
32 | * 写字楼里写字间,写字间里程序员;
33 | * 程序人员写程序,又拿程序换酒钱。
34 | * 酒醒只在网上坐,酒醉还来网下眠;
35 | * 酒醉酒醒日复日,网上网下年复年。
36 | * 但愿老死电脑间,不愿鞠躬老板前;
37 | * 奔驰宝马贵者趣,公交自行程序员。
38 | * 别人笑我忒疯癫,我笑自己命太贱;
39 | * 不见满街漂亮妹,哪个归得程序员?
40 | */
41 |
42 | /**
43 | * Github: https://github.com/xbdcc/.
44 | * Created by Carlos on 2019/1/22.
45 | */
46 | class MainHook : IXposedHookLoadPackage {
47 |
48 | private val packageName = "com.carlos.cxposed.demo"
49 |
50 | override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam) {
51 |
52 | if (packageName == lpparam.packageName) {
53 | xlog(TAG + "hook an app start:$packageName")
54 |
55 | hookDemoClass(lpparam)
56 |
57 | hookMainActivity(lpparam)
58 | }
59 | }
60 |
61 | private fun hookMainActivity(lpparam: XC_LoadPackage.LoadPackageParam) {
62 | val hookClass = lpparam.classLoader.loadClass("com.carlos.cxposed.demo.MainActivity")
63 |
64 | XposedHelpers.findAndHookMethod(hookClass, "getLog", object : XC_MethodHook() {
65 | override fun beforeHookedMethod(param: MethodHookParam?) {
66 | xlog("hook before getLog")
67 | // 修改方法返回值
68 | param?.result = "this is a hook message."
69 | }
70 |
71 | override fun afterHookedMethod(param: MethodHookParam?) {
72 | xlog("hook after getLog")
73 | }
74 | })
75 |
76 | XposedHelpers.findAndHookMethod(hookClass, "click", View::class.java,
77 | object : XC_MethodReplacement() {
78 | override fun replaceHookedMethod(param: MethodHookParam?): Any {
79 | xlog("hook replace click")
80 | val thisObject = param?.thisObject ?: return ""
81 | // 修改textView的显示内容
82 | val activity = thisObject as Activity
83 | val textView = activity.findViewById(R.id.textview)
84 | textView.text = "carlos"
85 | return ""
86 | }
87 | })
88 |
89 | }
90 |
91 | private fun hookDemoClass(lpparam: XC_LoadPackage.LoadPackageParam) {
92 | // 通过类加载器加载DemoClass类
93 | val hookClass = lpparam.classLoader.loadClass("com.carlos.cxposed.demo.DemoClass") ?: return
94 | // 通过XposedHelpers调用静态方法printlnHelloWorld
95 | XposedHelpers.callStaticMethod(hookClass, "printlnHelloWorld")
96 | // 获取DemoClass的类对象
97 | val demoClass = hookClass.newInstance()
98 | // 获取私有字段name
99 | val field = hookClass.getDeclaredField("name")
100 | // 私有字段name访问属性改为公有
101 | field.isAccessible = true
102 | // 给字段name赋值为"xbd"
103 | field.set(demoClass, "xbd")
104 | // 通过XposedHelpers调用非静态方法printlnName
105 | XposedHelpers.callMethod(demoClass, "printlnName")
106 | }
107 |
108 | }
109 |
110 | const val TAG = "MainHook->"
111 |
112 | fun log(string: String) {
113 | Log.d(TAG, string)
114 | }
115 |
116 | fun xlog(string: String) {
117 | XposedBridge.log(TAG + string)
118 | }
119 |
--------------------------------------------------------------------------------
/demo/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
13 |
19 |
22 |
25 |
26 |
27 |
28 |
34 |
35 |
--------------------------------------------------------------------------------
/demo/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
10 |
12 |
14 |
16 |
18 |
20 |
22 |
24 |
26 |
28 |
30 |
32 |
34 |
36 |
38 |
40 |
42 |
44 |
46 |
48 |
50 |
52 |
54 |
56 |
58 |
60 |
62 |
64 |
66 |
68 |
70 |
72 |
74 |
75 |
--------------------------------------------------------------------------------
/demo/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
21 |
22 |
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/demo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/demo/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #008577
4 | #00574B
5 | #D81B60
6 |
7 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | CXposed Demo
3 |
4 |
--------------------------------------------------------------------------------
/demo/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/demo/src/test/java/com/carlos/cxposed/demo/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.carlos.cxposed.demo
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Jul 04 20:14:09 CST 2020
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/res/demo/taichi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/demo/taichi.png
--------------------------------------------------------------------------------
/res/demo/virtual_xposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/demo/virtual_xposed.png
--------------------------------------------------------------------------------
/res/demo/xposed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/demo/xposed.png
--------------------------------------------------------------------------------
/res/demo/xposed_code1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/demo/xposed_code1.png
--------------------------------------------------------------------------------
/res/demo/xposed_reboot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/demo/xposed_reboot.png
--------------------------------------------------------------------------------
/res/old/alipay_money.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/old/alipay_money.jpg
--------------------------------------------------------------------------------
/res/old/old_README.md:
--------------------------------------------------------------------------------
1 | ## Screenshots
2 | ### Wechat6.7.3
3 | 
4 | ### Alipay10.1.55
5 | 
6 |
--------------------------------------------------------------------------------
/res/old/wechat_money.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/old/wechat_money.jpg
--------------------------------------------------------------------------------
/res/wechat/beat.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/beat.gif
--------------------------------------------------------------------------------
/res/wechat/beat.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/beat.mp4
--------------------------------------------------------------------------------
/res/wechat/beat_background1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/beat_background1.jpg
--------------------------------------------------------------------------------
/res/wechat/beat_background2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/beat_background2.jpg
--------------------------------------------------------------------------------
/res/wechat/beat_ui.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/beat_ui.jpg
--------------------------------------------------------------------------------
/res/wechat/get_id.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/get_id.jpg
--------------------------------------------------------------------------------
/res/wechat/jadx1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/jadx1.jpg
--------------------------------------------------------------------------------
/res/wechat/jadx2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/jadx2.jpg
--------------------------------------------------------------------------------
/res/wechat/jadx3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/jadx3.jpg
--------------------------------------------------------------------------------
/res/wechat/monitor_method.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/monitor_method.jpg
--------------------------------------------------------------------------------
/res/wechat/monitor_trace.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/monitor_trace.jpg
--------------------------------------------------------------------------------
/res/wechat/monitor_view.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/monitor_view.jpg
--------------------------------------------------------------------------------
/res/wechat/octotree.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/octotree.jpg
--------------------------------------------------------------------------------
/res/wechat/trace_html.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/trace_html.jpg
--------------------------------------------------------------------------------
/res/wechat/trace_method.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/trace_method.jpg
--------------------------------------------------------------------------------
/res/wechat/wechat.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/wechat.gif
--------------------------------------------------------------------------------
/res/wechat/wechat.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/wechat.mp4
--------------------------------------------------------------------------------
/res/wechat/wechat_apk.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/wechat_apk.jpg
--------------------------------------------------------------------------------
/res/wechat/wechat_pay1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/wechat_pay1.jpg
--------------------------------------------------------------------------------
/res/wechat/wechat_pay_method.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbdcc/CXposed/360b90f280c75c430b854dfce1d20e4f6b1c7541/res/wechat/wechat_pay_method.jpg
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':demo'
2 |
--------------------------------------------------------------------------------