Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,742,742 Members 37,640 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 327
Posts: 235
Join Date: Jan 2013
Default How to use hidden class in hook?

I have something like this..
Code:
Select 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 13718
Posts: 2,367
Join Date: Jan 2012
Quote:
Originally Posted by pyler View Post
I have something like this..
Code:
Select 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:
Select 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 327
Posts: 235
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:
Select 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:
Select 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:
Select 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 13718
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


XDA PORTAL POSTS

Slide Dial Replacement Dialer Lets You Make Calls from Anywhere

If you frequently make phone calls, your dialer (aka phone app)is one of the … more

Navigate with Your Samsung Gear 2 Using DMA Navi Watch

Whether you’re travelling to a new destination or exploring some previously … more

Xperia Z1 Stereo Speaker Mod, Cell Phone Unlocking Legal Again! – XDA Developer TV

Cell Phone Unlocking is legal again!! That and much … more