Search in sources :

Example 1 with BinderInvocationStub

use of com.lody.virtual.client.hook.base.BinderInvocationStub in project VirtualXposed by android-hacker.

the class ActivityManagerStub method inject.

@Override
public void inject() throws Throwable {
    if (BuildCompat.isOreo()) {
        // Android Oreo(8.X)
        Object singleton = ActivityManagerOreo.IActivityManagerSingleton.get();
        Singleton.mInstance.set(singleton, getInvocationStub().getProxyInterface());
    } else {
        if (ActivityManagerNative.gDefault.type() == IActivityManager.TYPE) {
            ActivityManagerNative.gDefault.set(getInvocationStub().getProxyInterface());
        } else if (ActivityManagerNative.gDefault.type() == Singleton.TYPE) {
            Object gDefault = ActivityManagerNative.gDefault.get();
            Singleton.mInstance.set(gDefault, getInvocationStub().getProxyInterface());
        }
    }
    BinderInvocationStub hookAMBinder = new BinderInvocationStub(getInvocationStub().getBaseInterface());
    hookAMBinder.copyMethodProxies(getInvocationStub());
    ServiceManager.sCache.get().put(Context.ACTIVITY_SERVICE, hookAMBinder);
}
Also used : BinderInvocationStub(com.lody.virtual.client.hook.base.BinderInvocationStub)

Example 2 with BinderInvocationStub

use of com.lody.virtual.client.hook.base.BinderInvocationStub in project VirtualApp by asLody.

the class ContextFixer method fixContext.

/**
 * Fuck AppOps
 *
 * @param context Context
 */
public static void fixContext(Context context) {
    try {
        context.getPackageName();
    } catch (Throwable e) {
        return;
    }
    InvocationStubManager.getInstance().checkEnv(GraphicsStatsStub.class);
    int deep = 0;
    while (context instanceof ContextWrapper) {
        context = ((ContextWrapper) context).getBaseContext();
        deep++;
        if (deep >= 10) {
            return;
        }
    }
    ContextImpl.mPackageManager.set(context, null);
    try {
        context.getPackageManager();
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (!VirtualCore.get().isVAppProcess()) {
        return;
    }
    DropBoxManager dm = (DropBoxManager) context.getSystemService(Context.DROPBOX_SERVICE);
    BinderInvocationStub boxBinder = InvocationStubManager.getInstance().getInvocationStub(DropBoxManagerStub.class);
    if (boxBinder != null) {
        try {
            Reflect.on(dm).set("mService", boxBinder.getProxyInterface());
        } catch (ReflectException e) {
            e.printStackTrace();
        }
    }
    String hostPkg = VirtualCore.get().getHostPkg();
    ContextImpl.mBasePackageName.set(context, hostPkg);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ContextImplKitkat.mOpPackageName.set(context, hostPkg);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        ContentResolverJBMR2.mPackageName.set(context.getContentResolver(), hostPkg);
    }
}
Also used : DropBoxManager(android.os.DropBoxManager) BinderInvocationStub(com.lody.virtual.client.hook.base.BinderInvocationStub) ContextWrapper(android.content.ContextWrapper) ReflectException(com.lody.virtual.helper.utils.ReflectException)

Example 3 with BinderInvocationStub

use of com.lody.virtual.client.hook.base.BinderInvocationStub in project VirtualApp by asLody.

the class ActivityManagerStub method inject.

@Override
public void inject() throws Throwable {
    if (BuildCompat.isOreo()) {
        // Android Oreo(8.X)
        Object singleton = ActivityManagerOreo.IActivityManagerSingleton.get();
        Singleton.mInstance.set(singleton, getInvocationStub().getProxyInterface());
    } else {
        if (ActivityManagerNative.gDefault.type() == IActivityManager.TYPE) {
            ActivityManagerNative.gDefault.set(getInvocationStub().getProxyInterface());
        } else if (ActivityManagerNative.gDefault.type() == Singleton.TYPE) {
            Object gDefault = ActivityManagerNative.gDefault.get();
            Singleton.mInstance.set(gDefault, getInvocationStub().getProxyInterface());
        }
    }
    BinderInvocationStub hookAMBinder = new BinderInvocationStub(getInvocationStub().getBaseInterface());
    hookAMBinder.copyMethodProxies(getInvocationStub());
    ServiceManager.sCache.get().put(Context.ACTIVITY_SERVICE, hookAMBinder);
}
Also used : BinderInvocationStub(com.lody.virtual.client.hook.base.BinderInvocationStub)

Example 4 with BinderInvocationStub

use of com.lody.virtual.client.hook.base.BinderInvocationStub in project VirtualXposed by android-hacker.

the class PackageManagerStub method inject.

@Override
public void inject() throws Throwable {
    final IInterface hookedPM = getInvocationStub().getProxyInterface();
    ActivityThread.sPackageManager.set(hookedPM);
    BinderInvocationStub pmHookBinder = new BinderInvocationStub(getInvocationStub().getBaseInterface());
    pmHookBinder.copyMethodProxies(getInvocationStub());
    pmHookBinder.replaceService("package");
}
Also used : BinderInvocationStub(com.lody.virtual.client.hook.base.BinderInvocationStub) IInterface(android.os.IInterface)

Example 5 with BinderInvocationStub

use of com.lody.virtual.client.hook.base.BinderInvocationStub in project VirtualXposed by android-hacker.

the class ContextFixer method fixContext.

/**
 * Fuck AppOps
 *
 * @param context Context
 */
public static void fixContext(Context context) {
    try {
        context.getPackageName();
    } catch (Throwable e) {
        return;
    }
    InvocationStubManager.getInstance().checkEnv(GraphicsStatsStub.class);
    int deep = 0;
    while (context instanceof ContextWrapper) {
        context = ((ContextWrapper) context).getBaseContext();
        deep++;
        if (deep >= 10) {
            return;
        }
    }
    ContextImpl.mPackageManager.set(context, null);
    try {
        context.getPackageManager();
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (!VirtualCore.get().isVAppProcess()) {
        return;
    }
    DropBoxManager dm = (DropBoxManager) context.getSystemService(Context.DROPBOX_SERVICE);
    BinderInvocationStub boxBinder = InvocationStubManager.getInstance().getInvocationStub(DropBoxManagerStub.class);
    if (boxBinder != null) {
        try {
            Reflect.on(dm).set("mService", boxBinder.getProxyInterface());
        } catch (ReflectException e) {
            e.printStackTrace();
        }
    }
    String hostPkg = VirtualCore.get().getHostPkg();
    ContextImpl.mBasePackageName.set(context, hostPkg);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ContextImplKitkat.mOpPackageName.set(context, hostPkg);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        ContentResolverJBMR2.mPackageName.set(context.getContentResolver(), hostPkg);
    }
}
Also used : DropBoxManager(android.os.DropBoxManager) BinderInvocationStub(com.lody.virtual.client.hook.base.BinderInvocationStub) ContextWrapper(android.content.ContextWrapper) ReflectException(com.lody.virtual.helper.utils.ReflectException)

Aggregations

BinderInvocationStub (com.lody.virtual.client.hook.base.BinderInvocationStub)9 ContextWrapper (android.content.ContextWrapper)3 DropBoxManager (android.os.DropBoxManager)3 IInterface (android.os.IInterface)3 ReflectException (com.lody.virtual.helper.utils.ReflectException)3