Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,809,247 Members 45,561 Now Online
XDA Developers Android and Mobile Development Forum

How to use hidden class in hook?

Tip us?
 
pyler
Old
(Last edited by pyler; 19th June 2014 at 07:20 PM.)
#1  
Senior Member - OP
Thanks Meter 441
Posts: 358
Join Date: Jan 2013
Default How to use hidden class in hook?

I have something like this..
Code:
XposedHelpers.findAndHookMethod(packageManagerService,
				"installPackage", Uri.class, IPackageInstallObserver.class, int.class, String.class, new XC_MethodHook()
bla bla...
But IPackageInstallObserver.class is not resolved (hidden, not in SDK). So, devs, how can I use it? Any workaround? I just need it to make hook working. For info, I am going to hook flags, not observer.
 
rovo89
Old
#2  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter 14,095
Posts: 2,367
Join Date: Jan 2012
Quote:
Originally Posted by pyler View Post
I have something like this..
Code:
XposedHelpers.findAndHookMethod(packageManagerService,
				"installPackage", Uri.class, IPackageInstallObserver.class, int.class, String.class, new XC_MethodHook()
bla bla...
But IPackageInstallObserver.class is not resolved (hidden, not in SDK). So, devs, how can I use it? Any workaround? I just need it to make hook working. For info, I am going to hook flags, not observer.
Simply use the string "android.content.pm.IPackageInstallObserver" instead of IPackageInstallObserver.class. You can do the same for the first class name:
Code:
XposedHelpers.findAndHookMethod("com.android.server.pm.PackageManagerService", null,
				"installPackage", Uri.class, "android.content.pm.IPackageInstallObserver", int.class, String.class, new XC_MethodHook()
bla bla...
(classloader is null here because the class is part of the BootClassLoader, usually you would use lpparam.classLoader instead)
Tired of updating your mod for every new ROM release?
You want give users the possibility to combine different mods without creating tons of different files for all possible combinations?
Then have a look at my Xposed framework - modifications without APK changes!
 
pyler
Old
#3  
Senior Member - OP
Thanks Meter 441
Posts: 358
Join Date: Jan 2013
Quote:
Originally Posted by rovo89 View Post
Simply use the string "android.content.pm.IPackageInstallObserver" instead of IPackageInstallObserver.class. You can do the same for the first class name:
Code:
XposedHelpers.findAndHookMethod("com.android.server.pm.PackageManagerService", null,
				"installPackage", Uri.class, "android.content.pm.IPackageInstallObserver", int.class, String.class, new XC_MethodHook()
bla bla...
(classloader is null here because the class is part of the BootClassLoader, usually you would use lpparam.classLoader instead)
This is awesome. Thank you!
 
aoei
Old
#4  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: Jun 2014
Quote:
Originally Posted by rovo89 View Post
Simply use the string "android.content.pm.IPackageInstallObserver" instead of IPackageInstallObserver.class. You can do the same for the first class name:
Code:
XposedHelpers.findAndHookMethod("com.android.server.pm.PackageManagerService", null,
				"installPackage", Uri.class, "android.content.pm.IPackageInstallObserver", int.class, String.class, new XC_MethodHook()
bla bla...
(classloader is null here because the class is part of the BootClassLoader, usually you would use lpparam.classLoader instead)
hello @rovo89

I know that I can use the string ... instead of .....class to use "findAndHookMethod",
but if I want to get the parameter in "beforeHookedMethod", like this:
Code:
XposedHelpers.findAndHookMethod("com.example.main", null,
	"a", "com.example.Details", int.class, String.class, new XC_MethodHook() {
	@Override
	protected void beforeHookedMethod(MethodHookParam param)
			throws Throwable {
			int i = (Integer)param.args[1];
			String s = (String)param.args[2];
			.........					
			}
});
I can get the parameters like this: int i = (Integer)param.args[1]; String s = (String)param.args[2];
but what about the first one?
how to define "(Details)param.args[0]"?

thanks.
 
rovo89
Old
#5  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter 14,095
Posts: 2,367
Join Date: Jan 2012
Quote:
Originally Posted by aoei View Post
I can get the parameters like this: int i = (Integer)param.args[1]; String s = (String)param.args[2];
but what about the first one?
how to define "(Details)param.args[0]"?
That's not possible. You have to assign it to an Object variable and then keep using reflection to get/set its fields and call methods. The methods in XposedHelpers make this very easy.
Tired of updating your mod for every new ROM release?
You want give users the possibility to combine different mods without creating tons of different files for all possible combinations?
Then have a look at my Xposed framework - modifications without APK changes!
 
aoei
Old
#6  
Junior Member
Thanks Meter 0
Posts: 2
Join Date: Jun 2014
Quote:
Originally Posted by rovo89 View Post
That's not possible. You have to assign it to an Object variable and then keep using reflection to get/set its fields and call methods. The methods in XposedHelpers make this very easy.
Got it! Thank you very much!
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


MultiROM Makes Its Way to the LG G2

Over the last few weeks, we’ve seen quite a fewflagship (and former flagship) devicesget to … more

Jair Player with a Major Update–Here’s What’s New!

Back in May, we talked a bit aboutJair Player, a nice looking music … more

Paid Android App Developers Will Soon Have to Provide Physical Address

Google has now changed its policies regarding paid app developers. … more