rovo89 / XposedBridge

The Java part of the Xposed framework.
3.86k stars 1.1k forks source link

Not finding methods and classes that exist #255

Closed elesbb closed 6 years ago

elesbb commented 6 years ago

So I am trying to hook things. I can find the classes and methods inside the smali file that exists inside the ssrm.jar file. But xposed can't find them and I am doing everything correctly. Attached is the smali file and i have the logcat error included, along with code.

LOGCAT:

Line 6743: 06-24 12:57:19.443  2377  2377 E Xposed  : java.lang.NoSuchMethodError: com.android.server.ssrm.bx#run()#exact
    Line 6744: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:344)
    Line 6744: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:344)
    Line 6744: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:344)
    Line 6744: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedHelpers.findMethodExact(XposedHelpers.java:344)
    Line 6745: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:185)
    Line 6745: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:185)
    Line 6745: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:185)
    Line 6745: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedHelpers.findAndHookMethod(XposedHelpers.java:185)
    Line 6746: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.elesbb.s6xposed.xposed_classes.DVFSDisabler.HookMethods(DVFSDisabler.java:102)
    Line 6746: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.elesbb.s6xposed.xposed_classes.DVFSDisabler.HookMethods(DVFSDisabler.java:102)
    Line 6746: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.elesbb.s6xposed.xposed_classes.DVFSDisabler.HookMethods(DVFSDisabler.java:102)
    Line 6747: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.elesbb.s6xposed.XposedClass.handleLoadPackage(XposedClass.java:138)
    Line 6747: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.elesbb.s6xposed.XposedClass.handleLoadPackage(XposedClass.java:138)
    Line 6747: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.elesbb.s6xposed.XposedClass.handleLoadPackage(XposedClass.java:138)
    Line 6747: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.elesbb.s6xposed.XposedClass.handleLoadPackage(XposedClass.java:138)
    Line 6748: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:34)
    Line 6748: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:34)
    Line 6748: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:34)
    Line 6748: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.IXposedHookLoadPackage$Wrapper.handleLoadPackage(IXposedHookLoadPackage.java:34)
    Line 6749: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.callbacks.XC_LoadPackage.call(XC_LoadPackage.java:61)
    Line 6749: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.callbacks.XC_LoadPackage.call(XC_LoadPackage.java:61)
    Line 6750: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:106)
    Line 6750: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.callbacks.XCallback.callAll(XCallback.java:106)
    Line 6751: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedInit$4$1.beforeHookedMethod(XposedInit.java:176)
    Line 6751: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedInit$4$1.beforeHookedMethod(XposedInit.java:176)
    Line 6751: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedInit$4$1.beforeHookedMethod(XposedInit.java:176)
    Line 6751: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedInit$4$1.beforeHookedMethod(XposedInit.java:176)
    Line 6752: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:340)
    Line 6752: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:340)
    Line 6752: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:340)
    Line 6752: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedBridge.handleHookedMethod(XposedBridge.java:340)
    Line 6753: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.android.server.SystemServer.startBootstrapServices(<Xposed>)
    Line 6753: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.android.server.SystemServer.startBootstrapServices(<Xposed>)
    Line 6754: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.android.server.SystemServer.run(SystemServer.java:575)
    Line 6755: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.android.server.SystemServer.main(SystemServer.java:458)
    Line 6756: 06-24 12:57:19.443  2377  2377 E Xposed  :   at java.lang.reflect.Method.invoke(Native Method)
    Line 6757: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
    Line 6758: 06-24 12:57:19.443  2377  2377 E Xposed  :   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
    Line 6759: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
    Line 6759: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
    Line 6759: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)
    Line 6759: 06-24 12:57:19.443  2377  2377 E Xposed  :   at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)

JAVA CODE SNIPPET:

Class<?> BX = XposedHelpers.findClass("com.android.server.ssrm.bx", loadPackageParam.classLoader);
        XposedHelpers.findAndHookMethod(BX, "run", voidNuker);

bx.txt

If you look at the attached text file (smali) you'll see that the method is there.

Also, doing getMethods on the class shows that it doesn't exist so I don't think its necessarily xposed but what the heck is it then? The class is in a ssrm.jar framework file.

C3C0 commented 6 years ago

Are you sure com/android/server/ssrm/bx is exactly the class you are trying to work with? I would try to enumerate all declared methods of given class using getDeclaredMethods() and compare with your smali.

Maybe your class loader is wrong which means you are not hooking within a proper package/process.

elesbb commented 6 years ago

Yeah. Its the right class I need. I also agree that the class loader might be wrong. However, the class is part of a framework.jar, so I use loadPackageParam.packageName.equals("android") to filter the class loader. I'm going to surround it with a try/catch block to see if not filtering class loader will find the proper class. I find it hard to believe that another class has the same exact name from another package. Unless another package loads this class and only has access to specific methods? But getMethods should return ALL methods, including private/protected ones.

getDeclaredMethods() only returns AE which is not even in the class attached. It has to be loading a different class than the one I am looking at in smali code. I did a pull of the system so I know I don't have my jar files messed up. Its also Samsung, so god knows what could be going on.

wanam commented 6 years ago

If i remember well the days i was playing with Samsung dvfs freqs, ssrm classes were loading in a different package.

elesbb commented 6 years ago

So I tried this:

Class<?> BX = loadPackageParam.classLoader.loadClass("com.android.server.ssrm.bx");
Method m = BX.getMethod("run");

This was all in a try catch block and the only time it could find the class was when the loadPackageParam.packageName equaled android. Every other time an exception was thrown. And this was without filtering packageName. It never found the "run" method. So its like it doesn't exist.

So I have no idea which other package the class would be loaded in. Even still, it should have found it with the test I mentioned. I was getting multiple other errors with other classes too that had no real parent directory. They were like this in the decompiled directory "smali/g/i.smali" and it couldn't find those classes either.

I may just have to do the smali edits and remove the .odex file. I had a similar problem where the class was hooked but I couldn't locate the class smali file when coding my AOD Customizer module. Samsung can be really annoying but I need LifeProof cases lol.

@wanam, do you remember which package they were loading into?

I also wanna mention that the other methods and classes I can hook without any problem. There are just a few that I cannot.

elesbb commented 6 years ago

I'm an idiot. Somehow I managed to look at an ssrm.odex that ISN'T on my device... Doing a pull of /system/framework I can now see that those methods and classes are not even part of the odex.. I am so sorry...