What Features Do You Look for in a Gallery App?

With so many different options to choose from, finding the right Gallery app may be a … more

Google Photos ‘Unlimited’ Storage Reportedly Being Capped

When Google Photos was announced, many of us thought very highly … more

Sprint Moves to Lift Video Streaming Limit for All-In

Yesterday, Sprint announced a new unlimited scheme that offered customers an … more

Xiaomi Releases Kernel Source Code For Mi4i

If you’ve been following the XDA News Portal lately, you might have noticed an … more

How to use hidden class in hook?

917 posts
Thanks Meter: 955
 
By pyler, Senior Member on 19th June 2014, 07:18 PM
Post Reply Subscribe to Thread Email Thread
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.
Last edited by pyler; 19th June 2014 at 07:20 PM.
 
 
19th June 2014, 07:36 PM |#2  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter: 35,682
 
Donate to Me
More
Quote:
Originally Posted by pyler

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)
19th June 2014, 07:58 PM |#3  
OP Senior Member
Thanks Meter: 955
 
More
Quote:
Originally Posted by rovo89

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!
20th June 2014, 08:28 AM |#4  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by rovo89

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.
20th June 2014, 05:24 PM |#5  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter: 35,682
 
Donate to Me
More
Quote:
Originally Posted by aoei

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.
21st June 2014, 02:21 AM |#6  
Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by rovo89

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!
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes