Commit 75c42e7f authored by swift_gan's avatar swift_gan

avoid inline when call origin

parent feeab481
...@@ -6,6 +6,7 @@ import android.content.Context; ...@@ -6,6 +6,7 @@ import android.content.Context;
import com.swift.sandhook.xposedcompat.classloaders.ComposeClassLoader; import com.swift.sandhook.xposedcompat.classloaders.ComposeClassLoader;
import com.swift.sandhook.xposedcompat.methodgen.DynamicBridge; import com.swift.sandhook.xposedcompat.methodgen.DynamicBridge;
import com.swift.sandhook.xposedcompat.utils.ApplicationUtils; import com.swift.sandhook.xposedcompat.utils.ApplicationUtils;
import com.swift.sandhook.xposedcompat.utils.FileUtils;
import com.swift.sandhook.xposedcompat.utils.ProcessUtils; import com.swift.sandhook.xposedcompat.utils.ProcessUtils;
import java.io.File; import java.io.File;
...@@ -75,7 +76,7 @@ public class XposedCompat { ...@@ -75,7 +76,7 @@ public class XposedCompat {
public static boolean clearCache() { public static boolean clearCache() {
try { try {
cacheDir.delete(); FileUtils.delete(cacheDir);
cacheDir.mkdirs(); cacheDir.mkdirs();
return true; return true;
} catch (Throwable throwable) { } catch (Throwable throwable) {
......
...@@ -4,6 +4,7 @@ import android.os.Trace; ...@@ -4,6 +4,7 @@ import android.os.Trace;
import com.swift.sandhook.xposedcompat.XposedCompat; import com.swift.sandhook.xposedcompat.XposedCompat;
import com.swift.sandhook.xposedcompat.utils.DexLog; import com.swift.sandhook.xposedcompat.utils.DexLog;
import com.swift.sandhook.xposedcompat.utils.FileUtils;
import java.io.File; import java.io.File;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
...@@ -71,7 +72,8 @@ public final class DynamicBridge { ...@@ -71,7 +72,8 @@ public final class DynamicBridge {
if (!dexOatDir.exists()) if (!dexOatDir.exists())
return; return;
try { try {
dexOatDir.delete(); FileUtils.delete(dexOatDir);
dexOatDir.mkdirs();
} catch (Throwable throwable) { } catch (Throwable throwable) {
} }
} }
......
...@@ -267,11 +267,18 @@ public class HookerDexMaker { ...@@ -267,11 +267,18 @@ public class HookerDexMaker {
private void generateBackupMethod() { private void generateBackupMethod() {
mBackupMethodId = mHookerTypeId.getMethod(mReturnTypeId, METHOD_NAME_BACKUP, mParameterTypeIds); mBackupMethodId = mHookerTypeId.getMethod(mReturnTypeId, METHOD_NAME_BACKUP, mParameterTypeIds);
Code code = mDexMaker.declare(mBackupMethodId, Modifier.PUBLIC | Modifier.STATIC); Code code = mDexMaker.declare(mBackupMethodId, Modifier.PUBLIC | Modifier.STATIC);
Local<Member> method = code.newLocal(memberTypeId);
Map<TypeId, Local> resultLocals = createResultLocals(code); Map<TypeId, Local> resultLocals = createResultLocals(code);
MethodId<?, ?> errLogMethod = TypeId.get(DexLog.class).getMethod(TypeId.get(Void.TYPE), "printCallOriginError", TypeId.get(Member.class));
//very very important!!!!!!!!!!!
//add a try cache block avoid inline //add a try cache block avoid inline
Label tryCatchBlock = new Label(); Label tryCatchBlock = new Label();
code.sget(mMethodFieldId, method);
code.invokeStatic(errLogMethod, null, method);
// start of try // start of try
code.addCatchClause(throwableTypeId, tryCatchBlock); code.addCatchClause(throwableTypeId, tryCatchBlock);
......
...@@ -29,6 +29,12 @@ public class DexLog { ...@@ -29,6 +29,12 @@ public class DexLog {
} }
} }
public static void printCallOriginError(Member member) {
if (member != null) {
Log.e("SandHook-Xposed", "method <" + member.toString() + "> call origin error!");
}
}
public static int w(String s) { public static int w(String s) {
return Log.w(TAG, s); return Log.w(TAG, s);
} }
...@@ -40,4 +46,6 @@ public class DexLog { ...@@ -40,4 +46,6 @@ public class DexLog {
public static int e(String s, Throwable t) { public static int e(String s, Throwable t) {
return Log.e(TAG, s, t); return Log.e(TAG, s, t);
} }
} }
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