[core] clean
This commit is contained in:
parent
64c89d7fa7
commit
338c73bf10
|
|
@ -367,21 +367,13 @@ public final class XposedInit {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// module can load it's own so
|
var librarySearchPath = new StringBuilder();
|
||||||
StringBuilder nativePath = new StringBuilder();
|
var abis = Process.is64Bit() ? Build.SUPPORTED_64_BIT_ABIS : Build.SUPPORTED_32_BIT_ABIS;
|
||||||
// Compatible with applications with 32-bit native libraries only
|
for (String abi : abis) {
|
||||||
if (android.os.Process.is64Bit()) {
|
librarySearchPath.append(apk).append("!/lib/").append(abi).append(File.pathSeparator);
|
||||||
for (String i : Build.SUPPORTED_64_BIT_ABIS) {
|
|
||||||
nativePath.append(apk).append("!/lib/").append(i).append(File.pathSeparator);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
for (String i : Build.SUPPORTED_32_BIT_ABIS) {
|
|
||||||
nativePath.append(apk).append("!/lib/").append(i).append(File.pathSeparator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Log.d(TAG, "Allowed native path" + nativePath.toString());
|
|
||||||
ClassLoader initLoader = XposedInit.class.getClassLoader();
|
ClassLoader initLoader = XposedInit.class.getClassLoader();
|
||||||
ClassLoader mcl = new DelegateLastClassLoader(apk, nativePath.toString(), initLoader);
|
ClassLoader mcl = new DelegateLastClassLoader(apk, librarySearchPath.toString(), initLoader);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (mcl.loadClass(XposedBridge.class.getName()).getClassLoader() != initLoader) {
|
if (mcl.loadClass(XposedBridge.class.getName()).getClassLoader() != initLoader) {
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,6 @@ import org.lsposed.lspd.hooker.SystemMainHooker;
|
||||||
import org.lsposed.lspd.service.ServiceManager;
|
import org.lsposed.lspd.service.ServiceManager;
|
||||||
import org.lsposed.lspd.util.ModuleLogger;
|
import org.lsposed.lspd.util.ModuleLogger;
|
||||||
import org.lsposed.lspd.util.Utils;
|
import org.lsposed.lspd.util.Utils;
|
||||||
import org.lsposed.lspd.util.Versions;
|
|
||||||
import org.lsposed.lspd.yahfa.hooker.YahfaHooker;
|
import org.lsposed.lspd.yahfa.hooker.YahfaHooker;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -70,16 +69,6 @@ public class Main {
|
||||||
new LoadedApkCstrHooker());
|
new LoadedApkCstrHooker());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startSystemServerHook() {
|
|
||||||
StartBootstrapServicesHooker sbsHooker = new StartBootstrapServicesHooker();
|
|
||||||
Object[] paramTypesAndCallback = Versions.hasR() ?
|
|
||||||
new Object[]{"com.android.server.utils.TimingsTraceAndSlog", sbsHooker} :
|
|
||||||
new Object[]{sbsHooker};
|
|
||||||
XposedHelpers.findAndHookMethod("com.android.server.SystemServer",
|
|
||||||
SystemMainHooker.systemServerCL,
|
|
||||||
"startBootstrapServices", paramTypesAndCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void installBootstrapHooks(boolean isSystem, String appDataDir) {
|
private static void installBootstrapHooks(boolean isSystem, String appDataDir) {
|
||||||
// Initialize the Xposed framework
|
// Initialize the Xposed framework
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,8 @@ public class HandleBindAppHooker extends XC_MethodHook {
|
||||||
// save app process name here for later use
|
// save app process name here for later use
|
||||||
String appProcessName = (String) XposedHelpers.getObjectField(bindData, "processName");
|
String appProcessName = (String) XposedHelpers.getObjectField(bindData, "processName");
|
||||||
String reportedPackageName = appInfo.packageName.equals("android") ? "system" : appInfo.packageName;
|
String reportedPackageName = appInfo.packageName.equals("android") ? "system" : appInfo.packageName;
|
||||||
|
// Note: packageName="android" -> system_server process, ams pms etc;
|
||||||
|
// packageName="system" -> android pkg, system dialogues.
|
||||||
Utils.logD("processName=" + appProcessName +
|
Utils.logD("processName=" + appProcessName +
|
||||||
", packageName=" + reportedPackageName + ", appDataDir=" + appDataDir);
|
", packageName=" + reportedPackageName + ", appDataDir=" + appDataDir);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,10 @@ import de.robv.android.xposed.XposedHelpers;
|
||||||
import de.robv.android.xposed.XposedInit;
|
import de.robv.android.xposed.XposedInit;
|
||||||
|
|
||||||
// when a package is loaded for an existing process, trigger the callbacks as well
|
// when a package is loaded for an existing process, trigger the callbacks as well
|
||||||
// ed: remove resources related hooking
|
|
||||||
public class LoadedApkCstrHooker extends XC_MethodHook {
|
public class LoadedApkCstrHooker extends XC_MethodHook {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
protected void afterHookedMethod(MethodHookParam param) {
|
||||||
Hookers.logD("LoadedApk#<init> starts");
|
Hookers.logD("LoadedApk#<init> starts");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ public class LoadedApkGetCLHooker extends XC_MethodHook {
|
||||||
IBinder binder = loadedApk.getApplicationInfo() != null ? serviceClient.requestManagerBinder(loadedApk.getApplicationInfo().packageName) : null;
|
IBinder binder = loadedApk.getApplicationInfo() != null ? serviceClient.requestManagerBinder(loadedApk.getApplicationInfo().packageName) : null;
|
||||||
if (binder != null) {
|
if (binder != null) {
|
||||||
if (InstallerVerifier.verifyInstallerSignature(loadedApk.getApplicationInfo())) {
|
if (InstallerVerifier.verifyInstallerSignature(loadedApk.getApplicationInfo())) {
|
||||||
XposedInstallerHooker.hookXposedInstaller(lpparam.classLoader, binder);
|
InstallerVerifier.hookXposedInstaller(lpparam.classLoader, binder);
|
||||||
} else {
|
} else {
|
||||||
InstallerVerifier.hookXposedInstaller(classLoader);
|
InstallerVerifier.hookXposedInstaller(classLoader);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import de.robv.android.xposed.callbacks.XC_LoadPackage;
|
||||||
public class StartBootstrapServicesHooker extends XC_MethodHook {
|
public class StartBootstrapServicesHooker extends XC_MethodHook {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
|
protected void beforeHookedMethod(MethodHookParam param) {
|
||||||
logD("SystemServer#startBootstrapServices() starts");
|
logD("SystemServer#startBootstrapServices() starts");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -20,27 +20,33 @@
|
||||||
|
|
||||||
package org.lsposed.lspd.hooker;
|
package org.lsposed.lspd.hooker;
|
||||||
|
|
||||||
import org.lsposed.lspd.core.Main;
|
import android.os.Build;
|
||||||
|
|
||||||
import org.lsposed.lspd.deopt.PrebuiltMethodsDeopter;
|
import org.lsposed.lspd.deopt.PrebuiltMethodsDeopter;
|
||||||
import org.lsposed.lspd.util.Hookers;
|
import org.lsposed.lspd.util.Hookers;
|
||||||
|
|
||||||
import de.robv.android.xposed.XC_MethodHook;
|
import de.robv.android.xposed.XC_MethodHook;
|
||||||
|
import de.robv.android.xposed.XposedHelpers;
|
||||||
|
|
||||||
// system_server initialization
|
// system_server initialization
|
||||||
// ed: only support sdk >= 21 for now
|
|
||||||
public class SystemMainHooker extends XC_MethodHook {
|
public class SystemMainHooker extends XC_MethodHook {
|
||||||
|
|
||||||
public static volatile ClassLoader systemServerCL;
|
public static volatile ClassLoader systemServerCL;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
|
protected void afterHookedMethod(MethodHookParam param) {
|
||||||
Hookers.logD("ActivityThread#systemMain() starts");
|
Hookers.logD("ActivityThread#systemMain() starts");
|
||||||
try {
|
try {
|
||||||
// get system_server classLoader
|
// get system_server classLoader
|
||||||
systemServerCL = Thread.currentThread().getContextClassLoader();
|
systemServerCL = Thread.currentThread().getContextClassLoader();
|
||||||
// deopt methods in SYSTEMSERVERCLASSPATH
|
// deopt methods in SYSTEMSERVERCLASSPATH
|
||||||
PrebuiltMethodsDeopter.deoptSystemServerMethods(systemServerCL);
|
PrebuiltMethodsDeopter.deoptSystemServerMethods(systemServerCL);
|
||||||
Main.startSystemServerHook();
|
var sbsHooker = new StartBootstrapServicesHooker();
|
||||||
|
Object[] paramTypesAndCallback = Build.VERSION.SDK_INT >= Build.VERSION_CODES.R ?
|
||||||
|
new Object[]{"com.android.server.utils.TimingsTraceAndSlog", sbsHooker} :
|
||||||
|
new Object[]{sbsHooker};
|
||||||
|
XposedHelpers.findAndHookMethod("com.android.server.SystemServer",
|
||||||
|
systemServerCL, "startBootstrapServices", paramTypesAndCallback);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Hookers.logE("error when hooking systemMain", t);
|
Hookers.logE("error when hooking systemMain", t);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of LSPosed.
|
|
||||||
*
|
|
||||||
* LSPosed is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LSPosed is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 EdXposed Contributors
|
|
||||||
* Copyright (C) 2021 LSPosed Contributors
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lsposed.lspd.hooker;
|
|
||||||
|
|
||||||
import android.os.IBinder;
|
|
||||||
|
|
||||||
import org.lsposed.lspd.util.Utils;
|
|
||||||
|
|
||||||
import de.robv.android.xposed.XposedHelpers;
|
|
||||||
|
|
||||||
public class XposedInstallerHooker {
|
|
||||||
|
|
||||||
public static void hookXposedInstaller(final ClassLoader classLoader, IBinder binder) {
|
|
||||||
Utils.logI("Found LSPosed Manager, hooking it");
|
|
||||||
try {
|
|
||||||
Class<?> serviceClass = XposedHelpers.findClass("org.lsposed.manager.receivers.LSPManagerServiceClient", classLoader);
|
|
||||||
XposedHelpers.setStaticObjectField(serviceClass, "binder", binder);
|
|
||||||
|
|
||||||
Utils.logI("Hooked LSPosed Manager");
|
|
||||||
} catch (Throwable t) {
|
|
||||||
Utils.logW("Could not hook LSPosed Manager", t);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -26,6 +26,7 @@ import android.content.Context;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.IBinder;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.android.apksig.ApkVerifier;
|
import com.android.apksig.ApkVerifier;
|
||||||
|
|
@ -72,4 +73,16 @@ public class InstallerVerifier {
|
||||||
Utils.logW("hookXposedInstaller: ", t);
|
Utils.logW("hookXposedInstaller: ", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void hookXposedInstaller(final ClassLoader classLoader, IBinder binder) {
|
||||||
|
Utils.logI("Found LSPosed Manager, hooking it");
|
||||||
|
try {
|
||||||
|
Class<?> serviceClass = XposedHelpers.findClass("org.lsposed.manager.receivers.LSPManagerServiceClient", classLoader);
|
||||||
|
XposedHelpers.setStaticObjectField(serviceClass, "binder", binder);
|
||||||
|
|
||||||
|
Utils.logI("Hooked LSPosed Manager");
|
||||||
|
} catch (Throwable t) {
|
||||||
|
Utils.logW("Could not hook LSPosed Manager", t);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* <!--This file is part of LSPosed.
|
|
||||||
*
|
|
||||||
* LSPosed is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LSPosed is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2021 LSPosed Contributors-->
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lsposed.lspd.util;
|
|
||||||
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class Logger {
|
|
||||||
private static final String TAG = "LSPosed";
|
|
||||||
|
|
||||||
public static int e(String msg) {
|
|
||||||
return Log.e(TAG, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int e(String msg, Throwable e) {
|
|
||||||
return Log.e(TAG, msg, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int e(Throwable e) {
|
|
||||||
return Log.e(TAG, e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int d(String msg) {
|
|
||||||
return Log.d(TAG, msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int w(String msg) {
|
|
||||||
return Log.w(TAG, msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of LSPosed.
|
|
||||||
*
|
|
||||||
* LSPosed is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LSPosed is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 EdXposed Contributors
|
|
||||||
* Copyright (C) 2021 LSPosed Contributors
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lsposed.lspd.util;
|
|
||||||
|
|
||||||
public class ProxyClassLoader extends ClassLoader {
|
|
||||||
|
|
||||||
private final ClassLoader mClassLoader;
|
|
||||||
|
|
||||||
public ProxyClassLoader(ClassLoader parentCL, ClassLoader appCL) {
|
|
||||||
super(parentCL);
|
|
||||||
mClassLoader = appCL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
|
||||||
Class<?> clazz = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
clazz = mClassLoader.loadClass(name);
|
|
||||||
} catch (ClassNotFoundException ignored) {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (clazz == null) {
|
|
||||||
clazz = super.loadClass(name, resolve);
|
|
||||||
if (clazz == null) {
|
|
||||||
throw new ClassNotFoundException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return clazz;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of LSPosed.
|
|
||||||
*
|
|
||||||
* LSPosed is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* LSPosed is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 EdXposed Contributors
|
|
||||||
* Copyright (C) 2021 LSPosed Contributors
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.lsposed.lspd.util;
|
|
||||||
|
|
||||||
import android.os.Build;
|
|
||||||
|
|
||||||
public class Versions {
|
|
||||||
|
|
||||||
public static boolean hasR() {
|
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.R;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasQ() {
|
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
package org.lsposed.lspd.yahfa.dexmaker;
|
package org.lsposed.lspd.yahfa.dexmaker;
|
||||||
|
|
||||||
import org.lsposed.lspd.util.Logger;
|
import org.lsposed.lspd.util.Utils;
|
||||||
|
|
||||||
import java.lang.reflect.Executable;
|
import java.lang.reflect.Executable;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
@ -34,21 +34,20 @@ public final class DynamicBridge {
|
||||||
private static final ConcurrentHashMap<Executable, LspHooker> hookedInfo = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<Executable, LspHooker> hookedInfo = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
public static synchronized void hookMethod(Executable hookMethod, XposedBridge.AdditionalHookInfo additionalHookInfo) {
|
public static synchronized void hookMethod(Executable hookMethod, XposedBridge.AdditionalHookInfo additionalHookInfo) {
|
||||||
Logger.d("hooking " + hookMethod);
|
Utils.logD("hooking " + hookMethod);
|
||||||
|
|
||||||
if (hookedInfo.containsKey(hookMethod)) {
|
if (hookedInfo.containsKey(hookMethod)) {
|
||||||
Logger.w("already hook method:" + hookMethod.toString());
|
Utils.logW("already hook method:" + hookMethod);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.d("start to generate class for: " + hookMethod);
|
Utils.logD("start to generate class for: " + hookMethod);
|
||||||
try {
|
try {
|
||||||
final HookerDexMaker dexMaker = new HookerDexMaker();
|
final HookerDexMaker dexMaker = new HookerDexMaker();
|
||||||
dexMaker.start(hookMethod, additionalHookInfo,
|
dexMaker.start(hookMethod, additionalHookInfo);
|
||||||
hookMethod.getDeclaringClass().getClassLoader());
|
|
||||||
hookedInfo.put(hookMethod, dexMaker.getHooker());
|
hookedInfo.put(hookMethod, dexMaker.getHooker());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Logger.e("error occur when generating dex.", e);
|
Utils.logE("error occur when generating dex.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,5 +63,3 @@ public final class DynamicBridge {
|
||||||
return hooker.invokeOriginalMethod(thisObject, args);
|
return hooker.invokeOriginalMethod(thisObject, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,7 @@ package org.lsposed.lspd.yahfa.dexmaker;
|
||||||
|
|
||||||
import org.lsposed.lspd.core.yahfa.HookMain;
|
import org.lsposed.lspd.core.yahfa.HookMain;
|
||||||
import org.lsposed.lspd.nativebridge.Yahfa;
|
import org.lsposed.lspd.nativebridge.Yahfa;
|
||||||
import org.lsposed.lspd.util.Logger;
|
import org.lsposed.lspd.util.Utils;
|
||||||
import org.lsposed.lspd.util.ProxyClassLoader;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Executable;
|
import java.lang.reflect.Executable;
|
||||||
|
|
@ -57,7 +56,6 @@ public class HookerDexMaker {
|
||||||
|
|
||||||
private Executable mMember;
|
private Executable mMember;
|
||||||
private XposedBridge.AdditionalHookInfo mHookInfo;
|
private XposedBridge.AdditionalHookInfo mHookInfo;
|
||||||
private ClassLoader mAppClassLoader;
|
|
||||||
private LspHooker mHooker;
|
private LspHooker mHooker;
|
||||||
|
|
||||||
private static Class<?>[] getParameterTypes(Executable method, boolean isStatic) {
|
private static Class<?>[] getParameterTypes(Executable method, boolean isStatic) {
|
||||||
|
|
@ -87,8 +85,7 @@ public class HookerDexMaker {
|
||||||
return descriptors;
|
return descriptors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(Executable member, XposedBridge.AdditionalHookInfo hookInfo,
|
public void start(Executable member, XposedBridge.AdditionalHookInfo hookInfo) throws Exception {
|
||||||
ClassLoader appClassLoader) throws Exception {
|
|
||||||
if (member instanceof Method) {
|
if (member instanceof Method) {
|
||||||
Method method = (Method) member;
|
Method method = (Method) member;
|
||||||
mReturnType = method.getReturnType();
|
mReturnType = method.getReturnType();
|
||||||
|
|
@ -100,22 +97,15 @@ public class HookerDexMaker {
|
||||||
}
|
}
|
||||||
mMember = member;
|
mMember = member;
|
||||||
mHookInfo = hookInfo;
|
mHookInfo = hookInfo;
|
||||||
if (appClassLoader == null
|
|
||||||
|| appClassLoader.getClass().getName().equals("java.lang.BootClassLoader")) {
|
|
||||||
mAppClassLoader = getClass().getClassLoader();
|
|
||||||
} else {
|
|
||||||
mAppClassLoader = appClassLoader;
|
|
||||||
mAppClassLoader = new ProxyClassLoader(mAppClassLoader, getClass().getClassLoader());
|
|
||||||
}
|
|
||||||
|
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
doMake(member instanceof Constructor ? "constructor" : member.getName());
|
doMake(member instanceof Constructor ? "constructor" : member.getName());
|
||||||
long endTime = System.nanoTime();
|
long endTime = System.nanoTime();
|
||||||
Logger.d("Hook time: " + (endTime - startTime) / 1e6 + "ms");
|
Utils.logD("Hook time: " + (endTime - startTime) / 1e6 + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doMake(String methodName) throws Exception {
|
private void doMake(String methodName) throws Exception {
|
||||||
Class<?> hookClass = Yahfa.buildHooker(mAppClassLoader, getDescriptor(mReturnType), getDescriptors(mActualParameterTypes), methodName);
|
Class<?> hookClass = Yahfa.buildHooker(LspHooker.class.getClassLoader(), getDescriptor(mReturnType), getDescriptors(mActualParameterTypes), methodName);
|
||||||
// Execute our newly-generated code in-process.
|
// Execute our newly-generated code in-process.
|
||||||
Method backupMethod = hookClass.getMethod(METHOD_NAME_BACKUP, mActualParameterTypes);
|
Method backupMethod = hookClass.getMethod(METHOD_NAME_BACKUP, mActualParameterTypes);
|
||||||
mHooker = new LspHooker(mHookInfo, mMember, backupMethod);
|
mHooker = new LspHooker(mHookInfo, mMember, backupMethod);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue