Java Code Examples for de.robv.android.xposed.XposedHelpers#findAndHookConstructor()

The following examples show how to use de.robv.android.xposed.XposedHelpers#findAndHookConstructor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XposedMod.java    From VirtualSensor with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void addSensors(final LoadPackageParam lpparam) {
    if (Build.VERSION.SDK_INT >= 24)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API24(lpparam));
    else if (Build.VERSION.SDK_INT == 23)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API23(lpparam));
    else if (Build.VERSION.SDK_INT >= 18)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.content.Context.class, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API18(lpparam));
    else if (Build.VERSION.SDK_INT >= 16)
        XposedHelpers.findAndHookConstructor("android.hardware.SystemSensorManager",
                lpparam.classLoader, android.os.Looper.class,
                new fr.frazew.virtualgyroscope.hooks.constructor.API16(lpparam));
    else XposedBridge.log("VirtualSensor: Using SDK version " + Build.VERSION.SDK_INT + ", this is not supported");
}
 
Example 2
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static XC_MethodHook.Unhook findAndHookConstructor(Class<?> clazz, Object... parameterTypesAndCallback) {
    try {
        return XposedHelpers.findAndHookConstructor(clazz, parameterTypesAndCallback);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example 3
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static XC_MethodHook.Unhook findAndHookConstructor(String className, ClassLoader classLoader, Object... parameterTypesAndCallback) {
    try {
        return XposedHelpers.findAndHookConstructor(className, classLoader, parameterTypesAndCallback);
    } catch (Throwable t) {
        log(t);
    }
    return null;
}
 
Example 4
Source File: SmsHandlerHook.java    From XposedSmsCode with GNU General Public License v3.0 5 votes vote down vote up
private void hookConstructor24(ClassLoader classloader) {
    XLog.i("Hooking InboundSmsHandler constructor for android v24+");
    XposedHelpers.findAndHookConstructor(SMS_HANDLER_CLASS, classloader,
            /* name                 */ String.class,
            /* context              */ Context.class,
            /* storageMonitor       */ TELEPHONY_PACKAGE + ".SmsStorageMonitor",
            /* phone                */ TELEPHONY_PACKAGE + ".Phone",
            /* cellBroadcastHandler */ TELEPHONY_PACKAGE + ".CellBroadcastHandler",
            new ConstructorHook());
}
 
Example 5
Source File: SmsHandlerHook.java    From XposedSmsCode with GNU General Public License v3.0 5 votes vote down vote up
private void hookConstructor19(ClassLoader classloader) {
    XLog.i("Hooking InboundSmsHandler constructor for Android v19+");
    XposedHelpers.findAndHookConstructor(SMS_HANDLER_CLASS, classloader,
            /*                 name */ String.class,
            /*              context */ Context.class,
            /*       storageMonitor */ TELEPHONY_PACKAGE + ".SmsStorageMonitor",
            /*                phone */ TELEPHONY_PACKAGE + ".PhoneBase",
            /* cellBroadcastHandler */ TELEPHONY_PACKAGE + ".CellBroadcastHandler",
            new ConstructorHook());
}
 
Example 6
Source File: ChromeHook.java    From OneTapVideoDownload with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
    String mediaPlayerBridgeClassName = "org.chromium.chrome.browser.media.remote.RemoteMediaPlayerBridge";
    if (!usesChromeBrowserComponent(lpparam.classLoader, mediaPlayerBridgeClassName)) {
        return;
    }

    final String packageName = lpparam.packageName;
    XC_MethodHook methodHook = new XC_MethodHook() {
        protected void beforeHookedMethod(XC_MethodHook.MethodHookParam hookParams) throws Throwable {
            try {
                Uri uri = Uri.parse((String) hookParams.args[1]);
                ApplicationLogMaintainer.sendBroadcast(Global.getContext(), "Chrome Hook : URL" + uri.toString());
                if (uri.toString().startsWith("http")) {
                    IpcService.startSaveUrlAction(Global.getContext(), uri, packageName);
                }
            } catch (Exception e) {
                ApplicationLogMaintainer.sendBroadcast(Global.getContext(), Global.getStackTrace(e));
            }
        }
    };

    // RemoteMediaPlayerBridge(long nativeRemoteMediaPlayerBridge, String sourceUrl, String frameUrl, String userAgent)
    Class remoteMediaPlayerBridge = XposedHelpers.findClass(mediaPlayerBridgeClassName, lpparam.classLoader);
    Object[] objects = new Object[] { long.class, String.class, String.class, String.class, methodHook };
    XposedHelpers.findAndHookConstructor(remoteMediaPlayerBridge, objects);
}
 
Example 7
Source File: SmsHandlerHook.java    From NekoSMS with GNU General Public License v3.0 5 votes vote down vote up
private void hookConstructor19(XC_LoadPackage.LoadPackageParam lpparam) {
    Xlog.i("Hooking InboundSmsHandler constructor for Android v19+");
    XposedHelpers.findAndHookConstructor(SMS_HANDLER_CLASS, lpparam.classLoader,
        /*                 name */ String.class,
        /*              context */ Context.class,
        /*       storageMonitor */ TELEPHONY_PACKAGE + ".SmsStorageMonitor",
        /*                phone */ TELEPHONY_PACKAGE + ".PhoneBase",
        /* cellBroadcastHandler */ TELEPHONY_PACKAGE + ".CellBroadcastHandler",
        new ConstructorHook());
}
 
Example 8
Source File: SmsHandlerHook.java    From NekoSMS with GNU General Public License v3.0 5 votes vote down vote up
private void hookConstructor24(XC_LoadPackage.LoadPackageParam lpparam) {
    Xlog.i("Hooking InboundSmsHandler constructor for Android v24+");
    XposedHelpers.findAndHookConstructor(SMS_HANDLER_CLASS, lpparam.classLoader,
        /*                 name */ String.class,
        /*              context */ Context.class,
        /*       storageMonitor */ TELEPHONY_PACKAGE + ".SmsStorageMonitor",
        /*                phone */ TELEPHONY_PACKAGE + ".Phone",
        /* cellBroadcastHandler */ TELEPHONY_PACKAGE + ".CellBroadcastHandler",
        new ConstructorHook());
}
 
Example 9
Source File: Patch.java    From wifi-password-android with Apache License 2.0 5 votes vote down vote up
private static boolean tryHookConstructor(Class<?> clazz, String msg,
        Object... parameterTypesAndCallback) {
    try {
        XposedHelpers.findAndHookConstructor(clazz, parameterTypesAndCallback);
    } catch (Error e) {
        return false;
    }

    XposedBridge.log(msg + " success");
    return true;
}