Micromax Yureka: Indian Handset with CyanogenMod

Thesoap opera involving Cyanogen Inc., OnePlus, and Micromax is one of the most talked about … more

Chainfire Turns Your Bootanimation into a Logging Center

Having a nice boot animation certainly adds a little bit of aesthetic polish to your … more

Android TV Launcher Pushed to Google Play

Over the past decade, the tech universe has seen two drastic and widely contrasting changes with … more

Cyngn, OnePlus, Micromax – The Legal Battle

Recently, a battle has been waging in India over the rights to distribute the commercial … more

Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

How to use hidden class in hook?

OP pyler

19th June 2014, 08:18 PM   |  #1  
OP Senior Member
Thanks Meter: 606
 
509 posts
Join Date:Joined: Jan 2013
More
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 08:20 PM.
19th June 2014, 08:36 PM   |  #2  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter: 15,315
 
2,386 posts
Join Date:Joined: Jan 2012
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, 08:58 PM   |  #3  
OP Senior Member
Thanks Meter: 606
 
509 posts
Join Date:Joined: Jan 2013
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, 09:28 AM   |  #4  
Junior Member
Thanks Meter: 0
 
4 posts
Join Date:Joined: Jun 2014
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, 06:24 PM   |  #5  
rovo89's Avatar
Senior Recognized Developer
Thanks Meter: 15,315
 
2,386 posts
Join Date:Joined: Jan 2012
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, 03:21 AM   |  #6  
Junior Member
Thanks Meter: 0
 
4 posts
Join Date:Joined: Jun 2014
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