Skip to content

Commit

Permalink
[SandHook]remove useless code
Browse files Browse the repository at this point in the history
  • Loading branch information
swift_gan committed Mar 8, 2019
1 parent 08834c9 commit 96a9bc8
Showing 1 changed file with 4 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
package com.swift.sandhook.xposedcompat.utils;
import external.com.android.dx.Code;
import external.com.android.dx.Local;
import external.com.android.dx.TypeId;
import com.android.dx.rop.code.Insn;
import com.android.dx.rop.code.PlainInsn;
import com.android.dx.rop.code.RegisterSpec;
import com.android.dx.rop.code.RegisterSpecList;
import com.android.dx.rop.code.Rops;
import com.android.dx.rop.code.SourcePosition;
import com.android.dx.rop.type.Type;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;

import external.com.android.dx.Code;
import external.com.android.dx.Local;
import external.com.android.dx.TypeId;

public class DexMakerUtils {


Expand Down Expand Up @@ -219,44 +211,6 @@ public static void returnRightValue(Code code, Class<?> returnType, Map<Class, L
code.returnValue(resultLocals.get(returnType));
}

public static void moveException(Code code, Local<?> result) {
addInstruction(code, new PlainInsn(Rops.opMoveException(Type.THROWABLE),
SourcePosition.NO_INFO, spec(result), RegisterSpecList.EMPTY));
}

public static void addInstruction(Code code, Insn insn) {
if (addInstMethod == null) {
try {
addInstMethod = Code.class.getDeclaredMethod("addInstruction", Insn.class);
addInstMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
try {
addInstMethod.invoke(code, insn);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
}

public static RegisterSpec spec(Local<?> result) {
if (specMethod == null) {
try {
specMethod = Local.class.getDeclaredMethod("spec");
specMethod.setAccessible(true);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
try {
return (RegisterSpec) specMethod.invoke(result);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
return null;
}
}

public static String MD5(String source) {
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
Expand Down

0 comments on commit 96a9bc8

Please sign in to comment.