Instantiating a package-private class - Xposed Framework Development

Fixed! I tried to change things again and again and I got it to work.
---
Hello !
I am trying to make a module for which I need to instantiate the android.hardware.Sensor class. It can be instantiated (android.hardware.SystemSensorManager does it) but it's visibility is only package-wise. Therefore, whenever I try to to something like this :
Code:
XposedHelpers.findConstructorExact("android.hardware.Sensor", lpparam.classLoader).setAccessible(true);
Sensor s = (Sensor) XposedHelpers.findClass("android.hardware.Sensor", lpparam.classLoader).newInstance();
I get a java.lang.IllegalAccessException telling me the constructor is not accessible from my Xposed class. I guess the solution is easy but I've been trying things for a while now and I cannot figure out a way to make it work.
Thank you in advance for your kind help.

Related

How to relocate & replace modules?

Hello,
Today if I'm wish to replace a file (stored as a module) in WM5/WM6, I end up deleting the module and replacing it by a file (stored as a file).
How do you create a module from a file?
How do you relocate a module (for instance if you import a module from another ROM and you don't want to turn it into a file)?
Regards,
--eluth.
So what? Does nobody know how to do that?
Is there no one capable of pointing me in the right direction?
--eluth.
eluth said:
Today if I'm wish to replace a file (stored as a module) in WM5/WM6, I end up deleting the module and replacing it by a file (stored as a file).
How do you create a module from a file?
How do you relocate a module (for instance if you import a module from another ROM and you don't want to turn it into a file)?
Click to expand...
Click to collapse
The "simple" answer is that you can not relocate a module - i.e. into a different memory map location. It was compiled for a specific space in memory, and there it must stay. There are no tools available for this. While something could potentially be written to do this task, the complexity involved would be quite high, and probably not worth the risk/reward/time.
Deleting the module - thereby freeing up the space, and having that space 'reclaimed' by a relocatable file is the only way you can modify/merge the ROMs. Use mamaich's tool to convert the module to a file. There is "no" other way.
Now, having said that, I have (previously) relocated a number of modules in the ROMs I made (TuMa series), however these relocations were MANUALLY done with a HEX EDITOR, and only on very small modules. i.e. I analysed the module, and changed everything necessary (byte-by-byte) to relocate the module. This is a very time-consuming manual process, and not recommended unless ... well ... ok, it's just not recommended period. Let's just say I won't be doing that again unless I really need to.
Tuatara. Many, many thanks for that answer.
This question was here several times, but always without any answer.
Thanks
You're very welcome ...
I forgot to mention that what I meant by "unless I really need to", was during the time BEFORE mamaich made his recmod tool. That tool actually came about because there were so many problems trying to relocate modules and/or find file-based versions of the required DLL's in order to build up a complete ROM. In TuMa v1.1 onwards there were always a number of modules which "previously didn't exist" in any ROM that came before. The things we do!
Anyways ... some day ... when I have some time again (real life has just been very consuming!), I'll be looking into the last few issues with the BA and see what I can resolve. The ROMs which have been made now are fantastic ... kudos to you all!
Tua! Your back How's things going?
Midget_1990 said:
Tua! Your back How's things going?
Click to expand...
Click to collapse
Well ... I actually never left ... I've just been 'lurking'.
Things have been good and things have been busy and things have been very trying. Kind of the 'same old - same old' story of everyone else who has real life take over, and doesn't have any time left to do the things they would like to do. Otherwise though, everything (and everyone) has been great!
I have watched with great interest all of Bepe's ROM Kitchen work, and the ROMs released from Helmi, xplode, baniaczek, yourself and others. With only a few things now causing problems, I think a solid WM5 ROM for the BA is quite possible to achieve ... but some of the last bugs do "bug" me ... so they'll NEED to be fixed. I want to keep using my BA ... nothing else beats it ... yet. (Well, ok VGA screen rocks, but ...)
I'm probably going to look into WM6 for BA at some point myself - just to see if there is anything which can be done. I don't hold much hope, but I'm not sure until I try ... it could just end up being a 'Frankenstein monster' of a ROM instead.
Anywho ... I might be a bit less 'lurker' and a bit more 'around' in the next while. Gotta have some hobbies ... right?
Thanks Tuatara,
This helps and explain why I couldn't find more details.
Best regards,
--eluth.

Looking for evC++ source for screen-off

Hello.
I searched anywhere,but I didn't found it yet,so I hope,that someone is able to help me in this case.
All I need is to implement "Screen Off" feature to my program,that switches off display and keeps everything else alive. That means classic thingie...
Thanks for your code sharing.
Btw,I am using Embedded Visual C++ 4.0
I think
Code:
DWORD SetSystemPowerState(
LPCWSTR psState,
DWORD StateFlags,
DWORD Options
);
from here should be what's needed. Check PM.h for which state flag it is (I can't remember of the top of my head, but it should be there).
Alternatively, you could try using unattended mode
PowerPolicyNotify(PPN_UNATTENDEDMODE, TRUE). (See here).
Hope that helps.
Thanks for your reply.
Unfortunately,no of them works.
SetSystemPowerState and PowerPolicyNotify are undeclared identifiers.
I also didn't found,which header file should I include.
evC++ 4.0 is relatively old tool for WM2003+,however it is free and useful also for WM6.5.
TomasNM said:
Thanks for your reply.
Unfortunately,no of them works.
SetSystemPowerState and PowerPolicyNotify are undeclared identifiers.
I also didn't found,which header file should I include.
evC++ 4.0 is relatively old tool for WM2003+,however it is free and useful also for WM6.5.
Click to expand...
Click to collapse
If you have an emulator set up for WM6.5 (not sure if you can do that with evC), you should be able to just inlcude PM.h, though I would have thought it's in WM2003.
Well,this works perfectly...
#include "PM.h"
SetSystemPowerState(NULL,POWER_STATE_IDLE,NULL);
Thanks for your help...
TomasNM said:
Well,this works perfectly...
#include "PM.h"
SetSystemPowerState(NULL,POWER_STATE_IDLE,NULL);
Thanks for your help...
Click to expand...
Click to collapse
Excellent... I should probably have said it was PM.h in my first reply... :S
Okay. Thanks again.
However I have to say,that I was used Google for it the same time amount as our dialog,but without success...

[Q] VPN SSL AnyConnect on Froyo FRX07

Hello
I try to install Cisco AnyConnect on my Touch Pro (FRX07)
but when it start, I have error: failed to connect to VPN service.
Can you say me if you can run it, and how?
I want diag my problem, but log are not very explicite
Thank's for your help
I join the apk I use.
and my debug log
seems it's buz the bundle still not supports VPN
likounin said:
seems it's buz the bundle still not supports VPN
Click to expand...
Click to collapse
We've never supported VPN's. If there's some way to make them work, we will gladly implement the code. As always, patches welcome.
arrrghhh said:
We've never supported VPN's. If there's some way to make them work, we will gladly implement the code. As always, patches welcome.
Click to expand...
Click to collapse
ok, thank's. I understand now.
I am new on Android, but I known Linux
What patch may we do? kernel, daemon, ...
ejantzen said:
ok, thank's. I understand now.
I am new on Android, but I known Linux
What patch may we do? kernel, daemon, ...
Click to expand...
Click to collapse
First, if I knew it would already be patched lol. Second, I don't have any VPN to test with - so you're going to have to tell us what needs patched. It seems like a userland issue, but I honestly don't know. Perhas some kernel module is missing? Again, I don't know for sure. I don't have any way to test it, and I think that's the problem most have - they have no way of testing VPN, and I think most probably use OpenVPN if it's in their home. At work, it's probably mostly PPTP.
So if you find something to patch, please submit it. If you can't... well then we just won't be able to support VPN's. Pretty minor feature, but I'm sure it would be nice for some.
arrrghhh said:
It seems like a userland issue, but I honestly don't know. Perhas some kernel module is missing? Again, I don't know for sure.
Click to expand...
Click to collapse
ok, thank's
but on the debig file, we can't see where is the problem?
ejantzen said:
ok, thank's
but on the debig file, we can't see where is the problem?
Click to expand...
Click to collapse
If by "we" you mean me, no. I'm no expert on the matter of deciphering logs and determining what exactly needs to be fixed. I can usually pinpoint problems, but pinpointing exactly which element needs fixing... I'm pretty new to.
In my horrible estimation, these three lines are where it starts going badly:
Code:
09-04 10:27:28.770 I/vpnagent( 1847): Function: scanAvailableModule File: PluginLoader.cpp Line: 745 Scanning plugin libvpncommoncrypt.so
09-04 10:27:28.770 W/vpnagent( 1847): Function: STGetProcAddress File: HModuleMgr.cpp Line: 263 Invoked Function: dlsym Return Code: 0 (0x00000000) Description: Symbol not found:
09-04 10:27:28.770 E/vpnagent( 1847): Function: scanAvailableModule File: PluginLoader.cpp Line: 783 Invoked Function: CHModuleMgr::STGetProcAddress Return Code: -33554427 (0xFE000005) Description: GLOBAL_ERROR_NULL_POINTER
The "Scanning plugin libvpncommoncrypt.so" portion really interests me. Does this lib exist? Have you been able to find perhaps another version of it? I know very little about VPN's... never had the desire to use one on a phone. I don't even use 'em on computers really... my office has a VPN that requires a PC, and is far from a 'traditional' VPN.
Looking further thru the log, it seems the app is just going thru libs. It would appear we're either missing these libs, or the libs we have aren't playing nicely. I keep seeing the same "Symbol not found" errors... I'm betting we simply don't have the right libs for this type of VPN app.
thank's
I will try in this direction.

[Q] Can we hook class loaders?

Hello fellow devs!
I've got an idea for a module that involves reinstrumentation of classes at runtime and also preventing classes from being loaded too.
The problem is, I don't know where to start hooking. I don't really understand the way class loading works in Android.
I tried searching deep into the source code of the OS, found PathClassLoader, which resides in 'dalvik.system' package. I imagine it's not hookable...
So my question is:
Is what I'm trying to do even possible? Maybe I'm looking in the wrong place?
Also take note, modifying packages outside of memory is out of question here.
Guess I was wrong. I successfully hooked PathClassLoader's findClass method with no problems.
Now, how can I make my class respond to non-existent methods' calls? One solution would be to just hook all methods in the existing class, but I'd prefer something like this (link)...
Yew, interesting idea. @rovo89?
Can we "create/redirect" methods/classes? Let's say app calls X method from Y class, but Y class is not available (e.g. GP Services), so can we redirect original Y class to our class and redirect original X method to our method from our class?
Xiaomi Poco F1 [ROM] [8.1.0] ResurrectionRemix v6.2.1
I installed xposed v90beta3, I can not start the module, it gives an error.
Help solve the problem
zygote64(3278): ClassLoaderContext size mismatch. expected=1, actual=2 (PCL[] | PCL[];PCL[/data/dalvik-cache/xposed_XResourcesSuperClass.dex*2802528989:/data/dalvik-cache/xposed_XTypedArraySuperClass.dex*708326108])

[Need Help] Hook and override system method

Hello! i'm only today start read documentation by Xposed modules. And i have question.
For example in class android.os.UserManager has method getMaxSupportedUsers that return int.
Can i with xposed module hook calling of this method and override return value ? For simple, I want that method always returns 6.
Or is it impossible with Xposed?
P.s. sorry for my bad english
Yes, its possible.
PBombNZ said:
Yes, its possible.
Click to expand...
Click to collapse
Can you show the link where I can read about it or some small sample?
Firstly I recommend going to https://github.com/rovo89/XposedBridge/wiki . its made by rovo89 himself. Enough to help you get started and understand how xposed works. You could also look up some other developer's xposed module source code on github. It will help you understand how the to hook methods and stuff by looking at other people's code.
This guy's code is pretty basic but could be useful to understand how it works. https://github.com/veeti/DisableFla...isableflagsecure/DisableFlagSecureModule.java. This guy hooks the setFlag and setSecure methods of the Window class and SurfaceView class respectively and overrides the outcome. this will probably be system wide though, but you can change it so it only is enabled for certain applications. Also look at his "AndroidManifest.xml" and "assets/xposed_init" files. The Android Manifest contains xposed information and the the xposed_init file contains the full class name of the class which contains all the hooks (which tells xposed where to find your hook methods).
Hope that helps.

Categories

Resources