Commit a19666fa authored by swift_gan's avatar swift_gan

Merge remote-tracking branch 'origin/master'

parents 0edd3087 9f403419
...@@ -13,7 +13,7 @@ Android ART Hook ...@@ -13,7 +13,7 @@ Android ART Hook
# OS # OS
4.4(ART Runtime) - 9.0 4.4(ART Runtime) - 10.0
# Scope # Scope
...@@ -30,7 +30,7 @@ cant hook if lined ...@@ -30,7 +30,7 @@ cant hook if lined
# how to use # how to use
```gradle ```gradle
implementation 'com.swift.sandhook:hooklib:3.0.2' implementation 'com.swift.sandhook:hooklib:3.1.0'
``` ```
- Annotation API - Annotation API
...@@ -121,7 +121,7 @@ SanHook.public static boolean hook(Member target, Method hook, Method backup) {} ...@@ -121,7 +121,7 @@ SanHook.public static boolean hook(Member target, Method hook, Method backup) {}
if hookers is in plugin(like xposed): if hookers is in plugin(like xposed):
```groovy ```groovy
provided 'com.swift.sandhook:hookannotation:3.0.2' provided 'com.swift.sandhook:hookannotation:3.1.0'
``` ```
in your plugin in your plugin
...@@ -136,7 +136,7 @@ backup method can call itself to avoid be inlining ...@@ -136,7 +136,7 @@ backup method can call itself to avoid be inlining
Now you can use Xposed api: Now you can use Xposed api:
```groovy ```groovy
implementation 'com.swift.sandhook:xposedcompat:3.0.2' implementation 'com.swift.sandhook:xposedcompat:3.1.0'
``` ```
```java ```java
...@@ -191,6 +191,13 @@ You can also deoptimize a caller that inlined your hook method by SandHook.deCom ...@@ -191,6 +191,13 @@ You can also deoptimize a caller that inlined your hook method by SandHook.deCom
non-Root Xposed Environment Demo (VirtualApp With SandHook): non-Root Xposed Environment Demo (VirtualApp With SandHook):
https://github.com/ganyao114/SandVXposed https://github.com/ganyao114/SandVXposed
# Android Q(10.0)
in MyApp.java
//if you want test Android Q, please set true, because SDK_INT of Android Q is still 28
public final static boolean testAndroidQ = false;
# References # References
......
...@@ -54,10 +54,9 @@ public class MyApp extends Application { ...@@ -54,10 +54,9 @@ public class MyApp extends Application {
XposedCompat.classLoader = getClassLoader(); XposedCompat.classLoader = getClassLoader();
XposedCompat.isFirstApplication= true; XposedCompat.isFirstApplication= true;
//some error when invoke backup in Android Q // //some error when invoke backup in Android Q
if (SandHookConfig.SDK_INT >= 29) { if (SandHookConfig.SDK_INT >= 29) {
XposedCompat.useNewDexMaker = false; XposedCompat.useNewCallBackup = false;
XposedCompat.useInternalStub = false;
} }
XposedHelpers.findAndHookMethod(Activity.class, "onResume", new XC_MethodHook() { XposedHelpers.findAndHookMethod(Activity.class, "onResume", new XC_MethodHook() {
......
...@@ -244,7 +244,7 @@ Java_com_swift_sandhook_SandHook_compileMethod(JNIEnv *env, jclass type, jobject ...@@ -244,7 +244,7 @@ Java_com_swift_sandhook_SandHook_compileMethod(JNIEnv *env, jclass type, jobject
extern "C" extern "C"
JNIEXPORT jboolean JNICALL JNIEXPORT jboolean JNICALL
Java_com_swift_sandhook_SandHook_deCompileMethod(JNIEnv *env, jclass type, jobject member) { Java_com_swift_sandhook_SandHook_deCompileMethod(JNIEnv *env, jclass type, jobject member, jboolean disableJit) {
if (member == NULL) if (member == NULL)
return JNI_FALSE; return JNI_FALSE;
...@@ -253,6 +253,10 @@ Java_com_swift_sandhook_SandHook_deCompileMethod(JNIEnv *env, jclass type, jobje ...@@ -253,6 +253,10 @@ Java_com_swift_sandhook_SandHook_deCompileMethod(JNIEnv *env, jclass type, jobje
if (method == nullptr) if (method == nullptr)
return JNI_FALSE; return JNI_FALSE;
if (disableJit) {
method->disableCompilable();
}
if (method->isCompiled()) { if (method->isCompiled()) {
SandHook::StopTheWorld stopTheWorld; SandHook::StopTheWorld stopTheWorld;
if (SDK_INT >= ANDROID_N) { if (SDK_INT >= ANDROID_N) {
......
...@@ -308,7 +308,7 @@ public class SandHook { ...@@ -308,7 +308,7 @@ public class SandHook {
public static native void ensureMethodCached(Method hook, Method backup); public static native void ensureMethodCached(Method hook, Method backup);
public static native boolean compileMethod(Member member); public static native boolean compileMethod(Member member);
public static native boolean deCompileMethod(Member member); public static native boolean deCompileMethod(Member member, boolean disableJit);
public static native boolean canGetObject(); public static native boolean canGetObject();
public static native Object getObjectNative(long thread, long address); public static native Object getObjectNative(long thread, long address);
......
...@@ -61,7 +61,7 @@ TEMP_STUB_INFO = """ ...@@ -61,7 +61,7 @@ TEMP_STUB_INFO = """
STUB_SIZES = [10,20,30,30,30,30,30,20,10,10,5,5,3] STUB_SIZES = [10,20,30,30,30,30,30,20,10,10,5,5,3]
HAS_BACKUP = False; HAS_BACKUP = True;
def getMethodId(args, index): def getMethodId(args, index):
......
...@@ -27,7 +27,7 @@ public class XposedCompat { ...@@ -27,7 +27,7 @@ public class XposedCompat {
//try to use internal stub hooker & backup method to speed up hook //try to use internal stub hooker & backup method to speed up hook
public static volatile boolean useInternalStub = true; public static volatile boolean useInternalStub = true;
public static volatile boolean useNewDexMaker = true; public static volatile boolean useNewCallBackup = true;
public static volatile boolean retryWhenCallOriginError = false; public static volatile boolean retryWhenCallOriginError = false;
private static ClassLoader sandHookXposedClassLoader; private static ClassLoader sandHookXposedClassLoader;
......
...@@ -6,6 +6,7 @@ import com.swift.sandhook.SandHook; ...@@ -6,6 +6,7 @@ import com.swift.sandhook.SandHook;
import com.swift.sandhook.SandHookMethodResolver; import com.swift.sandhook.SandHookMethodResolver;
import com.swift.sandhook.utils.ParamWrapper; import com.swift.sandhook.utils.ParamWrapper;
import com.swift.sandhook.wrapper.BackupMethodStubs; import com.swift.sandhook.wrapper.BackupMethodStubs;
import com.swift.sandhook.xposedcompat.XposedCompat;
import com.swift.sandhook.xposedcompat.utils.DexLog; import com.swift.sandhook.xposedcompat.utils.DexLog;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
...@@ -44,7 +45,7 @@ public class HookStubManager { ...@@ -44,7 +45,7 @@ public class HookStubManager {
Class stubClass = SandHook.is64Bit() ? MethodHookerStubs64.class : MethodHookerStubs32.class; Class stubClass = SandHook.is64Bit() ? MethodHookerStubs64.class : MethodHookerStubs32.class;
stubSizes = (int[]) XposedHelpers.getStaticObjectField(stubClass, "stubSizes"); stubSizes = (int[]) XposedHelpers.getStaticObjectField(stubClass, "stubSizes");
Boolean hasBackup = (Boolean) XposedHelpers.getStaticObjectField(stubClass, "hasStubBackup"); Boolean hasBackup = (Boolean) XposedHelpers.getStaticObjectField(stubClass, "hasStubBackup");
hasStubBackup = hasBackup == null ? false : hasBackup; hasStubBackup = hasBackup != null && (hasBackup && !XposedCompat.useNewCallBackup);
if (stubSizes != null && stubSizes.length > 0) { if (stubSizes != null && stubSizes.length > 0) {
MAX_STUB_ARGS = stubSizes.length - 1; MAX_STUB_ARGS = stubSizes.length - 1;
curUseStubIndexes = new AtomicInteger[MAX_STUB_ARGS + 1]; curUseStubIndexes = new AtomicInteger[MAX_STUB_ARGS + 1];
......
...@@ -24,7 +24,7 @@ import de.robv.android.xposed.XposedBridge; ...@@ -24,7 +24,7 @@ import de.robv.android.xposed.XposedBridge;
public final class DynamicBridge { public final class DynamicBridge {
private static final HashMap<Member, Method> hookedInfo = new HashMap<>(); private static final HashMap<Member, Method> hookedInfo = new HashMap<>();
private static HookMaker hookMaker = XposedCompat.useNewDexMaker ? new HookerDexMakerNew() : new HookerDexMaker(); private static HookMaker hookMaker = XposedCompat.useNewCallBackup ? new HookerDexMakerNew() : new HookerDexMaker();
private static final AtomicBoolean dexPathInited = new AtomicBoolean(false); private static final AtomicBoolean dexPathInited = new AtomicBoolean(false);
private static File dexDir; private static File dexDir;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment