Fix ShouldUseInterpreterEntrypoint for pendding hook

This commit is contained in:
LoveSy 2021-01-29 04:36:11 +08:00
parent 3896a76373
commit 716dfae0f6
5 changed files with 19 additions and 59 deletions

View File

@ -125,21 +125,8 @@ public class App extends Application {
pref = PreferenceManager.getDefaultSharedPreferences(this);
master();
NotificationUtil.init();
Shizuku.addRequestPermissionResultListener(REQUEST_PERMISSION_RESULT_LISTENER);
}
private void master() {
// This will affect the fengshui of the whole app, don't remove this
Constants.getXposedVersionCode();
Constants.getXposedVersion();
Constants.getXposedApiVersion();
Constants.getXposedVariant();
Constants.getBaseDir();
Constants.getModulesListFile();
Constants.getEnabledModulesListFile();
}
}

View File

@ -4,62 +4,34 @@ import android.util.Log;
public class Constants {
public static int getXposedApiVersion() {
try {
Log.e(App.TAG, "getXposedApiVersion: Xposed is not active");
return -1;
} catch (Exception e) {
return -1;
}
Log.e(App.TAG, "getXposedApiVersion: Xposed is not active");
return -1;
}
public static String getXposedVersion() {
try {
Log.e(App.TAG, "getXposedVersion: Xposed is not active");
return null;
} catch (Exception e) {
return null;
}
Log.e(App.TAG, "getXposedVersion: Xposed is not active");
return null;
}
public static int getXposedVersionCode() {
try {
Log.e(App.TAG, "getXposedVersionCode: Xposed is not active");
return -1;
} catch (Exception e) {
return -1;
}
Log.e(App.TAG, "getXposedVersionCode: Xposed is not active");
return -1;
}
public static String getXposedVariant() {
try {
Log.e(App.TAG, "getXposedVariant: Xposed is not active");
return null;
} catch (Exception e) {
return null;
}
Log.e(App.TAG, "getXposedVariant: Xposed is not active");
return null;
}
public static String getEnabledModulesListFile() {
try {
return getBaseDir() + "conf/enabled_modules.list";
} catch (Exception e) {
return null;
}
return getBaseDir() + "conf/enabled_modules.list";
}
public static String getModulesListFile() {
try {
return getBaseDir() + "conf/modules.list";
} catch (Exception e) {
return null;
}
return getBaseDir() + "conf/modules.list";
}
public static String getBaseDir() {
try {
return App.getInstance().getApplicationInfo().deviceProtectedDataDir + "/";
} catch (Exception e) {
return null;
}
return App.getInstance().getApplicationInfo().deviceProtectedDataDir + "/";
}
}

View File

@ -1,10 +1,8 @@
package io.github.lsposed.manager.ui.activity;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.widget.PopupMenu;
import androidx.appcompat.widget.TooltipCompat;

View File

@ -19,11 +19,14 @@ namespace lspd {
return pending_classes_.count(clazz);
}
static void PendingHooks_recordPendingMethodNative(JNI_START, jclass class_ref) {
static void PendingHooks_recordPendingMethodNative(JNI_START, jobject method_ref, jclass class_ref) {
auto *class_ptr = art::Thread::Current().DecodeJObject(class_ref);
auto *method = getArtMethod(env, method_ref);
art::mirror::Class mirror_class(class_ptr);
if (auto def = mirror_class.GetClassDef(); LIKELY(def)) {
LOGD("record pending: %p (%s)", class_ptr, mirror_class.GetDescriptor().c_str());
LOGD("record pending: %p (%s) with %p", class_ptr, mirror_class.GetDescriptor().c_str(), method);
// Add it for ShouldUseInterpreterEntrypoint
recordHooked(method);
pending_classes_.insert(def);
} else {
LOGW("fail to record pending for : %p (%s)", class_ptr,
@ -32,7 +35,7 @@ namespace lspd {
}
static JNINativeMethod gMethods[] = {
NATIVE_METHOD(PendingHooks, recordPendingMethodNative, "(Ljava/lang/Class;)V"),
NATIVE_METHOD(PendingHooks, recordPendingMethodNative, "(Ljava/lang/reflect/Member;Ljava/lang/Class;)V"),
};
void RegisterPendingHooks(JNIEnv *env) {

View File

@ -33,12 +33,12 @@ public final class PendingHooks {
});
pending.put(hookMethod, additionalInfo);
recordPendingMethodNative(hookMethod.getDeclaringClass());
recordPendingMethodNative(hookMethod, hookMethod.getDeclaringClass());
}
public synchronized void cleanUp() {
sPendingHooks.clear();
}
private static native void recordPendingMethodNative(Class clazz);
private static native void recordPendingMethodNative(Member hookMethod, Class clazz);
}