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) {
|
if (opcode == Opcodes.INVOKESPECIAL) {
|
||||||
for (i in 0 .. Type.getMethodType(descriptor).argumentTypes.size) {
|
for (i in 0 .. Type.getMethodType(descriptor).argumentTypes.size) {
|
||||||
println("load param $i")
|
|
||||||
super.visitVarInsn(Opcodes.ALOAD, i)
|
super.visitVarInsn(Opcodes.ALOAD, i)
|
||||||
}
|
}
|
||||||
val newOwner =
|
val newOwner =
|
||||||
|
|
|
||||||
|
|
@ -211,10 +211,7 @@ public final class XposedInit {
|
||||||
resparam.res = newRes;
|
resparam.res = newRes;
|
||||||
XCallback.callAll(resparam);
|
XCallback.callAll(resparam);
|
||||||
|
|
||||||
var rlparam = new XposedModuleInterface.ResourceLoadedParam();
|
LSPosedContext.callOnResourceLoaded(resparam);
|
||||||
rlparam.packageName = packageName;
|
|
||||||
rlparam.res = newRes;
|
|
||||||
LSPosedContext.callOnResourceLoaded(rlparam, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
param.setResult(newRes);
|
param.setResult(newRes);
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,16 @@
|
||||||
package de.robv.android.xposed.callbacks;
|
package de.robv.android.xposed.callbacks;
|
||||||
|
|
||||||
import android.content.res.XResources;
|
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 java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import de.robv.android.xposed.IXposedHookInitPackageResources;
|
import de.robv.android.xposed.IXposedHookInitPackageResources;
|
||||||
|
import io.github.libxposed.XposedModuleInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is only used for internal purposes, except for the {@link InitPackageResourcesParam}
|
* 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.
|
* 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
|
* @hide
|
||||||
*/
|
*/
|
||||||
|
|
@ -72,6 +78,24 @@ public abstract class XC_InitPackageResources extends XCallback implements IXpos
|
||||||
* {@link XResources#setReplacement(String, String, String, Object)}.
|
* {@link XResources#setReplacement(String, String, String, Object)}.
|
||||||
*/
|
*/
|
||||||
public XResources res;
|
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;
|
package de.robv.android.xposed.callbacks;
|
||||||
|
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import java.util.concurrent.CopyOnWriteArraySet;
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||||||
|
|
||||||
import de.robv.android.xposed.IXposedHookLoadPackage;
|
import de.robv.android.xposed.IXposedHookLoadPackage;
|
||||||
import de.robv.android.xposed.XposedBridge.CopyOnWriteSortedSet;
|
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}
|
* 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.
|
* 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
|
* @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.
|
* Set to {@code true} if this is the first (and main) application for this process.
|
||||||
*/
|
*/
|
||||||
public boolean isFirstApplication;
|
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;
|
package io.github.libxposed;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
public abstract class XposedModule extends XposedContextWrapper implements XposedModuleInterface {
|
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);
|
super(base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,24 +9,33 @@ import androidx.annotation.Nullable;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public interface XposedModuleInterface {
|
public interface XposedModuleInterface {
|
||||||
class PackageLoadedParam {
|
interface ModuleLoadedParam {
|
||||||
public String packageName;
|
boolean isSystemServer();
|
||||||
public String processName;
|
@NonNull String getProcessName();
|
||||||
public ClassLoader classLoader;
|
@NonNull String getAppDataDir();
|
||||||
public ApplicationInfo appInfo;
|
@Nullable Bundle getExtras();
|
||||||
public boolean isFirstApplication;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class ResourceLoadedParam {
|
interface PackageLoadedParam {
|
||||||
public String packageName;
|
@NonNull String getPackageName();
|
||||||
public XposedResources res;
|
@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);
|
Hookers.logD("Call handleLoadedPackage: packageName=" + lpparam.packageName + " processName=" + lpparam.processName + " isFirstApplication=" + isFirstApplication + " classLoader=" + lpparam.classLoader + " appInfo=" + lpparam.appInfo);
|
||||||
XC_LoadPackage.callAll(lpparam);
|
XC_LoadPackage.callAll(lpparam);
|
||||||
|
|
||||||
var plparam = new XposedModuleInterface.PackageLoadedParam();
|
LSPosedContext.callOnPackageLoaded(lpparam);
|
||||||
plparam.packageName = packageName;
|
|
||||||
plparam.processName = processName;
|
|
||||||
plparam.classLoader = classLoader;
|
|
||||||
plparam.appInfo = loadedApk.getApplicationInfo();
|
|
||||||
plparam.isFirstApplication = isFirstApplication;
|
|
||||||
LSPosedContext.callOnPackageLoaded(plparam, null);
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Hookers.logE("error when hooking LoadedApk#getClassLoader", t);
|
Hookers.logE("error when hooking LoadedApk#getClassLoader", t);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
|
|
@ -77,20 +77,20 @@ public class LSPosedContext extends XposedContext {
|
||||||
this.mApkPath = apkPath;
|
this.mApkPath = apkPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void callOnPackageLoaded(XposedModuleInterface.PackageLoadedParam param, Bundle extra) {
|
public static void callOnPackageLoaded(XposedModuleInterface.PackageLoadedParam param) {
|
||||||
for (XposedModule module : modules) {
|
for (XposedModule module : modules) {
|
||||||
try {
|
try {
|
||||||
module.onPackageLoaded(param, extra);
|
module.onPackageLoaded(param);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.e(TAG, "Error when calling onPackageLoaded of " + ((LSPosedContext) module.getBaseContext()).mPackageName, 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) {
|
for (XposedModule module : modules) {
|
||||||
try {
|
try {
|
||||||
module.onResourceLoaded(param, extra);
|
module.onResourceLoaded(param);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.e(TAG, "Error when calling onResourceLoaded of " + ((LSPosedContext) module.getBaseContext()).mPackageName, 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");
|
Log.e(TAG, " This class doesn't implement any sub-interface of XposedModule, skipping it");
|
||||||
}
|
}
|
||||||
try {
|
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();
|
XposedInit.hookResources();
|
||||||
}
|
}
|
||||||
var moduleEntry = moduleClass.getConstructor(XposedContext.class, boolean.class, String.class, Bundle.class);
|
var moduleEntry = moduleClass.getConstructor(XposedContext.class, XposedModuleInterface.ModuleLoadedParam.class);
|
||||||
var moduleContext = (XposedModule) moduleEntry.newInstance(ctx, isSystemServer, processName, null);
|
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);
|
modules.add(moduleContext);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
Log.e(TAG, " Failed to load class " + moduleClass, e);
|
Log.e(TAG, " Failed to load class " + moduleClass, e);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue