Dont expose loaded param impl
This commit is contained in:
parent
265d8e7e76
commit
7b4c10da07
|
|
@ -130,7 +130,6 @@ abstract class ExampleClassVisitorFactory : AsmClassVisitorFactory<Instrumentati
|
|||
) {
|
||||
if (opcode == Opcodes.INVOKESPECIAL) {
|
||||
for (i in 0 .. Type.getMethodType(descriptor).argumentTypes.size) {
|
||||
println("load param $i")
|
||||
super.visitVarInsn(Opcodes.ALOAD, i)
|
||||
}
|
||||
val newOwner =
|
||||
|
|
|
|||
|
|
@ -211,10 +211,7 @@ public final class XposedInit {
|
|||
resparam.res = newRes;
|
||||
XCallback.callAll(resparam);
|
||||
|
||||
var rlparam = new XposedModuleInterface.ResourceLoadedParam();
|
||||
rlparam.packageName = packageName;
|
||||
rlparam.res = newRes;
|
||||
LSPosedContext.callOnResourceLoaded(rlparam, null);
|
||||
LSPosedContext.callOnResourceLoaded(resparam);
|
||||
}
|
||||
|
||||
param.setResult(newRes);
|
||||
|
|
|
|||
|
|
@ -21,10 +21,16 @@
|
|||
package de.robv.android.xposed.callbacks;
|
||||
|
||||
import android.content.res.XResources;
|
||||
import android.content.res.XposedResources;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import de.robv.android.xposed.IXposedHookInitPackageResources;
|
||||
import io.github.libxposed.XposedModuleInterface;
|
||||
|
||||
/**
|
||||
* This class is only used for internal purposes, except for the {@link InitPackageResourcesParam}
|
||||
|
|
@ -54,7 +60,7 @@ public abstract class XC_InitPackageResources extends XCallback implements IXpos
|
|||
/**
|
||||
* Wraps information about the resources being initialized.
|
||||
*/
|
||||
public static final class InitPackageResourcesParam extends XCallback.Param {
|
||||
public static final class InitPackageResourcesParam extends XCallback.Param implements XposedModuleInterface.ResourcesLoadedParam {
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
|
@ -72,6 +78,24 @@ public abstract class XC_InitPackageResources extends XCallback implements IXpos
|
|||
* {@link XResources#setReplacement(String, String, String, Object)}.
|
||||
*/
|
||||
public XResources res;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public XposedResources getResources() {
|
||||
return res;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Bundle getExtras() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -21,11 +21,16 @@
|
|||
package de.robv.android.xposed.callbacks;
|
||||
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
import de.robv.android.xposed.IXposedHookLoadPackage;
|
||||
import de.robv.android.xposed.XposedBridge.CopyOnWriteSortedSet;
|
||||
import io.github.libxposed.XposedModuleInterface;
|
||||
|
||||
/**
|
||||
* This class is only used for internal purposes, except for the {@link LoadPackageParam}
|
||||
|
|
@ -55,7 +60,7 @@ public abstract class XC_LoadPackage extends XCallback implements IXposedHookLoa
|
|||
/**
|
||||
* Wraps information about the app being loaded.
|
||||
*/
|
||||
public static final class LoadPackageParam extends XCallback.Param {
|
||||
public static final class LoadPackageParam extends XCallback.Param implements XposedModuleInterface.PackageLoadedParam {
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
|
|
@ -87,6 +92,41 @@ public abstract class XC_LoadPackage extends XCallback implements IXposedHookLoa
|
|||
* Set to {@code true} if this is the first (and main) application for this process.
|
||||
*/
|
||||
public boolean isFirstApplication;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getPackageName() {
|
||||
return packageName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ApplicationInfo getAppInfo() {
|
||||
return appInfo;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ClassLoader getClassLoader() {
|
||||
return classLoader;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getProcessName() {
|
||||
return processName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFirstApplication() {
|
||||
return isFirstApplication;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Bundle getExtras() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
package io.github.libxposed;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
public abstract class XposedModule extends XposedContextWrapper implements XposedModuleInterface {
|
||||
public XposedModule(XposedContext base, @SuppressWarnings("unused") boolean isSystemServer, @SuppressWarnings("unused") String processName, @SuppressWarnings("unused") String appDir, @SuppressWarnings("unused") @Nullable Bundle extras) {
|
||||
public XposedModule(XposedContext base, @SuppressWarnings("unused") @NonNull ModuleLoadedParam param) {
|
||||
super(base);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,24 +9,33 @@ import androidx.annotation.Nullable;
|
|||
|
||||
@SuppressWarnings("unused")
|
||||
public interface XposedModuleInterface {
|
||||
class PackageLoadedParam {
|
||||
public String packageName;
|
||||
public String processName;
|
||||
public ClassLoader classLoader;
|
||||
public ApplicationInfo appInfo;
|
||||
public boolean isFirstApplication;
|
||||
interface ModuleLoadedParam {
|
||||
boolean isSystemServer();
|
||||
@NonNull String getProcessName();
|
||||
@NonNull String getAppDataDir();
|
||||
@Nullable Bundle getExtras();
|
||||
}
|
||||
|
||||
class ResourceLoadedParam {
|
||||
public String packageName;
|
||||
public XposedResources res;
|
||||
interface PackageLoadedParam {
|
||||
@NonNull String getPackageName();
|
||||
@NonNull ApplicationInfo getAppInfo();
|
||||
@NonNull ClassLoader getClassLoader();
|
||||
@NonNull String getProcessName();
|
||||
boolean isFirstApplication();
|
||||
@Nullable Bundle getExtras();
|
||||
}
|
||||
|
||||
default void onPackageLoaded(@NonNull PackageLoadedParam param, @Nullable Bundle extra) {
|
||||
interface ResourcesLoadedParam {
|
||||
@NonNull String getPackageName();
|
||||
@NonNull XposedResources getResources();
|
||||
@Nullable Bundle getExtras();
|
||||
}
|
||||
|
||||
default void onPackageLoaded(@NonNull PackageLoadedParam param) {
|
||||
|
||||
}
|
||||
|
||||
default void onResourceLoaded(@NonNull ResourceLoadedParam param, @Nullable Bundle extra) {
|
||||
default void onResourceLoaded(@NonNull ResourcesLoadedParam param) {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,13 +93,7 @@ public class LoadedApkGetCLHooker extends XC_MethodHook {
|
|||
Hookers.logD("Call handleLoadedPackage: packageName=" + lpparam.packageName + " processName=" + lpparam.processName + " isFirstApplication=" + isFirstApplication + " classLoader=" + lpparam.classLoader + " appInfo=" + lpparam.appInfo);
|
||||
XC_LoadPackage.callAll(lpparam);
|
||||
|
||||
var plparam = new XposedModuleInterface.PackageLoadedParam();
|
||||
plparam.packageName = packageName;
|
||||
plparam.processName = processName;
|
||||
plparam.classLoader = classLoader;
|
||||
plparam.appInfo = loadedApk.getApplicationInfo();
|
||||
plparam.isFirstApplication = isFirstApplication;
|
||||
LSPosedContext.callOnPackageLoaded(plparam, null);
|
||||
LSPosedContext.callOnPackageLoaded(lpparam);
|
||||
} catch (Throwable t) {
|
||||
Hookers.logE("error when hooking LoadedApk#getClassLoader", t);
|
||||
} finally {
|
||||
|
|
|
|||
|
|
@ -77,20 +77,20 @@ public class LSPosedContext extends XposedContext {
|
|||
this.mApkPath = apkPath;
|
||||
}
|
||||
|
||||
public static void callOnPackageLoaded(XposedModuleInterface.PackageLoadedParam param, Bundle extra) {
|
||||
public static void callOnPackageLoaded(XposedModuleInterface.PackageLoadedParam param) {
|
||||
for (XposedModule module : modules) {
|
||||
try {
|
||||
module.onPackageLoaded(param, extra);
|
||||
module.onPackageLoaded(param);
|
||||
} catch (Throwable t) {
|
||||
Log.e(TAG, "Error when calling onPackageLoaded of " + ((LSPosedContext) module.getBaseContext()).mPackageName, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void callOnResourceLoaded(XposedModuleInterface.ResourceLoadedParam param, Bundle extra) {
|
||||
public static void callOnResourceLoaded(XposedModuleInterface.ResourcesLoadedParam param) {
|
||||
for (XposedModule module : modules) {
|
||||
try {
|
||||
module.onResourceLoaded(param, extra);
|
||||
module.onResourceLoaded(param);
|
||||
} catch (Throwable t) {
|
||||
Log.e(TAG, "Error when calling onResourceLoaded of " + ((LSPosedContext) module.getBaseContext()).mPackageName, t);
|
||||
}
|
||||
|
|
@ -149,11 +149,34 @@ public class LSPosedContext extends XposedContext {
|
|||
Log.e(TAG, " This class doesn't implement any sub-interface of XposedModule, skipping it");
|
||||
}
|
||||
try {
|
||||
if (moduleClass.getMethod("onResourceLoaded", XposedModuleInterface.ResourceLoadedParam.class, Bundle.class).getDeclaringClass() != XposedModuleInterface.class) {
|
||||
if (moduleClass.getMethod("onResourceLoaded", XposedModuleInterface.ResourcesLoadedParam.class).getDeclaringClass() != XposedModuleInterface.class) {
|
||||
XposedInit.hookResources();
|
||||
}
|
||||
var moduleEntry = moduleClass.getConstructor(XposedContext.class, boolean.class, String.class, Bundle.class);
|
||||
var moduleContext = (XposedModule) moduleEntry.newInstance(ctx, isSystemServer, processName, null);
|
||||
var moduleEntry = moduleClass.getConstructor(XposedContext.class, XposedModuleInterface.ModuleLoadedParam.class);
|
||||
var moduleContext = (XposedModule) moduleEntry.newInstance(ctx, new XposedModuleInterface.ModuleLoadedParam() {
|
||||
@Override
|
||||
public boolean isSystemServer() {
|
||||
return isSystemServer;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getProcessName() {
|
||||
return processName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getAppDataDir() {
|
||||
return appDir;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Bundle getExtras() {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
modules.add(moduleContext);
|
||||
} catch (Throwable e) {
|
||||
Log.e(TAG, " Failed to load class " + moduleClass, e);
|
||||
|
|
|
|||
Loading…
Reference in New Issue