Hi,
I want to use sqlite in my xposed module but i don't have any activity or context to send the database constructor.
Is it possible to overcome this?
I tried to send null as a context, but i'm getting nullPointerException when i try to open the database.
Thanks,
Gidi
If you can't get a context from the method you're hooking, you could try the AndroidAppHelper.currentApplication method.
Code:
Context ctx = AndroidAppHelper.currentApplication();
Context myCtx = ctx.createPackageContext("com.developer.app");
pyler said:
Code:
Context ctx = AndroidAppHelper.currentApplication();
Context myCtx = ctx.createPackageContext("com.developer.app");
Click to expand...
Click to collapse
HI Guys,
I tried the AndroidAppHelper.currentApplication() option, but it returns NULL in my case...
shnapsi said:
HI Guys,
I tried the AndroidAppHelper.currentApplication() option, but it returns NULL in my case...
Click to expand...
Click to collapse
If you are editing a database using sqlite and the current process you are hooking as no context reference, you can use root to set the database file to readable, then have your own service running in the background with a file observer tracking changes to a file on the device. Inside xposed module you will write to the file with a command instructing the file observer what to do. Then your service will "hear" the command and execute the changes needed.
I plan on writing up a guide for this. Tomorrow
elesbb said:
If you are editing a database using sqlite and the current process you are hooking as no context reference, you can use root to set the database file to readable, then have your own service running in the background with a file observer tracking changes to a file on the device. Inside xposed module you will write to the file with a command instructing the file observer what to do. Then your service will "hear" the command and execute the changes needed.
I plan on writing up a guide for this. Tomorrow
Click to expand...
Click to collapse
Thanks, I'll be happy to read your guide and learn new stuff
Anyway, I read that it's possible to use Sqlite DB without using SQLiteOpenHelper, this way, i don't need context.
the problem is that when i do it i get exception:
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
this is my code:
database = SQLiteDatabase.openOrCreateDatabase(DB_NAME,null);
database.execSQL(CREATE_TABLE);
Thanks.
shnapsi said:
Thanks, I'll be happy to read your guide and learn new stuff
Anyway, I read that it's possible to use Sqlite DB without using SQLiteOpenHelper, this way, i don't need context.
the problem is that when i do it i get exception:
android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
this is my code:
database = SQLiteDatabase.openOrCreateDatabase(DB_NAME,null);
database.execSQL(CREATE_TABLE);
Thanks.
Click to expand...
Click to collapse
You probably don't have the required permissions to read/write to that location.
GermainZ said:
You probably don't have the required permissions to read/write to that location.
Click to expand...
Click to collapse
Thanks GermainZ,
which permissions do i need?
I tried to do it this way too:
Code:
File db = new File("/data/data/com.example.mytest/databases/" + DB_NAME);
db.setReadable(true);
db.setWritable(true);
File path = new File("/data/data/com.example.mytest/databases/");
path.setReadable(true);
path.setWritable(true);
path.mkdirs();
database = SQLiteDatabase.openOrCreateDatabase(db,null);
Still same result...
Thanks!
shnapsi said:
Thanks GermainZ,
which permissions do i need?
I tried to do it this way too:
Code:
File db = new File("/data/data/com.example.mytest/databases/" + DB_NAME);
db.setReadable(true);
db.setWritable(true);
File path = new File("/data/data/com.example.mytest/databases/");
path.setReadable(true);
path.setWritable(true);
path.mkdirs();
database = SQLiteDatabase.openOrCreateDatabase(db,null);
Still same result...
Thanks!
Click to expand...
Click to collapse
Let's differentiate between two things: your module (normal code) and the hooked process (the Xposed code).
Remember that hooked code runs as the hooked process (that is, the app you're hooking — *not* your module), so you won't be able to write to your module's data directory.
I don't know if you can change that. Maybe you could create the database and use Context.MODE_WORLD_WRITABLE (from your module, when it firsts open), but I don't think you'll have any luck creating it from the hooked process directly.
GermainZ said:
Let's differentiate between two things: your module (normal code) and the hooked process (the Xposed code).
Remember that hooked code runs as the hooked process (that is, the app you're hooking — *not* your module), so you won't be able to write to your module's data directory.
I don't know if you can change that. Maybe you could create the database and use Context.MODE_WORLD_WRITABLE (from your module, when it firsts open), but I don't think you'll have any luck creating it from the hooked process directly.
Click to expand...
Click to collapse
So where is the best place to use AndroidAppHelper.currentApplication(); so it won't return null and i will be able to use it in my hooked method?
Hello gays, i read all post's . I've the same problem. I start develop a module for xposed for my thesis the goal of application is return fake data when some aplications want access features that they don't need. I all ready can save in sqlite database the restrictions that the user want to restrict, the package name of application and uid. Now i want to access to the database methods by the main class (with implements IXposedHookLoadPackage) and i allways getting nullPointerException when i try connect to database. Anyone can solve this problem?? I will attach my main class IdentitySpoofing and my DatabaseHelper Best Regards Joao Marques
Related
I want to add a new button background to framework-res.apk (not modify an existing one). I need to change the look of the clear notification button without modifying everything else that uses that background.
The clear button uses btn_default_small, so I made a copy of btn_default_small.xml, named it btn_default_small2.xml and in the status bar xml, pointed the clear button to btn_default_small2. (No editing at all. I'll make it look different later.)
This causes a boot loop.
I must be missing something. Any idea what?
I tried adding an entry for my new button to public.xml (do I need to do that?) using the next available ID. It still boot looped.
I get an interesting logcat message
W/ResourceType( 1683): getEntry failing because entryIndex 952 is beyond type entryCount 952
W/ResourceType( 1683): Failure getting entry for 0x010803b8 (t=7 e=952) in package 0: 0x80000001
Click to expand...
Click to collapse
There are 952 drawable entries in Public.xml, my new file is number 953. The next available ID is 0x010803b8. I don't know what package 0: 0x80000001 is. Is any of that even relevant?
I attached the logcat output. Please help.
To answer your question...adding is difficult.
- Baksmali Services.jar
- search there for your "btn_default_small".
- you will be surprised how many times you will see it there..(maybe 7 times ?)
now
- how often do you find "btn_default_small2" in Services.jar ??
If you can handle smali.files, cool!
I believe it´s easier to get the source and do it in Eclipse.
But maybe, anybody with more knowledge can explain this better here.
greets
Shizlak said:
I made a copy of btn_default_small.xml, named it btn_default_small2.xml and in the status bar xml, pointed the clear button to btn_default_small2. (No editing at all. I'll make it look different later.)
Click to expand...
Click to collapse
It does not know the new file btn_default_small2.xml exists (no id), Try recompiling using apktool. (you need to use the resource-only flag for framework-res)
Make sure you deploy the new jar while the OS is not running. (i.e. recovery)
britoso said:
It does not know the new file btn_default_small2.xml exists (no id), Try recompiling using apktool. (you need to use the resource-only flag for framework-res)
Make sure you deploy the new jar while the OS is not running. (i.e. recovery)
Click to expand...
Click to collapse
So you can add without touching services.jar?
Hi folks,
I'm trying to extract execution path information using Xposed. All I need is to record the invocation of methods in logCat. I found this Xposed-Method-Finder module (github.com/MohammadAG/Xposed-Method-Finder) on repository that can inspect all the methods in a package. However, it needs the name of classes in the package as an input (private static final String[] CLASSES_TO_HOOK). Is there any way to automatically generate the list of classes inside a package instead of provide it manually? Or, is there any other way to inspect and hook all the methods in a package without providing the exact names?
I appreciate your helps
So I'm writing my first Xposed module and I've hit another snag.
My module has a UI that can be opened from the launcher. My UI is simple and it just allows the user to increment/decrement the counter. The value of the counter is saved to the SharedPreferences file found at \data\data\com.appname\shared_prefs.
The Xposed portion of the module will read the value out of the shared_prefs file, decrement the counter, and save the decremented value back to the file...
How can this be done? I know that I shouldn't be reading/writing to the shared_prefs file from the Xposed activity... so if there is a better (read correct) way of doing what I need to do, can you point me in the right direction? The only part of the module I don't have working is this last part... My UI is already able to Read/Write to the shared_prefs file, so hopefully that helps... or at least shows that I'm not wasting anyone's time.
In xposed module send intent to your app to modify prefs.
Could you be a little more specific? I'm more of an embedded/C programmer... Android/Java is still a little new to me.
Define own intent sction in manifest - e.g. mymodule.intent.action.DESCREASE_COUNTER
Then in hook you have to get context (getObjectField("mContext") - in android, AndroidAppHelper.currentApplication - for other apps)
Then just run intent:
mContext.sendBroadcast(new Intent("mymodule.intent.action.DESCREASE_COUNTER"));
I use such way in my module - https://github.com/pylerSM/XInstaller/. Check it
I try to read a shared preferences file in the Xposed Bridge module and I cannot get anything. Can you please, provide some information on how to read the file. I would prefer to use shared preferences instead of a binder.
I questions are :
1.
Is it possible to add Service into an app's AndroidManifest.xml ?
For example , I write a Service and I need an app start that service as local service.
( I need to use IBinder to interact with this service. )
2.
Is it possible to add permissions into an app's AndroidManifest.xml ?
For exmaple, I'd like to create a floating window when some method is called.
But the app do not have "android.permission.SYSTEM_ALERT_WINDOW".
So it will throw a permission deny error.
Is it possible to add that permission into the target app ?
Thanks!
darkk6 said:
I questions are :
1.
Is it possible to add Service into an app's AndroidManifest.xml ?
For example , I write a Service and I need an app start that service as local service.
( I need to use IBinder to interact with this service. )
2.
Is it possible to add permissions into an app's AndroidManifest.xml ?
For exmaple, I'd like to create a floating window when some method is called.
But the app do not have "android.permission.SYSTEM_ALERT_WINDOW".
So it will throw a permission deny error.
Is it possible to add that permission into the target app ?
Thanks!
Click to expand...
Click to collapse
you can hook package installer and do the modifications there before it passes to the native binaries the contents of AndroidManifest.xml (Similar to what XInstaller module does)
In my module, I want to compare my string with string in a list of strings, which is stored as a .txt file in the SD card of Android 11. If my string is found in that list, the module should return the "true" value. But I cannot access this .txt file, I met "Permission Denied". So, Is there any possible way to read that type of file in the EdXposed Module?
nthp999 said:
In my module, I want to compare my string with string in a list of strings, which is stored as a .txt file in the SD card of Android 11. If my string is found in that list, the module should return the "true" value. But I cannot access this .txt file, I met "Permission Denied". So, Is there any possible way to read that type of file in the EdXposed Module?
Click to expand...
Click to collapse
you can use objectinputsteam for read that file and after read that file you can check anything which you want and make sure make takget sdk 27 for bypass any aditional read or write security.
AndroidX said:
you can use objectinputsteam for read that file and after read that file you can check anything which you want and make sure make takget sdk 27 for bypass any aditional read or write security.
Click to expand...
Click to collapse
I tried in sdk27 and it doesn't work, so I used a broadcast receiver and send myString to MainActivity.java, this class will read the file which I stored in the SD card.