Commit 48916f5a authored by swift_gan's avatar swift_gan

remove useless code

parent e084449d
......@@ -58,53 +58,6 @@ void ensureMethodCached(art::mirror::ArtMethod *hookMethod, art::mirror::ArtMeth
}
}
void ensureBackupMethod(art::mirror::ArtMethod *origin, art::mirror::ArtMethod *backup) {
if (origin->getDeclaringClassPtr() != backup->getDeclaringClassPtr()) {
LOGW("backup method is out to date due to Moving GC!");
SandHook::HookTrampoline* trampoline = trampolineManager.getHookTrampoline(origin);
if (trampoline == nullptr)
return;
SandHook::StopTheWorld stopTheWorld;
if (trampoline->inlineJump != nullptr) {
origin->backup(backup);
backup->setQuickCodeEntry(trampoline->callOrigin->getCode());
if (SDK_INT >= ANDROID_N) {
backup->disableCompilable();
}
if (SDK_INT >= ANDROID_O) {
backup->disableInterpreterForO();
}
if (!backup->isStatic()) {
backup->setPrivate();
}
backup->tryDisableInline();
} else if (trampoline->replacement != nullptr) {
origin->backup(backup);
if (trampoline->callOrigin != nullptr) {
backup->setQuickCodeEntry(trampoline->callOrigin->getCode());
} else {
backup->setQuickCodeEntry(trampoline->originCode);
}
if (SDK_INT >= ANDROID_N) {
backup->disableCompilable();
}
if (SDK_INT >= ANDROID_O) {
backup->disableInterpreterForO();
}
if (!backup->isStatic()) {
backup->setPrivate();
}
backup->tryDisableInline();
} else {
return;
}
backup->flushCache();
}
}
bool doHookWithReplacement(JNIEnv* env,
art::mirror::ArtMethod *originMethod,
art::mirror::ArtMethod *hookMethod,
......@@ -264,19 +217,6 @@ Java_com_swift_sandhook_SandHook_ensureMethodCached(JNIEnv *env, jclass type, jo
ensureMethodCached(hookeMethod, backupMethod);
}
extern "C"
JNIEXPORT void JNICALL
Java_com_swift_sandhook_SandHook_ensureBackupMethod(JNIEnv *env, jclass type,
jobject originMethod,
jobject backupMethod) {
if (backupMethod == NULL || originMethod == NULL)
return;
art::mirror::ArtMethod* origin = reinterpret_cast<art::mirror::ArtMethod *>(env->FromReflectedMethod(originMethod));
art::mirror::ArtMethod* backup = reinterpret_cast<art::mirror::ArtMethod *>(env->FromReflectedMethod(backupMethod));
ensureBackupMethod(origin, backup);
}
extern "C"
JNIEXPORT jboolean JNICALL
Java_com_swift_sandhook_SandHook_compileMethod(JNIEnv *env, jclass type, jobject member) {
......
......@@ -172,37 +172,9 @@ public class SandHook {
}
}
public static Object ensureBackupAndCallOriginMethod(Member originMethod, Method backupMethod, Object thiz, Object[] args) throws Throwable {
backupMethod.setAccessible(true);
if (Modifier.isStatic(originMethod.getModifiers())) {
ensureBackupMethod(originMethod, backupMethod);
return backupMethod.invoke(null, args);
} else {
ensureBackupMethod(originMethod, backupMethod);
return backupMethod.invoke(thiz, args);
}
}
public static void ensureBackupMethod(Method backupMethod) {
if (backupMethod == null)
return;
HookWrapper.HookEntity hookEntity = globalBackupMap.get(backupMethod);
if (hookEntity == null)
return;
ensureBackupMethod(hookEntity.target, backupMethod);
}
public static void ensureBackupMethodByOrigin(Member originMethod) {
if (originMethod == null)
return;
HookWrapper.HookEntity hookEntity = globalHookEntityMap.get(originMethod);
if (hookEntity == null || hookEntity.backup == null)
return;
ensureBackupMethod(originMethod, hookEntity.backup);
}
public static void resolveStaticMethod(Member method) {
//ignore result, just call to trigger resolve
if (method == null)
......@@ -330,8 +302,6 @@ public class SandHook {
public static native void ensureMethodCached(Method hook, Method backup);
public static native void ensureBackupMethod(Member originMethod, Method backupMethod);
public static native boolean compileMethod(Member member);
public static native boolean canGetObject();
......
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