151 |
152 |
153 |
154 |
155 |
156 |
--------------------------------------------------------------------------------
/dexposed/NOTICE:
--------------------------------------------------------------------------------
1 |
2 | Original work Copyright (c) 2005-2008, The Android Open Source Project
3 | Modified work Copyright (c) 2013, rovo89 and Tungstwenty
4 | Modified work Copyright (c) 2015, Alibaba Mobile Infrastructure (Android) Team
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License");
7 | you may not use this file except in compliance with the License.
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
15 |
16 | Apache License
17 | Version 2.0, January 2004
18 | http://www.apache.org/licenses/
19 |
20 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
21 |
22 | 1. Definitions.
23 |
24 | "License" shall mean the terms and conditions for use, reproduction,
25 | and distribution as defined by Sections 1 through 9 of this document.
26 |
27 | "Licensor" shall mean the copyright owner or entity authorized by
28 | the copyright owner that is granting the License.
29 |
30 | "Legal Entity" shall mean the union of the acting entity and all
31 | other entities that control, are controlled by, or are under common
32 | control with that entity. For the purposes of this definition,
33 | "control" means (i) the power, direct or indirect, to cause the
34 | direction or management of such entity, whether by contract or
35 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
36 | outstanding shares, or (iii) beneficial ownership of such entity.
37 |
38 | "You" (or "Your") shall mean an individual or Legal Entity
39 | exercising permissions granted by this License.
40 |
41 | "Source" form shall mean the preferred form for making modifications,
42 | including but not limited to software source code, documentation
43 | source, and configuration files.
44 |
45 | "Object" form shall mean any form resulting from mechanical
46 | transformation or translation of a Source form, including but
47 | not limited to compiled object code, generated documentation,
48 | and conversions to other media types.
49 |
50 | "Work" shall mean the work of authorship, whether in Source or
51 | Object form, made available under the License, as indicated by a
52 | copyright notice that is included in or attached to the work
53 | (an example is provided in the Appendix below).
54 |
55 | "Derivative Works" shall mean any work, whether in Source or Object
56 | form, that is based on (or derived from) the Work and for which the
57 | editorial revisions, annotations, elaborations, or other modifications
58 | represent, as a whole, an original work of authorship. For the purposes
59 | of this License, Derivative Works shall not include works that remain
60 | separable from, or merely link (or bind by name) to the interfaces of,
61 | the Work and Derivative Works thereof.
62 |
63 | "Contribution" shall mean any work of authorship, including
64 | the original version of the Work and any modifications or additions
65 | to that Work or Derivative Works thereof, that is intentionally
66 | submitted to Licensor for inclusion in the Work by the copyright owner
67 | or by an individual or Legal Entity authorized to submit on behalf of
68 | the copyright owner. For the purposes of this definition, "submitted"
69 | means any form of electronic, verbal, or written communication sent
70 | to the Licensor or its representatives, including but not limited to
71 | communication on electronic mailing lists, source code control systems,
72 | and issue tracking systems that are managed by, or on behalf of, the
73 | Licensor for the purpose of discussing and improving the Work, but
74 | excluding communication that is conspicuously marked or otherwise
75 | designated in writing by the copyright owner as "Not a Contribution."
76 |
77 | "Contributor" shall mean Licensor and any individual or Legal Entity
78 | on behalf of whom a Contribution has been received by Licensor and
79 | subsequently incorporated within the Work.
80 |
81 | 2. Grant of Copyright License. Subject to the terms and conditions of
82 | this License, each Contributor hereby grants to You a perpetual,
83 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
84 | copyright license to reproduce, prepare Derivative Works of,
85 | publicly display, publicly perform, sublicense, and distribute the
86 | Work and such Derivative Works in Source or Object form.
87 |
88 | 3. Grant of Patent License. Subject to the terms and conditions of
89 | this License, each Contributor hereby grants to You a perpetual,
90 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
91 | (except as stated in this section) patent license to make, have made,
92 | use, offer to sell, sell, import, and otherwise transfer the Work,
93 | where such license applies only to those patent claims licensable
94 | by such Contributor that are necessarily infringed by their
95 | Contribution(s) alone or by combination of their Contribution(s)
96 | with the Work to which such Contribution(s) was submitted. If You
97 | institute patent litigation against any entity (including a
98 | cross-claim or counterclaim in a lawsuit) alleging that the Work
99 | or a Contribution incorporated within the Work constitutes direct
100 | or contributory patent infringement, then any patent licenses
101 | granted to You under this License for that Work shall terminate
102 | as of the date such litigation is filed.
103 |
104 | 4. Redistribution. You may reproduce and distribute copies of the
105 | Work or Derivative Works thereof in any medium, with or without
106 | modifications, and in Source or Object form, provided that You
107 | meet the following conditions:
108 |
109 | (a) You must give any other recipients of the Work or
110 | Derivative Works a copy of this License; and
111 |
112 | (b) You must cause any modified files to carry prominent notices
113 | stating that You changed the files; and
114 |
115 | (c) You must retain, in the Source form of any Derivative Works
116 | that You distribute, all copyright, patent, trademark, and
117 | attribution notices from the Source form of the Work,
118 | excluding those notices that do not pertain to any part of
119 | the Derivative Works; and
120 |
121 | (d) If the Work includes a "NOTICE" text file as part of its
122 | distribution, then any Derivative Works that You distribute must
123 | include a readable copy of the attribution notices contained
124 | within such NOTICE file, excluding those notices that do not
125 | pertain to any part of the Derivative Works, in at least one
126 | of the following places: within a NOTICE text file distributed
127 | as part of the Derivative Works; within the Source form or
128 | documentation, if provided along with the Derivative Works; or,
129 | within a display generated by the Derivative Works, if and
130 | wherever such third-party notices normally appear. The contents
131 | of the NOTICE file are for informational purposes only and
132 | do not modify the License. You may add Your own attribution
133 | notices within Derivative Works that You distribute, alongside
134 | or as an addendum to the NOTICE text from the Work, provided
135 | that such additional attribution notices cannot be construed
136 | as modifying the License.
137 |
138 | You may add Your own copyright statement to Your modifications and
139 | may provide additional or different license terms and conditions
140 | for use, reproduction, or distribution of Your modifications, or
141 | for any such Derivative Works as a whole, provided Your use,
142 | reproduction, and distribution of the Work otherwise complies with
143 | the conditions stated in this License.
144 |
145 | 5. Submission of Contributions. Unless You explicitly state otherwise,
146 | any Contribution intentionally submitted for inclusion in the Work
147 | by You to the Licensor shall be under the terms and conditions of
148 | this License, without any additional terms or conditions.
149 | Notwithstanding the above, nothing herein shall supersede or modify
150 | the terms of any separate license agreement you may have executed
151 | with Licensor regarding such Contributions.
152 |
153 | 6. Trademarks. This License does not grant permission to use the trade
154 | names, trademarks, service marks, or product names of the Licensor,
155 | except as required for reasonable and customary use in describing the
156 | origin of the Work and reproducing the content of the NOTICE file.
157 |
158 | 7. Disclaimer of Warranty. Unless required by applicable law or
159 | agreed to in writing, Licensor provides the Work (and each
160 | Contributor provides its Contributions) on an "AS IS" BASIS,
161 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
162 | implied, including, without limitation, any warranties or conditions
163 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
164 | PARTICULAR PURPOSE. You are solely responsible for determining the
165 | appropriateness of using or redistributing the Work and assume any
166 | risks associated with Your exercise of permissions under this License.
167 |
168 | 8. Limitation of Liability. In no event and under no legal theory,
169 | whether in tort (including negligence), contract, or otherwise,
170 | unless required by applicable law (such as deliberate and grossly
171 | negligent acts) or agreed to in writing, shall any Contributor be
172 | liable to You for damages, including any direct, indirect, special,
173 | incidental, or consequential damages of any character arising as a
174 | result of this License or out of the use or inability to use the
175 | Work (including but not limited to damages for loss of goodwill,
176 | work stoppage, computer failure or malfunction, or any and all
177 | other commercial damages or losses), even if such Contributor
178 | has been advised of the possibility of such damages.
179 |
180 | 9. Accepting Warranty or Additional Liability. While redistributing
181 | the Work or Derivative Works thereof, You may choose to offer,
182 | and charge a fee for, acceptance of support, warranty, indemnity,
183 | or other liability obligations and/or rights consistent with this
184 | License. However, in accepting such obligations, You may act only
185 | on Your own behalf and on Your sole responsibility, not on behalf
186 | of any other Contributor, and only if You agree to indemnify,
187 | defend, and hold each Contributor harmless for any liability
188 | incurred by, or claims asserted against, such Contributor by reason
189 | of your accepting any such warranty or additional liability.
190 |
191 | END OF TERMS AND CONDITIONS
192 |
193 |
--------------------------------------------------------------------------------
/dexposed/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 21
5 | buildToolsVersion '25.0.0'
6 | defaultConfig {
7 | ndk {
8 | abiFilters "armeabi", "armeabi-v7a","x86"
9 | }
10 | }
11 | compileOptions {
12 | sourceCompatibility JavaVersion.VERSION_1_7
13 | targetCompatibility JavaVersion.VERSION_1_7
14 | }
15 | externalNativeBuild {
16 | ndkBuild {
17 | path 'src/main/jni/Android.mk'
18 | }
19 | }
20 | }
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/dexposed/build/generated/source/buildConfig/androidTest/debug/com/taobao/android/dexposed/test/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Automatically generated file. DO NOT MODIFY
3 | */
4 | package com.taobao.android.dexposed.test;
5 |
6 | public final class BuildConfig {
7 | public static final boolean DEBUG = Boolean.parseBoolean("true");
8 | public static final String APPLICATION_ID = "com.taobao.android.dexposed.test";
9 | public static final String BUILD_TYPE = "debug";
10 | public static final String FLAVOR = "";
11 | public static final int VERSION_CODE = -1;
12 | public static final String VERSION_NAME = "";
13 | }
14 |
--------------------------------------------------------------------------------
/dexposed/build/generated/source/buildConfig/debug/com/taobao/android/dexposed/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Automatically generated file. DO NOT MODIFY
3 | */
4 | package com.taobao.android.dexposed;
5 |
6 | public final class BuildConfig {
7 | public static final boolean DEBUG = Boolean.parseBoolean("true");
8 | public static final String APPLICATION_ID = "com.taobao.android.dexposed";
9 | public static final String BUILD_TYPE = "debug";
10 | public static final String FLAVOR = "";
11 | public static final int VERSION_CODE = 1;
12 | public static final String VERSION_NAME = "0.1.0";
13 | }
14 |
--------------------------------------------------------------------------------
/dexposed/build/generated/source/buildConfig/release/com/taobao/android/dexposed/BuildConfig.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Automatically generated file. DO NOT MODIFY
3 | */
4 | package com.taobao.android.dexposed;
5 |
6 | public final class BuildConfig {
7 | public static final boolean DEBUG = false;
8 | public static final String APPLICATION_ID = "com.taobao.android.dexposed";
9 | public static final String BUILD_TYPE = "release";
10 | public static final String FLAVOR = "";
11 | public static final int VERSION_CODE = 1;
12 | public static final String VERSION_NAME = "0.1.0";
13 | }
14 |
--------------------------------------------------------------------------------
/dexposed/build/generated/source/r/androidTest/debug/com/taobao/android/dexposed/R.java:
--------------------------------------------------------------------------------
1 | /* AUTO-GENERATED FILE. DO NOT MODIFY.
2 | *
3 | * This class was automatically generated by the
4 | * gradle plugin from the resource data it found. It
5 | * should not be modified by hand.
6 | */
7 | package com.taobao.android.dexposed;
8 |
9 | public final class R {
10 | }
11 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/bundles/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/bundles/default/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/bundles/default/classes.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/bundles/default/classes.jar
--------------------------------------------------------------------------------
/dexposed/build/intermediates/bundles/default/jni/armeabi-v7a/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/bundles/default/jni/armeabi-v7a/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/bundles/default/jni/armeabi-v7a/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/bundles/default/jni/armeabi-v7a/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/bundles/default/jni/armeabi/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/bundles/default/jni/armeabi/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/bundles/default/jni/armeabi/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/bundles/default/jni/armeabi/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/BuildConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/BuildConfig.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/ClassUtils.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/ClassUtils.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DalvikArt.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DalvikArt.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DeviceCheck.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DeviceCheck.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DexposedBridge$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DexposedBridge$1.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DexposedBridge$AdditionalHookInfo.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DexposedBridge$AdditionalHookInfo.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DexposedBridge$CopyOnWriteSortedSet.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DexposedBridge$CopyOnWriteSortedSet.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DexposedBridge.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/DexposedBridge.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodHook$MethodHookParam.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodHook$MethodHookParam.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodHook$Unhook.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodHook$Unhook.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodHook$XC_MethodKeepHook.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodHook$XC_MethodKeepHook.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodHook.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodHook.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodReplacement$1.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodReplacement$1.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodReplacement$2.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodReplacement$2.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodReplacement$XC_MethodKeepReplacement.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodReplacement$XC_MethodKeepReplacement.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodReplacement.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XC_MethodReplacement.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XposedHelpers$ClassNotFoundError.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XposedHelpers$ClassNotFoundError.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XposedHelpers$InvocationTargetError.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XposedHelpers$InvocationTargetError.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XposedHelpers.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/XposedHelpers.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/callbacks/IXUnhook.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/callbacks/IXUnhook.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/callbacks/XCallback$Param$SerializeWrapper.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/callbacks/XCallback$Param$SerializeWrapper.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/callbacks/XCallback$Param.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/callbacks/XCallback$Param.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/callbacks/XCallback.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/classes/release/com/taobao/android/dexposed/callbacks/XCallback.class
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental-safeguard/release/tag.txt:
--------------------------------------------------------------------------------
1 | incremental task execution
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/compileDebugAidl/dependency.store:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/compileDebugAndroidTestAidl/dependency.store:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/compileReleaseAidl/dependency.store:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/mergeDebugAndroidTestResources/compile-file-map.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 30 19:30:11 CST 2017
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/mergeDebugAndroidTestResources/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/mergeDebugAssets/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/mergeDebugShaders/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/mergeReleaseAssets/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/mergeReleaseJniLibFolders/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/mergeReleaseShaders/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/packageDebugResources/compile-file-map.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 30 19:30:11 CST 2017
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/packageDebugResources/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/packageReleaseResources/compile-file-map.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 30 19:30:11 CST 2017
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/incremental/packageReleaseResources/merger.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/jniLibs/release/armeabi-v7a/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/jniLibs/release/armeabi-v7a/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/jniLibs/release/armeabi-v7a/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/jniLibs/release/armeabi-v7a/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/jniLibs/release/armeabi/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/jniLibs/release/armeabi/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/jniLibs/release/armeabi/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/jniLibs/release/armeabi/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/manifest/androidTest/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
8 |
9 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/manifests/aapt/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/manifests/aapt/release/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/dexposed/build/intermediates/res/resources-debug-androidTest.ap_:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/res/resources-debug-androidTest.ap_
--------------------------------------------------------------------------------
/dexposed/build/intermediates/transforms/mergeJniLibs/release/folders/2000/3/main/lib/armeabi-v7a/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/transforms/mergeJniLibs/release/folders/2000/3/main/lib/armeabi-v7a/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/transforms/mergeJniLibs/release/folders/2000/3/main/lib/armeabi-v7a/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/transforms/mergeJniLibs/release/folders/2000/3/main/lib/armeabi-v7a/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/transforms/mergeJniLibs/release/folders/2000/3/main/lib/armeabi/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/transforms/mergeJniLibs/release/folders/2000/3/main/lib/armeabi/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/transforms/mergeJniLibs/release/folders/2000/3/main/lib/armeabi/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/transforms/mergeJniLibs/release/folders/2000/3/main/lib/armeabi/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/transforms/stripDebugSymbol/release/folders/2000/3/main/lib/armeabi-v7a/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/transforms/stripDebugSymbol/release/folders/2000/3/main/lib/armeabi-v7a/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/transforms/stripDebugSymbol/release/folders/2000/3/main/lib/armeabi-v7a/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/transforms/stripDebugSymbol/release/folders/2000/3/main/lib/armeabi-v7a/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/transforms/stripDebugSymbol/release/folders/2000/3/main/lib/armeabi/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/transforms/stripDebugSymbol/release/folders/2000/3/main/lib/armeabi/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/build/intermediates/transforms/stripDebugSymbol/release/folders/2000/3/main/lib/armeabi/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/intermediates/transforms/stripDebugSymbol/release/folders/2000/3/main/lib/armeabi/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/build/outputs/aar/dexposed-debug.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/outputs/aar/dexposed-debug.aar
--------------------------------------------------------------------------------
/dexposed/build/outputs/aar/dexposed-release.aar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/build/outputs/aar/dexposed-release.aar
--------------------------------------------------------------------------------
/dexposed/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/dexposed/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Mar 19 19:33:06 CST 2015
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-2.2.1-all.zip
7 |
--------------------------------------------------------------------------------
/dexposed/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
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 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/dexposed/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/dexposed/local.properties:
--------------------------------------------------------------------------------
1 | ## This file is automatically generated by Android Studio.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must *NOT* be checked into Version Control Systems,
5 | # as it contains information specific to your local configuration.
6 | #
7 | # Location of the SDK. This is only used by Gradle.
8 | # For customization when using a Version Control System, please read the
9 | # header note.
10 | #Fri Apr 07 16:20:34 CST 2017
11 | ndk.dir=/Users/zhangzhongping/Library/Android/sdk/ndk-bundle
12 | sdk.dir=/Users/zhangzhongping/Library/Android/sdk
13 |
--------------------------------------------------------------------------------
/dexposed/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/DalvikArt.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed;
2 |
3 | import android.app.Application;
4 | import android.util.Base64;
5 |
6 | import com.taobao.android.dexposed.DexUtils.DexLoaderReplace;
7 | import com.taobao.android.dexposed.DexUtils.ReplaceResult;
8 | import com.taobao.android.dexposed.HookArt.utils.HookResult;
9 | import com.taobao.android.dexposed.HookArt.utils.HookUtils;
10 | import com.taobao.android.dexposed.annotations.Hook;
11 | import com.taobao.android.dexposed.annotations.Hooks;
12 | import com.taobao.android.dexposed.callbacks.DexLoaderCallBack;
13 |
14 | import java.util.ArrayList;
15 | import java.util.List;
16 |
17 |
18 | /**
19 | * 作者:zhangzhongping on 17/4/11 12:40
20 | * 邮箱:android_dy@163.com
21 | */
22 | public class DalvikArt {
23 |
24 | /**
25 | * 此方法用于替换内存中dex
26 | * 参数1:Application
27 | * 参数2:需要替换dex的路径
28 | * 参数3:替换完成后接口回调
29 | *
30 | * @author zhangzhongping
31 | * created at 17/4/17 19:35
32 | */
33 | public synchronized static void DexLoaderReplace(Application application, String dexPath, DexLoaderCallBack dexLoaderCallBack) {
34 | ReplaceResult replaceResult = DexLoaderReplace.injectAboveEqualApiLevel14(application, dexPath);
35 | if (dexLoaderCallBack != null) {
36 | dexLoaderCallBack.DexReplaceFinish(replaceResult);
37 | }
38 | }
39 |
40 | /**
41 | * 参数1 = Application
42 | * 参数2 = Hook 或 Hooks注解类
43 | *
Can use {@link MethodHookParam#setResult(Object)} and {@link MethodHookParam#setThrowable(Throwable)}
38 | * to prevent the original method from being called.
39 | */
40 | public abstract MethodHookParam beforeHookedMethod(MethodHookParam param) throws Throwable;
41 |
42 | /**
43 | * Called after the invocation of the method.
44 | *
Can use {@link MethodHookParam#setResult(Object)} and {@link MethodHookParam#setThrowable(Throwable)}
45 | * to modify the return value of the original method.
46 | */
47 | public abstract MethodHookParam afterHookedMethod(MethodHookParam param) throws Throwable;
48 |
49 |
50 | public static class MethodHookParam extends XCallback.Param {
51 | public XC_MethodHook HookMethod;
52 |
53 | public String Model = "NULL";
54 | /**
55 | * Description of the hooked method
56 | */
57 | public Member method;
58 | /**
59 | * The this reference for an instance method, or null for static methods
60 | */
61 | public Object thisObject;
62 | /**
63 | * Arguments to the method call
64 | */
65 | public Object[] args;
66 | private Object result = new Object();
67 | private Throwable throwable = null;
68 | /* package */ boolean returnEarly = false;
69 |
70 | /**
71 | * Returns the result of the method call
72 | */
73 | public Object getResult() {
74 | return result;
75 | }
76 |
77 | public boolean isEquals(XC_MethodHook xc_methodHook) {
78 | if (HookMethod == xc_methodHook || Model.equals("dalvik")) {
79 | return true;
80 | }
81 | return false;
82 | }
83 |
84 | /**
85 | * Modify the result of the method call. In a "before-method-call"
86 | * hook, prevents the call to the original method.
87 | * You still need to "return" from the hook handler if required.
88 | */
89 | public void setResult(Object result) {
90 | this.result = result;
91 | this.throwable = null;
92 | this.returnEarly = true;
93 | }
94 |
95 | /**
96 | * Returns the Throwable thrown by the method, or null
97 | */
98 | public Throwable getThrowable() {
99 | return throwable;
100 | }
101 |
102 | /**
103 | * Returns true if an exception was thrown by the method
104 | */
105 | public boolean hasThrowable() {
106 | return throwable != null;
107 | }
108 |
109 | /**
110 | * Modify the exception thrown of the method call. In a "before-method-call"
111 | * hook, prevents the call to the original method.
112 | * You still need to "return" from the hook handler if required.
113 | */
114 | public void setThrowable(Throwable throwable) {
115 | this.throwable = throwable;
116 | this.result = null;
117 | this.returnEarly = true;
118 | }
119 |
120 | /**
121 | * Returns the result of the method call, or throws the Throwable caused by it
122 | */
123 | public Object getResultOrThrowable() throws Throwable {
124 | if (throwable != null)
125 | throw throwable;
126 | return result;
127 | }
128 | }
129 |
130 | public class Unhook implements IXUnhook {
131 | private final Member hookMethod;
132 |
133 | public Unhook(Member hookMethod) {
134 | this.hookMethod = hookMethod;
135 | }
136 |
137 | public Member getHookedMethod() {
138 | return hookMethod;
139 | }
140 |
141 | public XC_MethodHook getCallback() {
142 | return XC_MethodHook.this;
143 | }
144 |
145 | @Override
146 | public void unhook() {
147 | DexposedBridge.unhookMethod(hookMethod, XC_MethodHook.this);
148 | }
149 |
150 | }
151 |
152 | /**
153 | * Note: This class used for distinguish the Method cann't unhook.
154 | */
155 | public abstract class XC_MethodKeepHook extends XC_MethodHook {
156 |
157 | public XC_MethodKeepHook() {
158 | super();
159 | }
160 |
161 | public XC_MethodKeepHook(int priority) {
162 | super(priority);
163 | }
164 |
165 | }
166 |
167 |
168 | }
169 |
170 |
171 |
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/XC_MethodReplacement.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2005-2008, The Android Open Source Project
3 | * Modified work Copyright (c) 2013, rovo89 and Tungstwenty
4 | * Modified work Copyright (c) 2015, Alibaba Mobile Infrastructure (Android) Team
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package com.taobao.android.dexposed;
20 |
21 |
22 | public abstract class XC_MethodReplacement extends XC_MethodHook {
23 | public XC_MethodReplacement() {
24 | super();
25 | }
26 |
27 | public XC_MethodReplacement(int priority) {
28 | super(priority);
29 | }
30 |
31 | @Override
32 | public final MethodHookParam beforeHookedMethod(MethodHookParam param) throws Throwable {
33 | try {
34 | param = replaceHookedMethod(param);
35 | param.returnEarly = true;
36 | return param;
37 | } catch (Throwable t) {
38 | param.setThrowable(t);
39 | }
40 | return param;
41 | }
42 |
43 | public final MethodHookParam afterHookedMethod(MethodHookParam param) throws Throwable {
44 | return param;
45 | }
46 |
47 | /**
48 | * Shortcut for replacing a method completely. Whatever is returned/thrown here is taken
49 | * instead of the result of the original method (which will not be called).
50 | */
51 | public abstract MethodHookParam replaceHookedMethod(MethodHookParam param) throws Throwable;
52 |
53 | public static final XC_MethodReplacement DO_NOTHING = new XC_MethodReplacement(PRIORITY_HIGHEST * 2) {
54 | @Override
55 | public MethodHookParam replaceHookedMethod(MethodHookParam param) throws Throwable {
56 | return param;
57 | }
58 | };
59 |
60 | /**
61 | * Creates a callback which always returns a specific value
62 | */
63 | public static XC_MethodReplacement returnConstant(final Object result) {
64 | return returnConstant(PRIORITY_DEFAULT, result);
65 | }
66 |
67 | /**
68 | * @see #returnConstant(Object)
69 | */
70 | public static XC_MethodReplacement returnConstant(int priority, final Object result) {
71 | return new XC_MethodReplacement(priority) {
72 | @Override
73 | public MethodHookParam replaceHookedMethod(MethodHookParam param) throws Throwable {
74 | return param;
75 | }
76 | };
77 | }
78 |
79 |
80 | /**
81 | * Note: This class used for distinguish the Method cann't unhook.
82 | */
83 | public abstract class XC_MethodKeepReplacement extends XC_MethodReplacement {
84 | public XC_MethodKeepReplacement() {
85 | super();
86 | }
87 |
88 | public XC_MethodKeepReplacement(int priority) {
89 | super(priority);
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/annotations/Hook.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Class = 需要hook的类
10 | * Name = 需要hook的方法名
11 | * Type = 需要hook方法的参数(如 :String.class)
12 | * returnVal = 需要hook方法的返回值(如 : String.class)
13 | * 作者:zhangzhongping on 17/4/11 17:13
14 | * 邮箱:android_dy@163.com
15 | */
16 | @Retention(RetentionPolicy.RUNTIME)
17 | @Target(ElementType.TYPE)
18 | public @interface Hook {
19 |
20 | String Class();
21 |
22 | String Name();
23 |
24 | Class> returnVal();
25 |
26 | boolean isStatic();
27 |
28 | Class[] Parameter() default {};
29 | }
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/annotations/HookMethod.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * 作者:zhangzhongping on 17/4/11 17:14
10 | * 邮箱:android_dy@163.com
11 | */
12 | @Target(ElementType.METHOD)
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Deprecated
15 | public @interface HookMethod {
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/annotations/Hooks.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Class = 需要hook的类
10 | * Name = 需要hook的方法名
11 | * Type = 需要hook方法的参数(如 : java.long.String)
12 | * returnVal = 需要hook方法的返回值(如 : java.long.String , void , int , int[])
13 | * 此注释是为了方便hook一些无法用.class获取参数的方法设计
14 | * (例如编写一些第三方应用的注入插件 一些自定义参数我们在我们的工程中无法获取.class参数 直接只需要设置参数的类字符串即可)
15 | * 作者:zhangzhongping on 17/4/11 17:13
16 | * 邮箱:android_dy@163.com
17 | */
18 | @Retention(RetentionPolicy.RUNTIME)
19 | @Target(ElementType.TYPE)
20 | public @interface Hooks {
21 |
22 | String Class();
23 |
24 | String Name();
25 |
26 | String returnVal();
27 |
28 | boolean isStatic();
29 |
30 | String[] Parameter() default {};
31 | }
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/annotations/OriginalHookMethod.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * 作者:zhangzhongping on 17/4/11 17:15
10 | * 邮箱:android_dy@163.com
11 | */
12 | @Target(ElementType.METHOD)
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Deprecated
15 | public @interface OriginalHookMethod {
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/callbacks/DexLoaderCallBack.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.callbacks;
2 |
3 | import com.taobao.android.dexposed.DexUtils.ReplaceResult;
4 |
5 | /**
6 | * 作者:zhangzhongping on 17/4/17 19:25
7 | * 邮箱:android_dy@163.com
8 | */
9 | public interface DexLoaderCallBack {
10 |
11 | void DexReplaceFinish(ReplaceResult replaceResult);
12 | }
13 |
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/callbacks/IXUnhook.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2005-2008, The Android Open Source Project
3 | * Modified work Copyright (c) 2013, rovo89 and Tungstwenty
4 | * Modified work Copyright (c) 2015, Alibaba Mobile Infrastructure (Android) Team
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package com.taobao.android.dexposed.callbacks;
20 |
21 |
22 | public interface IXUnhook {
23 | void unhook();
24 | }
25 |
--------------------------------------------------------------------------------
/dexposed/src/main/java/com/taobao/android/dexposed/callbacks/XCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Original work Copyright (c) 2005-2008, The Android Open Source Project
3 | * Modified work Copyright (c) 2013, rovo89 and Tungstwenty
4 | * Modified work Copyright (c) 2015, Alibaba Mobile Infrastructure (Android) Team
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | package com.taobao.android.dexposed.callbacks;
20 |
21 | import java.io.Serializable;
22 |
23 | import com.taobao.android.dexposed.DexposedBridge;
24 | import com.taobao.android.dexposed.DexposedBridge.CopyOnWriteSortedSet;
25 |
26 | import android.os.Bundle;
27 |
28 | public abstract class XCallback implements Comparable {
29 | public final int priority;
30 | public XCallback() {
31 | this.priority = PRIORITY_DEFAULT;
32 | }
33 | public XCallback(int priority) {
34 | this.priority = priority;
35 | }
36 |
37 | public static class Param {
38 | public final Object[] callbacks;
39 | private Bundle extra;
40 |
41 | protected Param() {
42 | callbacks = null;
43 | }
44 |
45 | protected Param(CopyOnWriteSortedSet extends XCallback> callbacks) {
46 | this.callbacks = callbacks.getSnapshot();
47 | }
48 |
49 | /**
50 | * This can be used to store anything for the scope of the callback.
51 | * Use this instead of instance variables.
52 | * @see #getObjectExtra
53 | * @see #setObjectExtra
54 | */
55 | public synchronized Bundle getExtra() {
56 | if (extra == null)
57 | extra = new Bundle();
58 | return extra;
59 | }
60 |
61 | /** @see #setObjectExtra */
62 | public Object getObjectExtra(String key) {
63 | Serializable o = getExtra().getSerializable(key);
64 | if (o instanceof SerializeWrapper)
65 | return ((SerializeWrapper) o).object;
66 | return null;
67 | }
68 |
69 | /** Provides a wrapper to store Objects in extra. */
70 | public void setObjectExtra(String key, Object o) {
71 | getExtra().putSerializable(key, new SerializeWrapper(o));
72 | }
73 |
74 | private static class SerializeWrapper implements Serializable {
75 | private static final long serialVersionUID = 1L;
76 | private Object object;
77 | public SerializeWrapper(Object o) {
78 | object = o;
79 | }
80 | }
81 | }
82 |
83 | public static final void callAll(Param param) {
84 | if (param.callbacks == null)
85 | throw new IllegalStateException("This object was not created for use with callAll");
86 |
87 | for (int i = 0; i < param.callbacks.length; i++) {
88 | try {
89 | ((XCallback) param.callbacks[i]).call(param);
90 | } catch (Throwable t) { DexposedBridge.log(t); }
91 | }
92 | }
93 |
94 | protected void call(Param param) throws Throwable {}
95 |
96 | @Override
97 | public int compareTo(XCallback other) {
98 | if (this == other)
99 | return 0;
100 | // order descending by priority
101 | if (other.priority != this.priority)
102 | return other.priority - this.priority;
103 | // then randomly
104 | else if (System.identityHashCode(this) < System.identityHashCode(other))
105 | return -1;
106 | else
107 | return 1;
108 | }
109 |
110 | public static final int PRIORITY_DEFAULT = 50;
111 | /** Call this handler last */
112 | public static final int PRIORITY_LOWEST = -10000;
113 | /** Call this handler first */
114 | public static final int PRIORITY_HIGHEST = 10000;
115 | }
116 |
--------------------------------------------------------------------------------
/dexposed/src/main/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH:= $(call my-dir)
2 | include $(CLEAR_VARS)
3 | LOCAL_SRC_FILES:= HookMain.c
4 | LOCAL_LDLIBS := -llog
5 |
6 | LOCAL_MODULE:= dexposed_art
7 |
8 | include $(BUILD_SHARED_LIBRARY)
9 |
--------------------------------------------------------------------------------
/dexposed/src/main/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_ABI := armeabi armeabi-v7a x86
2 |
--------------------------------------------------------------------------------
/dexposed/src/main/jni/HookMain.c:
--------------------------------------------------------------------------------
1 | #include "jni.h"
2 | #include
3 | #include
4 | #include
5 |
6 | #define LOG_TAG "YAHFA-Native"
7 | #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
8 | #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
9 | #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
10 |
11 | #define DEFAULT_CAP 100
12 |
13 | #define MAX(x, y) (((x) > (y)) ? (x) : (y))
14 | #define roundUpTo4(v) ((v+4-1) - ((v+4-1)&3))
15 |
16 | #define ANDROID_L 21
17 | #define ANDROID_L2 22
18 | #define ANDROID_M 23
19 | #define ANDROID_N 24
20 | #define ANDROID_N2 25
21 |
22 |
23 | static int SDKVersion;
24 |
25 | static int OFFSET_dex_cache_resolved_methods_in_ArtMethod;
26 | static int OFFSET_entry_point_from_interpreter_in_ArtMethod;
27 | static int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod;
28 | static int OFFSET_dex_method_index_in_ArtMethod;
29 | static int OFFSET_hotness_count_in_ArtMethod;
30 | static int OFFSET_array_in_PointerArray;
31 | static int OFFSET_ArtMehod_in_Object;
32 | static size_t pointer_size;
33 | static size_t ArtMethodSize;
34 | static int SupportAndNot;
35 | static unsigned int hookCap; // capacity for trampolines
36 | static unsigned int hookCount; // current count of used trampolines
37 | static unsigned char *trampolineCode; // place where trampolines are saved
38 | static unsigned int trampolineSize; // trampoline size required for each hook
39 | static unsigned int trampolineCodeSize; // total size of trampoline code area
40 |
41 |
42 | // trampoline1: set eax to a new ArtMethod addr and then jump into its entry point
43 | #if defined(__i386__)
44 | // b8 78 56 34 12 ; mov eax, 0x12345678
45 | // ff 70 20 ; push dword [eax + 0x20]
46 | // c3 ; ret
47 | static unsigned char trampoline1[] = {0xb8, 0x78, 0x56, 0x34, 0x12, 0xff, 0x70, 0x20, 0xc3};
48 | static unsigned int t1Size = roundUpTo4(sizeof(trampoline1)); // for alignment
49 | #elif defined(__arm__)
50 | // 00 00 9F E5 ; ldr r0, [pc]
51 | // 20 F0 90 E5 ; ldr pc, [r0, 0x20]
52 | // 78 56 34 12 ; 0x12345678
53 | static unsigned char trampoline1[] = {0x00, 0x00, 0x9f, 0xe5, 0x20, 0xf0, 0x90, 0xe5, 0x78, 0x56, 0x34, 0x12};
54 | static unsigned int t1Size = sizeof(trampoline1);
55 | #else
56 | #error Unsupported architecture
57 | #endif
58 |
59 | // trampoline2: clear hotness_count of ArtMethod in eax and then jump into its entry point
60 | #if defined(__i386__)
61 | // 66 c7 40 12 00 00 ; mov word [eax + 0x12], 0
62 | // 68 78 56 34 12 ; push 0x12345678
63 | // c3 ; ret
64 | static unsigned char trampoline2[] = {0x66, 0xc7, 0x40, 0x12, 0x00, 0x00, 0x68, 0x78, 0x56, 0x34, 0x12, 0xc3};
65 | static unsigned int t2Size = roundUpTo4(sizeof(trampoline2)); // for alignment
66 | #elif defined(__arm__)
67 | // 04 40 2D E5 ; push {r4}
68 | // 00 40 A0 E3 ; mov r4, #0
69 | // B2 41 C0 E1 ; strh r4, [r0, #18]
70 | // 04 40 9D E4 ; pop {r4}
71 | // 78 56 34 12 ; 0x12345678
72 | static unsigned char trampoline2[] = {
73 | 0x04, 0x40, 0x2d, 0xe5,
74 | 0x00, 0x40, 0xa0, 0xe3,
75 | 0xb2, 0x41, 0xc0, 0xe1,
76 | 0x04, 0x40, 0x9d, 0xe4,
77 | 0x04, 0xF0, 0x1F, 0xE5,
78 | 0x78, 0x56, 0x34, 0x12
79 | };
80 | static unsigned int t2Size = sizeof(trampoline2);
81 | #else
82 | #error Unsupported architecture
83 | #endif
84 |
85 | static unsigned int read32(void *addr) {
86 | return *((unsigned int*)addr);
87 | }
88 |
89 | static unsigned long read64(void *addr) {
90 | return *((unsigned long*)addr);
91 | }
92 |
93 | static unsigned long readAddr(void *addr) {
94 | if(pointer_size == 4) {
95 | return read32(addr);
96 | }
97 | else if(pointer_size == 8) {
98 | return read64(addr);
99 | }
100 | else {
101 | LOGE("unknown pointer size %d", pointer_size);
102 | return 0;
103 | }
104 | }
105 |
106 | static int doInitHookCap(unsigned int cap) {
107 | if(cap == 0) {
108 | LOGE("invalid capacity: %d", cap);
109 | return 1;
110 | }
111 | if(hookCap) {
112 | LOGW("allocating new space for trampoline code");
113 | }
114 | int allSize = trampolineSize*cap;
115 | char *buf = mmap(NULL, allSize, PROT_READ, MAP_ANON | MAP_PRIVATE, -1, 0);
116 | if(buf == MAP_FAILED) {
117 | LOGE("mmap failed");
118 | return 1;
119 | }
120 | hookCap = cap;
121 | hookCount = 0;
122 | trampolineCode = buf;
123 | trampolineCodeSize = allSize;
124 | return 0;
125 | }
126 |
127 | static void *genTrampoline1(void *hookMethod) {
128 | void *targetAddr;
129 | if(mprotect(trampolineCode, trampolineCodeSize, PROT_READ | PROT_WRITE) == -1) {
130 | LOGE("mprotect RW failed");
131 | return NULL;
132 | }
133 | targetAddr = trampolineCode + trampolineSize*hookCount;
134 | memcpy(targetAddr, trampoline1, sizeof(trampoline1)); // do not use t1size since it's a rounded size
135 |
136 | // replace with hook ArtMethod addr
137 | #if defined(__i386__)
138 | memcpy(targetAddr+1, &hookMethod, pointer_size);
139 | #elif defined(__arm__)
140 | memcpy(targetAddr+8, &hookMethod, pointer_size);
141 | #endif
142 |
143 | if(mprotect(trampolineCode, trampolineCodeSize, PROT_READ | PROT_EXEC) == -1) {
144 | LOGE("mprotect RX failed");
145 | return NULL;
146 | }
147 | return targetAddr;
148 | }
149 |
150 | static void *genTrampoline2(void *entryPoint) {
151 | void *targetAddr;
152 | if(mprotect(trampolineCode, trampolineCodeSize, PROT_READ | PROT_WRITE) == -1) {
153 | LOGE("mprotect RW failed");
154 | return NULL;
155 | }
156 | targetAddr = trampolineCode + trampolineSize*hookCount + t1Size;
157 | memcpy(targetAddr, trampoline2, sizeof(trampoline2)); // do not use t2size since it's a rounded size
158 |
159 | // replace with real entrypoint
160 | #if defined(__i386__)
161 | memcpy(targetAddr+7, &entryPoint, pointer_size);
162 | #elif defined(__arm__)
163 | memcpy(targetAddr+16, &entryPoint, pointer_size);
164 | #endif
165 |
166 | if(mprotect(trampolineCode, trampolineCodeSize, PROT_READ | PROT_EXEC) == -1) {
167 | LOGE("mprotect RX failed");
168 | return NULL;
169 | }
170 | return targetAddr;
171 | }
172 |
173 | void Java_com_taobao_android_dexposed_DexposedBridge_init(JNIEnv *env, jclass clazz, jint sdkVersion) {
174 | SDKVersion = sdkVersion;
175 | switch(sdkVersion) {
176 | case ANDROID_N2:
177 | SupportAndNot = 0;
178 | case ANDROID_N:
179 | LOGI("init to SDK %d", sdkVersion);
180 | SupportAndNot = ANDROID_N;
181 | OFFSET_dex_cache_resolved_methods_in_ArtMethod = 20;
182 | OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod = 32;
183 | OFFSET_dex_method_index_in_ArtMethod = 12;
184 | OFFSET_hotness_count_in_ArtMethod = 18;
185 | OFFSET_array_in_PointerArray = 0;
186 | OFFSET_ArtMehod_in_Object = 0;
187 | pointer_size = sizeof(void *);
188 | ArtMethodSize = 36;
189 | trampolineSize = t1Size + t2Size;
190 | break;
191 | case ANDROID_M:
192 | LOGI("init to SDK %d", sdkVersion);
193 | SupportAndNot = ANDROID_M;
194 | OFFSET_dex_cache_resolved_methods_in_ArtMethod = 4;
195 | OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod = 36;
196 | OFFSET_entry_point_from_interpreter_in_ArtMethod = 28;
197 | OFFSET_dex_method_index_in_ArtMethod = 20;
198 | OFFSET_array_in_PointerArray = 12;
199 | OFFSET_ArtMehod_in_Object = 0;
200 | pointer_size = sizeof(void *);
201 | ArtMethodSize = 40;
202 | trampolineSize = t1Size;
203 | break;
204 | case ANDROID_L2:
205 | LOGI("init to SDK %d", sdkVersion);
206 | SupportAndNot = ANDROID_L2;
207 | OFFSET_dex_cache_resolved_methods_in_ArtMethod = 12;
208 | OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod = 44;
209 | OFFSET_entry_point_from_interpreter_in_ArtMethod = 36;
210 | OFFSET_dex_method_index_in_ArtMethod = 28;
211 | OFFSET_array_in_PointerArray = 12;
212 | OFFSET_ArtMehod_in_Object = 8;
213 | pointer_size = sizeof(void *);
214 | ArtMethodSize = 48;
215 | trampolineSize = t1Size;
216 | break;
217 | case ANDROID_L:
218 | SupportAndNot = ANDROID_L;
219 | LOGI("init to SDK %d", sdkVersion);
220 | OFFSET_dex_cache_resolved_methods_in_ArtMethod = 12;
221 | OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod = 40;
222 | OFFSET_entry_point_from_interpreter_in_ArtMethod = 24;
223 | OFFSET_dex_method_index_in_ArtMethod = 64;
224 | OFFSET_array_in_PointerArray = 12;
225 | OFFSET_ArtMehod_in_Object = 8;
226 | pointer_size = sizeof(void *);
227 | ArtMethodSize = 72;
228 | trampolineSize = t1Size;
229 | break;
230 | default:
231 | SupportAndNot = 0;
232 | LOGE("not compatible with SDK %d", sdkVersion);
233 | break;
234 | }
235 | #if defined(__i386__)
236 | trampoline1[7] = OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod;
237 | #elif defined(__arm__)
238 | trampoline1[4] = OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod;
239 | #endif
240 | }
241 |
242 | static int doBackupAndHook(void *originMethod, void *hookMethod, void *backupMethod) {
243 | if(hookCount >= hookCap) {
244 | LOGW("not enough capacity");
245 | if(doInitHookCap(DEFAULT_CAP)) {
246 | LOGE("cannot hook method");
247 | return 1;
248 | }
249 | }
250 |
251 | // LOGI("origin method is at %p, hook method is at %p", originMethod, hookMethod);
252 | if(!backupMethod) {
253 | LOGW("backup method is null");
254 | }
255 | else { //do method backup
256 | void *dexCacheResolvedMethods = (void *)readAddr((void *)((char *)backupMethod+OFFSET_dex_cache_resolved_methods_in_ArtMethod));
257 | int methodIndex = read32((void *)((char *)backupMethod+
258 | OFFSET_dex_method_index_in_ArtMethod));
259 | //first update the cached method manually
260 | memcpy((char *)dexCacheResolvedMethods+OFFSET_array_in_PointerArray+pointer_size*methodIndex,
261 | (&backupMethod),
262 | pointer_size);
263 | //then replace the placeholder with original method
264 | memcpy((void *)((char *)backupMethod+OFFSET_ArtMehod_in_Object),
265 | (void *)((char *)originMethod+OFFSET_ArtMehod_in_Object),
266 | ArtMethodSize-OFFSET_ArtMehod_in_Object);
267 |
268 | // if Android N, then use trampoline2 to reset hotness_count
269 | if(SDKVersion >= ANDROID_N) {
270 | void *realEntryPoint = readAddr((char *) originMethod +
271 | OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod);
272 | void *newEntryPoint = genTrampoline2(realEntryPoint);
273 | if(newEntryPoint) {
274 | memcpy((char *) backupMethod + OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod,
275 | &newEntryPoint, pointer_size);
276 | }
277 | else {
278 | LOGE("failed to allocate space for backup method trampoline");
279 | return 1;
280 | }
281 | }
282 | // LOGI("backup method is at %p", backupMethod);
283 | }
284 |
285 | // replace entry point
286 | void *newEntrypoint = genTrampoline1(hookMethod);
287 | // LOGI("origin ep is %p, new ep is %p",
288 | // readAddr((char *) originMethod + OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod),
289 | // newEntrypoint
290 | // );
291 | if(newEntrypoint) {
292 | memcpy((char *) originMethod + OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod,
293 | &newEntrypoint,
294 | pointer_size);
295 | }
296 | else {
297 | LOGW("failed to allocate space for trampoline");
298 | return 1;
299 | }
300 |
301 | if(OFFSET_entry_point_from_interpreter_in_ArtMethod != 0) {
302 | memcpy((char *) originMethod + OFFSET_entry_point_from_interpreter_in_ArtMethod,
303 | (char *) hookMethod + OFFSET_entry_point_from_interpreter_in_ArtMethod,
304 | pointer_size);
305 | }
306 |
307 | LOGI("hook and backup done");
308 | hookCount += 1;
309 | return 0;
310 | }
311 |
312 | int Java_com_taobao_android_dexposed_DexposedBridge_findAndBackupAndHook(JNIEnv *env, jclass clazz,
313 | jclass targetClass, jstring methodName, jstring methodSig, jobject hook, jobject backup) {
314 | int Hookresult = 0;
315 | if(SupportAndNot == 0){
316 | return Hookresult;
317 | }
318 | if(!methodName || !methodSig) {
319 | LOGE("empty method name or signature");
320 | return Hookresult;
321 | }
322 | const char *c_methodName = (*env)->GetStringUTFChars(env, methodName, NULL);
323 | const char *c_methodSig = (*env)->GetStringUTFChars(env, methodSig, NULL);
324 | if(c_methodName == NULL || c_methodSig == NULL) {
325 | LOGE("failed to get c string");
326 | return Hookresult;
327 | }
328 | void *targetMethod = NULL;
329 | LOGI("Start findAndBackupAndHook for method %s%s", c_methodName, c_methodSig);
330 | if(pointer_size == 0) {
331 | LOGE("Not initialized");
332 | goto end;
333 | }
334 | targetMethod = (void *)(*env)->GetMethodID(env, targetClass, c_methodName, c_methodSig);
335 | if((*env)->ExceptionCheck(env)) {
336 | (*env)->ExceptionClear(env); //cannot find non-static method
337 | targetMethod = (void *)(*env)->GetStaticMethodID(env, targetClass, c_methodName, c_methodSig);
338 | if((*env)->ExceptionCheck(env)) {
339 | (*env)->ExceptionClear(env); //cannot find static method
340 | LOGE("Cannot find target method %s%s", c_methodName, c_methodSig);
341 | goto end;
342 | }
343 | }
344 | if(!doBackupAndHook(targetMethod, (void *)(*env)->FromReflectedMethod(env, hook),
345 | backup==NULL ? NULL : (void *)(*env)->FromReflectedMethod(env, backup))) {
346 | (*env)->NewGlobalRef(env, hook); // keep a global ref so that the hook method would not be GCed
347 | }
348 | Hookresult = 1;
349 | end:
350 | (*env)->ReleaseStringUTFChars(env, methodName, c_methodName);
351 | (*env)->ReleaseStringUTFChars(env, methodSig, c_methodSig);
352 | return Hookresult;
353 | }
354 |
--------------------------------------------------------------------------------
/dexposed/src/main/jniLibs/armeabi-v7a/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/src/main/jniLibs/armeabi-v7a/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/src/main/jniLibs/armeabi-v7a/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/src/main/jniLibs/armeabi-v7a/libdexposed_l.so
--------------------------------------------------------------------------------
/dexposed/src/main/jniLibs/armeabi/libdexposed.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/src/main/jniLibs/armeabi/libdexposed.so
--------------------------------------------------------------------------------
/dexposed/src/main/jniLibs/armeabi/libdexposed_l.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/dexposed/src/main/jniLibs/armeabi/libdexposed_l.so
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/androiddy/NewHooks/5f9903bc1fe6813d86a9c84d36cda86631e2a2af/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Apr 11 01:15:48 CST 2017
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
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 Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/hookinject/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/hookinject/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | sourceCompatibility = JavaVersion.VERSION_1_7
3 | targetCompatibility = JavaVersion.VERSION_1_7
4 |
5 | dependencies {
6 | compile fileTree(dir: 'libs', include: ['*.jar'])
7 | compile 'com.google.auto.service:auto-service:1.0-rc2'
8 | compile 'com.squareup:javapoet:1.7.0'
9 | }
--------------------------------------------------------------------------------
/hookinject/src/main/java/com/taobao/android/dexposed/annotations/Hook.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Class = 需要hook的类
10 | * Name = 需要hook的方法名
11 | * Type = 需要hook方法的参数(如 :String.class)
12 | * 作者:zhangzhongping on 17/4/11 17:13
13 | * 邮箱:android_dy@163.com
14 | */
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Target(ElementType.TYPE)
17 | public @interface Hook {
18 | String Class();
19 |
20 | String Name();
21 |
22 | Class> returnVal();
23 |
24 | boolean isStatic();
25 |
26 | Class[] Parameter() default {};
27 | }
--------------------------------------------------------------------------------
/hookinject/src/main/java/com/taobao/android/dexposed/annotations/Hooks.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Class = 需要hook的类
10 | * Name = 需要hook的方法名
11 | * Type = 需要hook方法的参数(如 : java.long.String)
12 | *
13 | * 此注释是为了方便hook一些无法用.class获取参数的方法设计
14 | * (例如编写一些第三方应用的注入插件 一些自定义参数我们在我们的工程中无法获取.class参数 直接只需要设置参数的类字符串即可)
15 | * 作者:zhangzhongping on 17/4/11 17:13
16 | * 邮箱:android_dy@163.com
17 | */
18 | @Retention(RetentionPolicy.RUNTIME)
19 | @Target(ElementType.TYPE)
20 | public @interface Hooks {
21 | String Class();
22 |
23 | String Name();
24 |
25 | String returnVal();
26 |
27 | boolean isStatic();
28 |
29 | String[] Parameter() default {};
30 | }
--------------------------------------------------------------------------------
/hookinject/src/main/java/com/taobao/android/dexposed/annotations/NewHookProcessor.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import com.google.auto.service.AutoService;
4 | import java.util.LinkedHashSet;
5 | import java.util.Set;
6 | import javax.annotation.processing.AbstractProcessor;
7 | import javax.annotation.processing.ProcessingEnvironment;
8 | import javax.annotation.processing.Processor;
9 | import javax.annotation.processing.RoundEnvironment;
10 | import javax.lang.model.SourceVersion;
11 | import javax.lang.model.element.Element;
12 | import javax.lang.model.element.TypeElement;
13 |
14 | /**
15 | * Created by zhy on 16/4/22.
16 | */
17 | @AutoService(Processor.class)
18 | public class NewHookProcessor extends AbstractProcessor {
19 |
20 | @Override
21 | public Set getSupportedAnnotationTypes() {
22 | Set annotataions = new LinkedHashSet(2);
23 | annotataions.add(Hook.class.getCanonicalName());
24 | annotataions.add(Hooks.class.getCanonicalName());
25 | return annotataions;
26 | }
27 |
28 | @Override
29 | public boolean process(Set extends TypeElement> set, RoundEnvironment roundEnvironment) {
30 | Set extends Element> elements = roundEnvironment.getElementsAnnotatedWith(Hook.class);
31 | for (Element element : elements) {
32 | getHook.getHook(element,processingEnv);
33 | }
34 | Set extends Element> elementss = roundEnvironment.getElementsAnnotatedWith(Hooks.class);
35 | for (Element element : elementss) {
36 | getHooks.getHooks(element,processingEnv);
37 | }
38 | return false;
39 | }
40 |
41 | @Override
42 | public synchronized void init(ProcessingEnvironment processingEnv) {
43 | super.init(processingEnv);
44 | Utils.setElementUtils(processingEnv.getElementUtils());
45 | }
46 |
47 | @Override
48 | public SourceVersion getSupportedSourceVersion() {
49 | return SourceVersion.RELEASE_7;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/hookinject/src/main/java/com/taobao/android/dexposed/annotations/Utils.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import com.squareup.javapoet.ClassName;
4 | import com.squareup.javapoet.TypeName;
5 |
6 | import java.lang.reflect.Type;
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | import javax.lang.model.element.TypeElement;
11 | import javax.lang.model.util.Elements;
12 |
13 | /**
14 | * 作者:zhangzhongping on 17/4/16 13:34
15 | * 邮箱:android_dy@163.com
16 | */
17 | public class Utils {
18 |
19 | private static Elements elementUtils;
20 |
21 | private static final Map abbreviationMap = new HashMap();
22 |
23 | private static final Map abbreviationMaps = new HashMap();
24 |
25 | static {
26 | abbreviationMaps.put("int", "1");
27 | abbreviationMaps.put("boolean", "false");
28 | abbreviationMaps.put("float", "1");
29 | abbreviationMaps.put("long", "1");
30 | abbreviationMaps.put("short", "1");
31 | abbreviationMaps.put("byte", "1");
32 | abbreviationMaps.put("double", "1");
33 | abbreviationMaps.put("char", "1");
34 | abbreviationMaps.put("void", "void");
35 | abbreviationMaps.put("int[]", "new int[]{1}");
36 | abbreviationMaps.put("boolean[]", "new boolean[]{false}");
37 | abbreviationMaps.put("float[]", "new float[]{1}");
38 | abbreviationMaps.put("long[]", "new long[]{1}");
39 | abbreviationMaps.put("short[]", "new short[]{1}");
40 | abbreviationMaps.put("byte[]", "new byte[]{1}");
41 | abbreviationMaps.put("double[]", "new double[]{1}");
42 | abbreviationMaps.put("char[]", "new char[]{1}");
43 | abbreviationMaps.put("java.lang.Object", "new Object()");
44 | abbreviationMaps.put("java.lang.String", "new String()");
45 | abbreviationMaps.put("java.lang.Void", "null");
46 | abbreviationMaps.put("java.lang.Boolean", "new Boolean(false)");
47 | abbreviationMaps.put("java.lang.Byte", "new Byte(\"1\")");
48 | abbreviationMaps.put("java.lang.Short", "new Short(\"1\")");
49 | abbreviationMaps.put("java.lang.Integer", "new Integer(1)");
50 | abbreviationMaps.put("java.lang.Long", "new Long(1)");
51 | abbreviationMaps.put("java.lang.Character", "new Character((char) 1)");
52 | abbreviationMaps.put("java.lang.Float", "new Float(1)");
53 | abbreviationMaps.put("java.lang.Double", "new Double(1)");
54 | abbreviationMaps.put("java.lang.Void[]", "null");
55 | abbreviationMaps.put("java.lang.Boolean[]", "new Boolean[]{true}");
56 | abbreviationMaps.put("java.lang.Byte[]", "new Byte[]{1}");
57 | abbreviationMaps.put("java.lang.Short[]", "new Short[]{1}");
58 | abbreviationMaps.put("java.lang.Integer[]", "new Integer[]{1}");
59 | abbreviationMaps.put("java.lang.Long[]", "new Long[]{(long)1}");
60 | abbreviationMaps.put("java.lang.Character[]", "new Character[]{1}");
61 | abbreviationMaps.put("java.lang.Float[]", "new Float[]{(float)1}");
62 | abbreviationMaps.put("java.lang.Double[]", "new Double[]{(double) 1}");
63 | abbreviationMaps.put("java.lang.String[]", "new String[]{\"\"}");
64 | abbreviationMaps.put("java.lang.Object[]", "new Object[]{new Object()}");
65 | abbreviationMap.put("int", TypeName.INT);
66 | abbreviationMap.put("boolean", TypeName.BOOLEAN);
67 | abbreviationMap.put("float", TypeName.FLOAT);
68 | abbreviationMap.put("long", TypeName.LONG);
69 | abbreviationMap.put("short", TypeName.SHORT);
70 | abbreviationMap.put("byte", TypeName.BYTE);
71 | abbreviationMap.put("double", TypeName.DOUBLE);
72 | abbreviationMap.put("char", TypeName.CHAR);
73 | abbreviationMap.put("void", TypeName.VOID);
74 | abbreviationMap.put("java.lang.Object", TypeName.OBJECT);
75 | abbreviationMap.put("int[]", ClassName.get((Type) int[].class));
76 | abbreviationMap.put("boolean[]", ClassName.get((Type) boolean[].class));
77 | abbreviationMap.put("float[]", ClassName.get((Type) float[].class));
78 | abbreviationMap.put("long[]", ClassName.get((Type) long[].class));
79 | abbreviationMap.put("short[]", ClassName.get((Type) short[].class));
80 | abbreviationMap.put("byte[]", ClassName.get((Type) byte[].class));
81 | abbreviationMap.put("double[]", ClassName.get((Type) double[].class));
82 | abbreviationMap.put("char[]", ClassName.get((Type) char[].class));
83 | abbreviationMap.put("java.lang.String", ClassName.get("java.lang", "String"));
84 | abbreviationMap.put("java.lang.Void", ClassName.get("java.lang", "Void"));
85 | abbreviationMap.put("java.lang.Boolean", ClassName.get("java.lang", "Boolean"));
86 | abbreviationMap.put("java.lang.Byte", ClassName.get("java.lang", "Byte"));
87 | abbreviationMap.put("java.lang.Short", ClassName.get("java.lang", "Short"));
88 | abbreviationMap.put("java.lang.Integer", ClassName.get("java.lang", "Integer"));
89 | abbreviationMap.put("java.lang.Long", ClassName.get("java.lang", "Long"));
90 | abbreviationMap.put("java.lang.Character", ClassName.get("java.lang", "Character"));
91 | abbreviationMap.put("java.lang.Float", ClassName.get("java.lang", "Float"));
92 | abbreviationMap.put("java.lang.Double", ClassName.get("java.lang", "Double"));
93 | abbreviationMap.put("java.lang.Object[]", ClassName.get((Type) Object[].class));
94 | abbreviationMap.put("java.lang.String[]", ClassName.get((Type) String[].class));
95 | abbreviationMap.put("java.lang.Void[]", ClassName.get((Type) Void[].class));
96 | abbreviationMap.put("java.lang.Boolean[]", ClassName.get((Type) Boolean[].class));
97 | abbreviationMap.put("java.lang.Byte[]", ClassName.get((Type) Byte[].class));
98 | abbreviationMap.put("java.lang.Short[]", ClassName.get((Type) Short[].class));
99 | abbreviationMap.put("java.lang.Integer[]", ClassName.get((Type) Integer[].class));
100 | abbreviationMap.put("java.lang.Long[]", ClassName.get((Type) Long[].class));
101 | abbreviationMap.put("java.lang.Character[]", ClassName.get((Type) Character[].class));
102 | abbreviationMap.put("java.lang.Float[]", ClassName.get((Type) Float[].class));
103 | abbreviationMap.put("java.lang.Double[]", ClassName.get((Type) Double[].class));
104 | }
105 |
106 |
107 | public static TypeName Parameter(String name) {
108 | if (abbreviationMap.get(name) != null) {
109 | return abbreviationMap.get(name);
110 | }
111 | return TypeName.OBJECT;
112 | }
113 |
114 | public static Object ReturnValue(String name) {
115 | if (abbreviationMaps.get(name) != null) {
116 | if (abbreviationMaps.get(name).equals("void")) {
117 | return "return";
118 | }
119 | return "return ".concat(abbreviationMaps.get(name));
120 | }
121 | return "return new Object()";
122 | }
123 |
124 | public static String getPackageName(TypeElement typeElement) {
125 | return elementUtils.getPackageOf(typeElement).getQualifiedName().toString();
126 | }
127 |
128 | public static void setElementUtils(Elements elementUtils) {
129 | Utils.elementUtils = elementUtils;
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/hookinject/src/main/java/com/taobao/android/dexposed/annotations/getHook.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import com.squareup.javapoet.ClassName;
4 | import com.squareup.javapoet.FieldSpec;
5 | import com.squareup.javapoet.JavaFile;
6 | import com.squareup.javapoet.MethodSpec;
7 | import com.squareup.javapoet.TypeName;
8 | import com.squareup.javapoet.TypeSpec;
9 | import java.util.List;
10 |
11 | import javax.annotation.processing.ProcessingEnvironment;
12 | import javax.lang.model.element.Element;
13 | import javax.lang.model.element.Modifier;
14 | import javax.lang.model.element.TypeElement;
15 | import javax.lang.model.type.MirroredTypeException;
16 | import javax.lang.model.type.MirroredTypesException;
17 | import javax.lang.model.type.TypeMirror;
18 |
19 | /**
20 | * 作者:zhangzhongping on 17/4/16 13:33
21 | * 邮箱:android_dy@163.com
22 | */
23 | public class getHook {
24 |
25 | public static void getHook(Element element, ProcessingEnvironment processingEnv) {
26 | try {
27 | TypeElement typeElement = (TypeElement) element;
28 | Hook hook = element.getAnnotation(Hook.class);
29 | ClassName className = ClassName.get("com.taobao.android.dexposed", "XC_MethodHook");
30 | MethodSpec.Builder bindViewMethodSpecBuilder = MethodSpec.methodBuilder("HookMethod")
31 | .addModifiers(Modifier.PRIVATE, Modifier.STATIC);
32 | MethodSpec.Builder bindViewMethodSpecBuilders = MethodSpec.methodBuilder("OriginalHookMethod")
33 | .addModifiers(Modifier.PRIVATE, Modifier.STATIC);
34 | MethodSpec.Builder bind = MethodSpec.methodBuilder("setXC_MethodHook")
35 | .addModifiers(Modifier.PRIVATE, Modifier.STATIC)
36 | .addParameter(className, "xc_methodhooks")
37 | .addStatement("xc_methodhook = xc_methodhooks");
38 | Class[] classes = null;
39 | int leng;
40 | String typeindex = "param.args = new Object[]{";
41 | String tyoeindes = "OriginalHookMethod(";
42 | String tyoeindess = "OriginalHookMethod(";
43 | List extends TypeMirror> classTypeMirror = null;
44 | try {
45 | classes = hook.Parameter();
46 | leng = classes.length;
47 | } catch (MirroredTypesException mte) {
48 | classTypeMirror = mte.getTypeMirrors();
49 | leng = classTypeMirror.size();
50 | }
51 | String name;
52 | try {
53 | name = hook.returnVal().getName();
54 | } catch (MirroredTypeException e) {
55 | TypeMirror classTypeMirro = e.getTypeMirror();
56 | name = classTypeMirro.toString();
57 | }
58 | boolean isStatic = hook.isStatic();
59 | String obj = null;
60 | if (!isStatic) {
61 | bindViewMethodSpecBuilder.addParameter(TypeName.OBJECT, "thiz");
62 | bindViewMethodSpecBuilders.addParameter(TypeName.OBJECT, "thiz");
63 | tyoeindess = tyoeindess.concat("thiz,");
64 | tyoeindes = tyoeindes.concat("thiz,");
65 | obj = "thiz";
66 | }
67 | for (int i = 0; i < leng; i++) {
68 | String ss = "object" + i;
69 | if (classes != null && classes.length > 0) {
70 | bindViewMethodSpecBuilder.addParameter(Utils.Parameter(classes[i].getName()), ss);
71 | bindViewMethodSpecBuilders.addParameter(Utils.Parameter(classes[i].getName()), ss);
72 | } else {
73 | bindViewMethodSpecBuilder.addParameter(Utils.Parameter(classTypeMirror.get(i).toString()), ss);
74 | bindViewMethodSpecBuilders.addParameter(Utils.Parameter(classTypeMirror.get(i).toString()), ss);
75 | }
76 | if (i == leng - 1) {
77 | typeindex = typeindex.concat(ss + "};");
78 | tyoeindess = tyoeindess.concat(ss + ")");
79 | if (classes != null && classes.length > 0) {
80 | tyoeindes = tyoeindes.concat("(" + Utils.Parameter(classes[i].getName()).toString() + ")param.args[" + i + "])");
81 | } else {
82 | tyoeindes = tyoeindes.concat("(" + Utils.Parameter(classTypeMirror.get(i).toString()).toString() + ")param.args[" + i + "])");
83 | }
84 | } else {
85 | typeindex = typeindex.concat(ss + ",");
86 | tyoeindess = tyoeindess.concat(ss + ",");
87 | if (classes != null && classes.length > 0) {
88 | tyoeindes = tyoeindes.concat("(" + Utils.Parameter(classes[i].getName()).toString() + ")param.args[" + i + "],");
89 | } else {
90 | tyoeindes = tyoeindes.concat("(" + Utils.Parameter(classTypeMirror.get(i).toString()).toString() + ")param.args[" + i + "],");
91 | }
92 | }
93 | }
94 | if (leng == 0 ) {
95 | typeindex = "param.args = null;";
96 | tyoeindes = tyoeindes.concat(")").replace(",", "");
97 | tyoeindess = tyoeindess.concat(")").replace(",", "");
98 | }
99 | TypeName namess = Utils.Parameter(name);
100 | bindViewMethodSpecBuilder.returns(namess);
101 | bindViewMethodSpecBuilders.returns(namess);
102 | FieldSpec.Builder fieldSpec = FieldSpec.builder(className, "xc_methodhook");
103 | fieldSpec.addModifiers(Modifier.PRIVATE, Modifier.STATIC);
104 | fieldSpec.initializer("null");
105 | String ret = (String) Utils.ReturnValue(name);
106 | String aptindex = "return".equals(ret) ? tyoeindess.concat(";\nreturn;\n") : "return ".concat(tyoeindess).concat(";\n");
107 | String aptindex2 = "return".equals(ret) ? tyoeindess : "return ".concat(tyoeindess).concat("");
108 | String aptindex1 = "return".equals(ret) ? "return;\n" : "return (".concat(namess.toString()).concat(")param.getResult();\n");
109 | String yunindex = "return".equals(ret) ? tyoeindes.concat(";\n") : "param.setResult(".concat(tyoeindes).concat(");\n");
110 | bindViewMethodSpecBuilder.addStatement("" +
111 | " if(xc_methodhook == null){\n" +
112 | "" + aptindex + "" +
113 | "}\n" +
114 | "try{\n" +
115 | "XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam();\n" +
116 | "param.Model = com.taobao.android.dexposed.DexposedBridge.ART;\n" +
117 | "param.HookMethod = xc_methodhook;\n" +
118 | "param.thisObject = "+obj+";\n" +
119 | typeindex +
120 | "\nif (xc_methodhook instanceof com.taobao.android.dexposed.XC_MethodReplacement) {\n" +
121 | " param = ((com.taobao.android.dexposed.XC_MethodReplacement) xc_methodhook).replaceHookedMethod(param);\n" +
122 | "" + aptindex1 + "" +
123 | " } else {\n" +
124 | " param = xc_methodhook.beforeHookedMethod(param);\n" +
125 | "" + yunindex + "" +
126 | " param = xc_methodhook.afterHookedMethod(param);\n" +
127 | "" + aptindex1 + "" +
128 | " }\n" +
129 | "}catch (Throwable e){\n" +
130 | " e.printStackTrace();\n" +
131 | "}\n" +
132 | "" + aptindex2 + "");
133 | bindViewMethodSpecBuilders.addStatement(" System.out.print(String.class);\n"+String.valueOf(Utils.ReturnValue(name)));
134 | TypeSpec typeSpec = TypeSpec.classBuilder(element.getSimpleName() + "$$Hook")
135 | .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
136 | .addMethod(bindViewMethodSpecBuilder.build())
137 | .addMethod(bindViewMethodSpecBuilders.build())
138 | .addMethod(bind.build())
139 | .addField(fieldSpec.build())
140 | .build();
141 | JavaFile javaFile = JavaFile.builder(Utils.getPackageName(typeElement), typeSpec).build();
142 | javaFile.writeTo(processingEnv.getFiler());
143 | } catch (Exception e) {
144 | e.printStackTrace();
145 | }
146 | }
147 | }
148 |
--------------------------------------------------------------------------------
/hookinject/src/main/java/com/taobao/android/dexposed/annotations/getHooks.java:
--------------------------------------------------------------------------------
1 | package com.taobao.android.dexposed.annotations;
2 |
3 | import com.squareup.javapoet.ClassName;
4 | import com.squareup.javapoet.FieldSpec;
5 | import com.squareup.javapoet.JavaFile;
6 | import com.squareup.javapoet.MethodSpec;
7 | import com.squareup.javapoet.TypeName;
8 | import com.squareup.javapoet.TypeSpec;
9 |
10 | import java.util.List;
11 |
12 | import javax.annotation.processing.ProcessingEnvironment;
13 | import javax.lang.model.element.Element;
14 | import javax.lang.model.element.Modifier;
15 | import javax.lang.model.element.TypeElement;
16 | import javax.lang.model.type.MirroredTypeException;
17 | import javax.lang.model.type.MirroredTypesException;
18 | import javax.lang.model.type.TypeMirror;
19 |
20 | /**
21 | * 作者:zhangzhongping on 17/4/16 13:35
22 | * 邮箱:android_dy@163.com
23 | */
24 | public class getHooks {
25 | public static void getHooks(Element element, ProcessingEnvironment processingEnv) {
26 | try {
27 | TypeElement typeElement = (TypeElement) element;
28 | Hooks hook = element.getAnnotation(Hooks.class);
29 | ClassName className = ClassName.get("com.taobao.android.dexposed", "XC_MethodHook");
30 | MethodSpec.Builder bindViewMethodSpecBuilder = MethodSpec.methodBuilder("HookMethod")
31 | .addModifiers(Modifier.PRIVATE, Modifier.STATIC);
32 | MethodSpec.Builder bindViewMethodSpecBuilders = MethodSpec.methodBuilder("OriginalHookMethod")
33 | .addModifiers(Modifier.PRIVATE, Modifier.STATIC);
34 | MethodSpec.Builder bind = MethodSpec.methodBuilder("setXC_MethodHook")
35 | .addModifiers(Modifier.PRIVATE, Modifier.STATIC)
36 | .addParameter(className, "xc_methodhooks")
37 | .addStatement("xc_methodhook = xc_methodhooks");
38 | String typeindex = "param.args = new Object[]{";
39 | String tyoeindes = "OriginalHookMethod(";
40 | String tyoeindess = "OriginalHookMethod(";
41 | String[] classes = hook.Parameter();
42 | int leng = classes.length;
43 | String name = hook.returnVal();
44 | boolean isStatic = hook.isStatic();
45 | String obj = null;
46 | if (!isStatic) {
47 | bindViewMethodSpecBuilder.addParameter(TypeName.OBJECT, "thiz");
48 | bindViewMethodSpecBuilders.addParameter(TypeName.OBJECT, "thiz");
49 | tyoeindess = tyoeindess.concat("thiz,");
50 | tyoeindes = tyoeindes.concat("thiz,");
51 | obj = "thiz";
52 | }
53 | for (int i = 0; i < leng; i++) {
54 | String ss = "object" + i;
55 | bindViewMethodSpecBuilder.addParameter(Utils.Parameter(classes[i]), ss);
56 | bindViewMethodSpecBuilders.addParameter(Utils.Parameter(classes[i]), ss);
57 | if (i == leng - 1) {
58 | typeindex = typeindex.concat(ss + "};");
59 | tyoeindes = tyoeindes.concat("(" + Utils.Parameter(classes[i]).toString() + ")param.args[" + i + "])");
60 | tyoeindess = tyoeindess.concat(ss + ")");
61 | } else {
62 | typeindex = typeindex.concat(ss + ",");
63 | tyoeindess = tyoeindess.concat(ss + ",");
64 | tyoeindes = tyoeindes.concat("(" + Utils.Parameter(classes[i]).toString() + ")param.args[" + i + "],");
65 | }
66 | }
67 | if (leng == 0) {
68 | typeindex = "param.args = null;";
69 | tyoeindes = tyoeindes.concat(")").replace(",", "");
70 | tyoeindess = tyoeindess.concat(")").replace(",", "");
71 | }
72 | TypeName namess = Utils.Parameter(name);
73 | bindViewMethodSpecBuilder.returns(namess);
74 | bindViewMethodSpecBuilders.returns(namess);
75 | FieldSpec.Builder fieldSpec = FieldSpec.builder(className, "xc_methodhook");
76 | fieldSpec.addModifiers(Modifier.PRIVATE, Modifier.STATIC);
77 | fieldSpec.initializer("null");
78 | String ret = (String) Utils.ReturnValue(name);
79 | String aptindex = "return".equals(ret) ? tyoeindess.concat(";\n") : "return ".concat(tyoeindess).concat(";\n");
80 | String aptindex2 = "return".equals(ret) ? tyoeindess : "return ".concat(tyoeindess).concat("");
81 | String aptindex1 = "return".equals(ret) ? "" : "return (".concat(namess.toString()).concat(")param.getResult();\n");
82 | String yunindex = "return".equals(ret) ? tyoeindes.concat(";\n") : "param.setResult(".concat(tyoeindes).concat(");\n");
83 | bindViewMethodSpecBuilder.addStatement("" +
84 | " if(xc_methodhook == null){\n" +
85 | " " + aptindex + "" +
86 | "}\n" +
87 | "try{\n" +
88 | "XC_MethodHook.MethodHookParam param = new XC_MethodHook.MethodHookParam();\n" +
89 | "param.Model = com.taobao.android.dexposed.DexposedBridge.ART;\n" +
90 | "param.HookMethod = xc_methodhook;\n" +
91 | "param.thisObject = "+obj+";\n" +
92 | typeindex +
93 | "\nif (xc_methodhook instanceof com.taobao.android.dexposed.XC_MethodReplacement) {\n" +
94 | " param = ((com.taobao.android.dexposed.XC_MethodReplacement) xc_methodhook).replaceHookedMethod(param);\n" +
95 | " " + aptindex1 + "" +
96 | " } else {\n" +
97 | " param = xc_methodhook.beforeHookedMethod(param);\n" +
98 | " " + yunindex + "" +
99 | " param = xc_methodhook.afterHookedMethod(param);\n" +
100 | " " + aptindex1 + "" +
101 | " }\n" +
102 | "}catch (Throwable e){\n" +
103 | " e.printStackTrace();\n" +
104 | "}\n" +
105 | "" + aptindex2 + "");
106 | bindViewMethodSpecBuilders.addStatement(" System.out.print(String.class);\n"+String.valueOf(Utils.ReturnValue(name)));
107 | TypeSpec typeSpec = TypeSpec.classBuilder(element.getSimpleName() + "$$Hook")
108 | .addModifiers(Modifier.PUBLIC, Modifier.FINAL)
109 | .addMethod(bindViewMethodSpecBuilder.build())
110 | .addMethod(bindViewMethodSpecBuilders.build())
111 | .addMethod(bind.build())
112 | .addField(fieldSpec.build())
113 | .build();
114 | JavaFile javaFile = JavaFile.builder(Utils.getPackageName(typeElement), typeSpec).build();
115 | javaFile.writeTo(processingEnv.getFiler());
116 | } catch (Exception e) {
117 | e.printStackTrace();
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':dexposed', ':hookinject'
2 |
--------------------------------------------------------------------------------