Fix exceptions when hooking pending methods
This commit is contained in:
parent
12dcfed0f3
commit
c5791951db
|
|
@ -36,4 +36,4 @@ only_commits:
|
|||
- gradle.properties
|
||||
- appveyor.yml
|
||||
|
||||
version: '0.4.4.4_alpha (4441) {build}'
|
||||
version: '0.4.4.5_alpha (4450) {build}'
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ import com.elderdrivers.riru.common.KeepAll;
|
|||
|
||||
import java.lang.reflect.Member;
|
||||
|
||||
import de.robv.android.xposed.XposedBridge;
|
||||
import de.robv.android.xposed.PendingHooks;
|
||||
|
||||
public class ClassLinker implements KeepAll {
|
||||
|
||||
public static native void setEntryPointsToInterpreter(Member method);
|
||||
|
||||
public static void onPostFixupStaticTrampolines(Class clazz) {
|
||||
XposedBridge.hookPendingMethod(clazz);
|
||||
PendingHooks.hookPendingMethod(clazz);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ import org.gradle.internal.os.OperatingSystem
|
|||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
version "v0.4.4.4_alpha"
|
||||
version "v0.4.4.5_alpha"
|
||||
|
||||
ext {
|
||||
versionCode = "4441"
|
||||
versionCode = "4450"
|
||||
module_name = "EdXposed"
|
||||
jar_dest_dir = "${projectDir}/template_override/system/framework/"
|
||||
is_windows = OperatingSystem.current().isWindows()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ namespace art {
|
|||
|
||||
CREATE_FUNC_SYMBOL_ENTRY(const char *, GetDescriptor, void *thiz,
|
||||
std::string *storage) {
|
||||
return GetDescriptorSym(thiz, storage);
|
||||
if (GetDescriptorSym)
|
||||
return GetDescriptorSym(thiz, storage);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
CREATE_HOOK_STUB_ENTRIES(bool, IsInSamePackage, void *thiz, void *that) {
|
||||
|
|
@ -57,6 +60,13 @@ namespace art {
|
|||
// HOOK_FUNC(ClassForName,
|
||||
// "_ZN3artL18Class_classForNameEP7_JNIEnvP7_jclassP8_jstringhP8_jobject");
|
||||
}
|
||||
|
||||
const char *GetDescriptor(std::string *storage) {
|
||||
if (thiz_ && GetDescriptorSym) {
|
||||
return GetDescriptor(thiz_, storage);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace mirror
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@
|
|||
#include <jni/edxp_resources_hook.h>
|
||||
#include <dl_util.h>
|
||||
#include <art/runtime/jni_env_ext.h>
|
||||
#include <art/runtime/mirror/class.h>
|
||||
#include <android-base/strings.h>
|
||||
#include "edxp_context.h"
|
||||
#include "config_manager.h"
|
||||
|
||||
|
|
@ -36,11 +38,16 @@ namespace edxp {
|
|||
if (UNLIKELY(!post_fixup_static_mid_ || !class_linker_class_)) {
|
||||
return;
|
||||
}
|
||||
if (!class_ptr) {
|
||||
return;
|
||||
}
|
||||
JNIEnv *env;
|
||||
vm_->GetEnv((void **) (&env), JNI_VERSION_1_4);
|
||||
art::JNIEnvExt env_ext(env);
|
||||
ScopedLocalRef clazz(env, env_ext.NewLocalRefer(class_ptr));
|
||||
JNI_CallStaticVoidMethod(env, class_linker_class_, post_fixup_static_mid_, clazz.get());
|
||||
if (clazz != nullptr) {
|
||||
JNI_CallStaticVoidMethod(env, class_linker_class_, post_fixup_static_mid_, clazz.get());
|
||||
}
|
||||
}
|
||||
|
||||
void Context::LoadDexAndInit(JNIEnv *env, const char *dex_path) {
|
||||
|
|
@ -169,7 +176,7 @@ namespace edxp {
|
|||
if (LIKELY(mid)) {
|
||||
va_list args;
|
||||
va_start(args, method_sig);
|
||||
env->functions->CallStaticVoidMethodV(env, entry_class_, mid, args);
|
||||
env->CallStaticVoidMethodV(entry_class_, mid, args);
|
||||
va_end(args);
|
||||
} else {
|
||||
LOGE("method %s id is null", method_name);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#!/system/bin/sh
|
||||
|
||||
EDXP_VERSION="0.4.4.4_alpha (4441)"
|
||||
EDXP_VERSION="0.4.4.5_alpha (4450)"
|
||||
ANDROID_SDK=`getprop ro.build.version.sdk`
|
||||
BUILD_DESC=`getprop ro.build.description`
|
||||
PRODUCT=`getprop ro.build.product`
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package de.robv.android.xposed;
|
||||
|
||||
import java.lang.reflect.Member;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static de.robv.android.xposed.XposedBridge.hookMethodNative;
|
||||
|
||||
public final class PendingHooks {
|
||||
|
||||
private static final ConcurrentHashMap<Member, XposedBridge.AdditionalHookInfo>
|
||||
sPendingHookMethods = new ConcurrentHashMap<>();
|
||||
|
||||
public synchronized static void hookPendingMethod(Class clazz) {
|
||||
for (Member member : sPendingHookMethods.keySet()) {
|
||||
if (member.getDeclaringClass().equals(clazz)) {
|
||||
hookMethodNative(member, clazz, 0, sPendingHookMethods.get(member));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized static void recordPendingMethod(Member hookMethod, XposedBridge.AdditionalHookInfo additionalInfo) {
|
||||
sPendingHookMethods.put(hookMethod, additionalInfo);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,6 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import dalvik.system.InMemoryDexClassLoader;
|
||||
import de.robv.android.xposed.XC_MethodHook.MethodHookParam;
|
||||
|
|
@ -235,29 +234,13 @@ public final class XposedBridge {
|
|||
if (reflectMethod != null) {
|
||||
hookMethodNative(reflectMethod, declaringClass, slot, additionalInfo);
|
||||
} else {
|
||||
synchronized (pendingLock) {
|
||||
sPendingHookMethods.put(hookMethod, additionalInfo);
|
||||
}
|
||||
PendingHooks.recordPendingMethod(hookMethod, additionalInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return callback.new Unhook(hookMethod);
|
||||
}
|
||||
|
||||
private static final ConcurrentHashMap<Member, XposedBridge.AdditionalHookInfo>
|
||||
sPendingHookMethods = new ConcurrentHashMap<>();
|
||||
private static final Object pendingLock = new Object();
|
||||
|
||||
public static void hookPendingMethod(Class clazz) {
|
||||
synchronized (pendingLock) {
|
||||
for (Member member : sPendingHookMethods.keySet()) {
|
||||
if (member.getDeclaringClass().equals(clazz)) {
|
||||
hookMethodNative(member, clazz, 0, sPendingHookMethods.get(member));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the callback for a hooked method/constructor.
|
||||
*
|
||||
|
|
@ -448,7 +431,7 @@ public final class XposedBridge {
|
|||
* Intercept every call to the specified method and call a handler function instead.
|
||||
* @param method The method to intercept
|
||||
*/
|
||||
private synchronized static void hookMethodNative(final Member method, Class<?> declaringClass,
|
||||
/*package*/ synchronized static void hookMethodNative(final Member method, Class<?> declaringClass,
|
||||
int slot, final Object additionalInfoObj) {
|
||||
EdXpConfigGlobal.getHookProvider().hookMethod(method, (AdditionalHookInfo) additionalInfoObj);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue