Commit 69b9b89f authored by swift_gan's avatar swift_gan

Merge remote-tracking branch 'origin/master'

parents 62b42c64 1e683c1c
......@@ -149,7 +149,7 @@ public class SandHook {
}
public static Object callOriginMethod(Member originMethod, Method backupMethod, Object thiz, Object[] args) throws Throwable {
return callOriginMethod(false, originMethod, backupMethod, thiz, args);
return callOriginMethod(true, originMethod, backupMethod, thiz, args);
}
public static Object callOriginMethod(boolean backupIsStub, Member originMethod, Method backupMethod, Object thiz, Object[] args) throws Throwable {
......
package com.swift.sandhook.blacklist;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
public class HookBlackList {
static Set<String> blackList = new HashSet<>();
public static Set<String> methodBlackList = new HashSet<>();
public static Set<Class> classBlackList = new HashSet<>();
static {
blackList.add("java.lang.reflect.Member.getDeclaringClass");
blackList.add("java.lang.reflect.Method.invoke");
blackList.add("java.util.Map.get");
blackList.add("java.lang.reflect.AccessibleObject.setAccessible");
blackList.add("java.lang.reflect.Member.getModifiers");
blackList.add("java.lang.reflect.InvocationTargetException.getCause");
methodBlackList.add("java.lang.reflect.Member.getDeclaringClass");
methodBlackList.add("java.lang.reflect.Method.invoke");
methodBlackList.add("java.util.Map.get");
methodBlackList.add("java.util.concurrent.ConcurrentHashMap.get");
methodBlackList.add("java.lang.reflect.AccessibleObject.setAccessible");
methodBlackList.add("java.lang.reflect.Member.getModifiers");
methodBlackList.add("java.lang.reflect.InvocationTargetException.getCause");
methodBlackList.add("java.lang.reflect.Method.hashCode");
methodBlackList.add("java.lang.reflect.Class.getName");
methodBlackList.add("java.lang.String.hashCode");
methodBlackList.add("java.lang.String.length");
}
public final static boolean canNotHook(Member origin) {
if (classBlackList.contains(origin.getDeclaringClass()))
return true;
String name = origin.getDeclaringClass().getName() + "." + origin.getName();
return blackList.contains(name);
return methodBlackList.contains(name);
}
}
......@@ -69,14 +69,15 @@ public class HookWrapper {
for (HookEntity hookEntity:hookEntityMap.values()) {
if (TextUtils.equals(hookEntity.isCtor() ? "<init>" : hookEntity.target.getName(), hookMethodBackup.value()) && samePars(classLoader, field, hookEntity.pars)) {
field.setAccessible(true);
if (hookEntity.backup == null)
if (hookEntity.backup == null) {
hookEntity.backup = BackupMethodStubs.getStubMethod();
hookEntity.hookIsStub = true;
hookEntity.resolveDexCache = false;
}
if (hookEntity.backup == null)
continue;
try {
field.set(null, hookEntity.backup);
hookEntity.hookIsStub = true;
hookEntity.resolveDexCache = false;
} catch (IllegalAccessException e) {
e.printStackTrace();
}
......
......@@ -400,7 +400,7 @@ public class HookStubManager {
}
}
public static long callOrigin(HookMethodEntity entity, Member origin, Object thiz, Object[] args) throws Throwable {
public final static long callOrigin(HookMethodEntity entity, Member origin, Object thiz, Object[] args) throws Throwable {
Object res = SandHook.callOriginMethod(origin, thiz, args);
return entity.getResultAddress(res);
}
......
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