Skip to content

Commit d183a00

Browse files
committed
Bump version for 3.6.0 release
1 parent 2323593 commit d183a00

File tree

19 files changed

+36
-20
lines changed

19 files changed

+36
-20
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 AndHook
3+
Copyright (c) 2019 AndHook
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="andhook.test"
44
android:versionCode="3"
5-
android:versionName="3.5.8">
5+
android:versionName="3.6.0">
66

77
<uses-sdk
88
android:minSdkVersion="14"

app/src/main/java/andhook/test/Constructor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ public final class Constructor {
88
private static boolean passed;
99

1010
private Constructor() {
11-
MainActivity.output("original constructor hit, this = " + this);
11+
final Object thiz = this; // dummy code to avoid inlining
12+
MainActivity.output("original constructor hit, this = " + thiz +
13+
", hash = " + thiz.hashCode());
1214
}
1315

1416
@SuppressWarnings("unused")

app/src/main/java/andhook/test/InnerException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import andhook.test.ui.MainActivity;
66

77
public final class InnerException {
8+
private static boolean passed = false;
9+
810
private static final class k {
911
static synchronized void a() {
1012
MainActivity.output("k->a");
@@ -77,15 +79,14 @@ protected void beforeHookedMethod(final MethodHookParam param)
7779
throws Throwable {
7880
super.beforeHookedMethod(param);
7981
MainActivity.output("q->d before");
82+
passed = true;
8083
}
8184
});
8285

83-
boolean passed = false;
8486
try {
8587
q.a();
8688
} catch (final UnsupportedOperationException e) {
8789
MainActivity.output(e);
88-
passed = true;
8990
}
9091

9192
if (passed)

app/src/main/java/andhook/test/Native.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ public final class Native {
88
private static boolean passed = false;
99

1010
// @CriticalNative since Android O
11+
@SuppressWarnings("unused")
1112
@Hook(clazz = android.os.SystemClock.class, need_origin = true)
1213
private static long currentThreadTimeMillis(final Class<?> clazz) {
1314
passed = true;

app/src/main/java/andhook/test/Threads.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ public static void test() {
1515

1616
passed = false;
1717

18-
// @NOTE that hooking methods of Thread.class is possibly unstable
19-
// as they may be on the stack before, which could result in
20-
// unexpected stack unwinding.
18+
// Methods of Thread are likely to be in threads call stack already,
19+
// which could result in unexpected stack unwinding.
20+
// Is it possible that we can fix up the stack layout?
2121
AndHook.stopDaemons();
2222
android.os.SystemClock.sleep(100);
2323

app/src/main/java/andhook/test/Virtual.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import andhook.lib.AndHook;
66
import andhook.lib.HookHelper;
77
import andhook.test.ui.MainActivity;
8+
89
import android.util.Log;
910

1011
public final class Virtual {
@@ -39,7 +40,10 @@ private static void hookWithinSameClass() throws Exception {
3940

4041
private static class A {
4142
public int get() {
42-
MainActivity.output("public A::get hit, this = " + this);
43+
// small methods without reachable non-instruction limits will always be inlined
44+
final Object thiz = this;
45+
MainActivity.output("public A::get hit, this = " + thiz +
46+
", hash = " + thiz.hashCode());
4347
return 0;
4448
}
4549
}
@@ -48,6 +52,7 @@ public static class B extends A {
4852
@Override
4953
public int get() {
5054
MainActivity.output("public B::get hit, this = " + this);
55+
// the following statement could be inlined if --compiler-filter=everything
5156
return super.get() + 1;
5257
}
5358

app/src/main/java/andhook/test/Xposed.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import andhook.lib.xposed.XposedHelpers;
99
import andhook.lib.xposed.XC_MethodHook;
1010
import andhook.test.ui.MainActivity;
11+
1112
import android.annotation.TargetApi;
1213
import android.os.Build;
1314
import android.system.OsConstants;

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
google()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.1.1'
8+
classpath 'com.android.tools.build:gradle:3.1.2'
99
}
1010
}
1111

lib/include/AndHook.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
*
33
* @author : Rprop ([email protected])
4-
* @date : 2018/05/05
4+
* @date : 2018/05/26
55
* https://github.com/Rprop/AndHook
66
*
77
*/
@@ -22,16 +22,21 @@ extern "C" {
2222
# define AK_DEFAULT(v)
2323
#endif
2424

25+
/// <summary>
26+
/// Loads the specified module using system linker or NULL if failed.
27+
/// @warning `caller_addr` is necessary for loading system libraries since Android N
28+
/// </summary>
29+
const void *AKLoadImage(const char *path, int flag, const void *caller_addr AK_DEFAULT(NULL));
2530
/// <summary>
2631
/// Gets handle to specified module or NULL if the target is not currently loaded
2732
/// </summary>
2833
const void *AKGetImageByName(const char *name AK_DEFAULT(AK_ANDROID_RUNTIME));
2934
/// <summary>
30-
/// Gets the address of defined symbols or NULL
35+
/// Gets the address of defined symbol or NULL
3136
/// </summary>
3237
void *AKFindSymbol(const void *handle, const char *symbol);
3338
/// <summary>
34-
/// Gets the base address of defined symbols or NULL
39+
/// Gets the base address of defined module or NULL
3540
/// </summary>
3641
void *AKGetBaseAddress(const void *handle);
3742
/// <summary>
@@ -112,7 +117,8 @@ extern "C" {
112117
/// </summary>
113118
void AKJavaHookMethodV(JNIEnv *env, jmethodID methodId, const void *replace, jmethodID *result AK_DEFAULT(NULL));
114119
/// <summary>
115-
/// Marks the specified java method as native (if not) and backups original method if `result` != NULL
120+
/// Marks the specified java method as native (if not) and backups original method if `result` != NULL.
121+
/// @warning The method must not be inlined or in any threads call stack
116122
/// </summary>
117123
AK_BOOL AKForceNativeMethod(JNIEnv *env, jmethodID methodId, const void *jni_entrypoint, AK_BOOL fast_native AK_DEFAULT(0),
118124
jmethodID *result AK_DEFAULT(NULL));
@@ -227,6 +233,7 @@ extern "C" {
227233
/// </summary>
228234
struct AKInvokeInterface {
229235
intptr_t version;
236+
const void *(*LoadImage)(const char *path, int flag, const void *caller_addr /* = NULL*/);
230237
const void *(*GetImageByName)(const char *name /* = AK_ANDROID_RUNTIME */);
231238
void *(*FindSymbol)(const void *handle, const char *symbol);
232239
void *(*GetBaseAddress)(const void *handle);

0 commit comments

Comments
 (0)