ads

jeudi 17 septembre 2015

[Help] Hooking a jar library such as Cardboard



Hi there,

I am currently working on an Xposed module which tries to anti-jitter the gyroscope for the phones that have an unprecise gyroscope such as Moto G 2nd gen or Huawei Ascendn G7.

The app currently hooks directly to the SystemSensorManager to modify the gyroscope's values before they get sent to another app (from the code in my github repo: lrq3000/GyroscopeNoiseFilter):


Code:


public class GyroscopeNoiseFilter implements IXposedHookLoadPackage {
        public XSharedPreferences pref;

    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
            pref = new XSharedPreferences(GyroscopeNoiseFilter.class.getPackage().getName(), "pref_median"); // load the preferences using Xposed (necessary to be accessible from inside the hook, SharedPreferences() won't work)
            pref.makeWorldReadable();

        try {
            final Class<?> sensorEQ = findClass(
                    "android.hardware.SystemSensorManager$SensorEventQueue",
                    lpparam.classLoader);

            XposedBridge.hookAllMethods(sensorEQ, "dispatchSensorEvent", new
                    XC_MethodHook() {
...


However, this does not work with apps that use the latest Google Cardboard SDK, since it provides its own virtual sensors and it seems it directly access the hardware sensors, thus this totally bypass the dispatchSensorEvent.

Thus, I would like to hook into a class inside Google Cardboard SDK. I identified some candidates, but everytime I try to hook a class inside this library, I get an exception "java.lang.ClassNotFoundException".

Google Cardboard SDK is directly imported by the app devs inside their projects, and it's referenced as an external jar in the build path. I guess this is where the problem is: I am neither trying to hook a specific app or a global android SDK class, but a class in a library that is imported in multiples apps.

Is there a way to hook into such a library using Xposed?



Aucun commentaire:

Enregistrer un commentaire