[parasitic] Load original providers (#1139)
* Don't clear providers in handleBindApplication() * Load original providers * restore packageName Co-authored-by: 残页 <31466456+canyie@users.noreply.github.com>
This commit is contained in:
parent
91667dc67f
commit
024af644e6
|
|
@ -12,6 +12,7 @@ import android.content.pm.ActivityInfo;
|
|||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ProviderInfo;
|
||||
import android.os.IBinder;
|
||||
import android.os.Process;
|
||||
import android.os.RemoteException;
|
||||
|
|
@ -87,7 +88,6 @@ public class ParasiticManagerHooker {
|
|||
Object bindData = param.args[0];
|
||||
ApplicationInfo appInfo = (ApplicationInfo) XposedHelpers.getObjectField(bindData, "appInfo");
|
||||
XposedHelpers.setObjectField(bindData, "appInfo", getManagerPkgInfo(appInfo).applicationInfo);
|
||||
XposedHelpers.setObjectField(bindData, "providers", new ArrayList<>());
|
||||
}
|
||||
};
|
||||
XposedHelpers.findAndHookMethod(ActivityThread.class,
|
||||
|
|
@ -120,6 +120,35 @@ public class ParasiticManagerHooker {
|
|||
return null;
|
||||
}
|
||||
});
|
||||
XposedBridge.hookAllMethods(ActivityThread.class, "installProvider", new XC_MethodHook() {
|
||||
private Context originalContext = null;
|
||||
@Override
|
||||
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
|
||||
Hookers.logD("before install provider");
|
||||
Context ctx = null;
|
||||
ProviderInfo info = null;
|
||||
int ctxIdx = -1;
|
||||
for (var i = 0; i < param.args.length; ++i) {
|
||||
var arg = param.args[i];
|
||||
if (arg instanceof Context) {
|
||||
ctx = (Context) arg;
|
||||
ctxIdx = i;
|
||||
} else if (arg instanceof ProviderInfo) info = (ProviderInfo) arg;
|
||||
}
|
||||
if (ctx != null && info != null) {
|
||||
if (originalContext == null) {
|
||||
info.applicationInfo.packageName = BuildConfig.MANAGER_INJECTED_PKG_NAME + ".origin";
|
||||
var originalPkgInfo = ActivityThread.currentActivityThread().getPackageInfoNoCheck(info.applicationInfo, HiddenApiBridge.Resources_getCompatibilityInfo(ctx.getResources()));
|
||||
XposedHelpers.setObjectField(originalPkgInfo, "mPackageName", BuildConfig.MANAGER_INJECTED_PKG_NAME);
|
||||
originalContext = (Context) XposedHelpers.callStaticMethod(XposedHelpers.findClass("android.app.ContextImpl", null), "createAppContext", ActivityThread.currentActivityThread(), originalPkgInfo);
|
||||
info.applicationInfo.packageName = BuildConfig.MANAGER_INJECTED_PKG_NAME;
|
||||
}
|
||||
param.args[ctxIdx] = originalContext;
|
||||
} else {
|
||||
Hookers.logE("Failed to reload provider", new RuntimeException());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
XposedHelpers.findAndHookMethod(ActivityThread.class, "deliverNewIntents", ActivityThread.ActivityClientRecord.class, List.class, new XC_MethodHook() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import android.content.IntentFilter;
|
|||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageInstaller;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.CompatibilityInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.ResourcesImpl;
|
||||
import android.os.Binder;
|
||||
|
|
@ -86,4 +87,8 @@ public class HiddenApiBridge {
|
|||
public static void ApplicationInfo_credentialProtectedDataDir(ApplicationInfo applicationInfo, String dir) {
|
||||
applicationInfo.credentialProtectedDataDir = dir;
|
||||
}
|
||||
|
||||
public static CompatibilityInfo Resources_getCompatibilityInfo(Resources res) {
|
||||
return res.getCompatibilityInfo();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,7 @@ public class Resources {
|
|||
throw new UnsupportedOperationException("STUB");
|
||||
}
|
||||
|
||||
public CompatibilityInfo getCompatibilityInfo() {
|
||||
throw new UnsupportedOperationException("STUB");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue