Commit 912f76cd authored by swift_gan's avatar swift_gan

fix null dir

parent 5c250a7a
...@@ -546,6 +546,12 @@ public final class DexMaker { ...@@ -546,6 +546,12 @@ public final class DexMaker {
* *
* TODO: load the dex from memory where supported. * TODO: load the dex from memory where supported.
*/ */
File parentDir = result.getParentFile();
if (!parentDir.exists()) {
parentDir.mkdirs();
}
result.createNewFile(); result.createNewFile();
JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(result)); JarOutputStream jarOut = new JarOutputStream(new FileOutputStream(result));
JarEntry entry = new JarEntry(DexFormat.DEX_IN_JAR_NAME); JarEntry entry = new JarEntry(DexFormat.DEX_IN_JAR_NAME);
......
...@@ -47,6 +47,8 @@ public final class DynamicBridge { ...@@ -47,6 +47,8 @@ public final class DynamicBridge {
try { try {
String fixedAppDataDir = XposedCompat.cacheDir.getAbsolutePath(); String fixedAppDataDir = XposedCompat.cacheDir.getAbsolutePath();
dexDir = new File(fixedAppDataDir, "/sandxposed/"); dexDir = new File(fixedAppDataDir, "/sandxposed/");
if (!dexDir.exists())
dexDir.mkdirs();
} catch (Throwable throwable) { } catch (Throwable throwable) {
DexLog.e("error when init dex path", throwable); DexLog.e("error when init dex path", throwable);
} }
......
...@@ -20,7 +20,6 @@ import java.lang.reflect.Member; ...@@ -20,7 +20,6 @@ import java.lang.reflect.Member;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.Map; import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;
import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.XposedBridge;
...@@ -30,7 +29,6 @@ import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.autoBoxIfNeces ...@@ -30,7 +29,6 @@ import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.autoBoxIfNeces
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.autoUnboxIfNecessary; import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.autoUnboxIfNecessary;
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.createResultLocals; import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.createResultLocals;
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.getObjTypeIdIfPrimitive; import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.getObjTypeIdIfPrimitive;
import static com.swift.sandhook.xposedcompat.utils.DexMakerUtils.moveException;
public class HookerDexMaker { public class HookerDexMaker {
...@@ -48,7 +46,6 @@ public class HookerDexMaker { ...@@ -48,7 +46,6 @@ public class HookerDexMaker {
private static final String PARAMS_FIELD_NAME_ARGS = "args"; private static final String PARAMS_FIELD_NAME_ARGS = "args";
private static final String CALLBACK_METHOD_NAME_BEFORE = "callBeforeHookedMethod"; private static final String CALLBACK_METHOD_NAME_BEFORE = "callBeforeHookedMethod";
private static final String CALLBACK_METHOD_NAME_AFTER = "callAfterHookedMethod"; private static final String CALLBACK_METHOD_NAME_AFTER = "callAfterHookedMethod";
private static final String PARAMS_METHOD_NAME_IS_EARLY_RETURN = "isEarlyReturn";
private static final TypeId<Throwable> throwableTypeId = TypeId.get(Throwable.class); private static final TypeId<Throwable> throwableTypeId = TypeId.get(Throwable.class);
private static final TypeId<Member> memberTypeId = TypeId.get(Member.class); private static final TypeId<Member> memberTypeId = TypeId.get(Member.class);
private static final TypeId<XC_MethodHook> callbackTypeId = TypeId.get(XC_MethodHook.class); private static final TypeId<XC_MethodHook> callbackTypeId = TypeId.get(XC_MethodHook.class);
...@@ -77,8 +74,6 @@ public class HookerDexMaker { ...@@ -77,8 +74,6 @@ public class HookerDexMaker {
private static final TypeId<XposedBridge> xposedBridgeTypeId = TypeId.get(XposedBridge.class); private static final TypeId<XposedBridge> xposedBridgeTypeId = TypeId.get(XposedBridge.class);
private static final MethodId<XposedBridge, Void> logThrowableMethodId = private static final MethodId<XposedBridge, Void> logThrowableMethodId =
xposedBridgeTypeId.getMethod(TypeId.VOID, "log", throwableTypeId); xposedBridgeTypeId.getMethod(TypeId.VOID, "log", throwableTypeId);
private static final MethodId<XposedBridge, Void> logStrMethodId =
xposedBridgeTypeId.getMethod(TypeId.VOID, "log", TypeId.STRING);
private FieldId<?, XposedBridge.AdditionalHookInfo> mHookInfoFieldId; private FieldId<?, XposedBridge.AdditionalHookInfo> mHookInfoFieldId;
private FieldId<?, Member> mMethodFieldId; private FieldId<?, Member> mMethodFieldId;
...@@ -406,9 +401,9 @@ public class HookerDexMaker { ...@@ -406,9 +401,9 @@ public class HookerDexMaker {
code.newInstance(param, paramTypeId.getConstructor()); code.newInstance(param, paramTypeId.getConstructor());
// set method, thisObject, args // set method, thisObject, args
code.sget(mMethodFieldId, method); code.sget(mMethodFieldId, method);
code.iput(paramTypeId.getField(memberTypeId, "method"), param, method); code.iput(paramTypeId.getField(memberTypeId, PARAMS_FIELD_NAME_METHOD), param, method);
code.iput(paramTypeId.getField(TypeId.OBJECT, "thisObject"), param, thisObject); code.iput(paramTypeId.getField(TypeId.OBJECT, PARAMS_FIELD_NAME_THIS_OBJECT), param, thisObject);
code.iput(paramTypeId.getField(objArrayTypeId, "args"), param, args); code.iput(paramTypeId.getField(objArrayTypeId, PARAMS_FIELD_NAME_ARGS), param, args);
// call beforeCallbacks // call beforeCallbacks
code.loadConstant(beforeIdx, 0); code.loadConstant(beforeIdx, 0);
...@@ -427,7 +422,7 @@ public class HookerDexMaker { ...@@ -427,7 +422,7 @@ public class HookerDexMaker {
// start of catch // start of catch
code.mark(tryBeforeCatch); code.mark(tryBeforeCatch);
moveException(code, throwable); code.moveException(throwable);
code.invokeStatic(logThrowableMethodId, null, throwable); code.invokeStatic(logThrowableMethodId, null, throwable);
code.invokeVirtual(setResultMethodId, null, param, nullObj); code.invokeVirtual(setResultMethodId, null, param, nullObj);
code.loadConstant(returnEarly, false); code.loadConstant(returnEarly, false);
...@@ -484,7 +479,7 @@ public class HookerDexMaker { ...@@ -484,7 +479,7 @@ public class HookerDexMaker {
code.removeCatchClause(throwableTypeId); code.removeCatchClause(throwableTypeId);
// catch // catch
code.mark(tryOrigCatch); code.mark(tryOrigCatch);
moveException(code, throwable); code.moveException(throwable);
// exception occurred when calling backup, save throwable to param // exception occurred when calling backup, save throwable to param
code.invokeVirtual(setThrowableMethodId, null, param, throwable); code.invokeVirtual(setThrowableMethodId, null, param, throwable);
...@@ -507,7 +502,7 @@ public class HookerDexMaker { ...@@ -507,7 +502,7 @@ public class HookerDexMaker {
code.removeCatchClause(throwableTypeId); code.removeCatchClause(throwableTypeId);
// catch // catch
code.mark(tryAfterCatch); code.mark(tryAfterCatch);
moveException(code, throwable); code.moveException(throwable);
code.invokeStatic(logThrowableMethodId, null, throwable); code.invokeStatic(logThrowableMethodId, null, throwable);
// if lastThrowable == null, go to recover lastResult // if lastThrowable == null, go to recover lastResult
code.compareZ(Comparison.EQ, noBackupThrowable, lastThrowable); code.compareZ(Comparison.EQ, noBackupThrowable, lastThrowable);
......
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