I want to hook the constructor with xposed , and the code is as follows ,but there is some wrong.
Code:
XposedHelpers.findAndHookConstructor("java.io.File",
lpparam.classLoader, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param)
throws Throwable {
}
@Override
protected void afterHookedMethod(MethodHookParam param)
throws Throwable {
System.out.println("file interception" + "-------------->"
+ param.args[0]);
}
});
Error content:
java.lang.NoSuchMethodError: java.io.File()#exact
Thanks
That's because there is no File() constructor. To hook e.g. File(String filename), you need to use:
Code:
XposedHelpers.findAndHookConstructor("java.io.File",
lpparam.classLoader, [COLOR="Red"][B]String.class, [/B][/COLOR]new XC_MethodHook() {
or simply
Code:
XposedHelpers.findAndHookConstructor(File.class, [COLOR="Red"][B]String.class, [/B][/COLOR]new XC_MethodHook() {
Be careful with such generic classes though, you can easily get lots of calls to it.
rovo89 said:
That's because there is no File() constructor. To hook e.g. File(String filename), you need to use:
Code:
XposedHelpers.findAndHookConstructor("java.io.File",
lpparam.classLoader, [COLOR="Red"][B]String.class, [/B][/COLOR]new XC_MethodHook() {
or simply
Code:
XposedHelpers.findAndHookConstructor(File.class, [COLOR="Red"][B]String.class, [/B][/COLOR]new XC_MethodHook() {
Be careful with such generic classes though, you can easily get lots of calls to it.
Click to expand...
Click to collapse
It works, thanks you very much .
Related
I'm trying to hook GLES API with Xposed. But met some problems. Xposed can work well when i use it for some other things except the GLES API.
The module:
...
public class Tutorial implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
XposedBridge.log("Loaded app: " + lpparam.packageName);
if (lpparam.packageName.equals("android"))
{
XposedBridge.log("Mark !");
findAndHookMethod("android.opengl.GLES20", lpparam.classLoader, "glFinish", new XC_MethodHook() {
@override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("glFinish GLES20");
}
@override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("glFinish GLES20");
}
});
}
...
And i wrote an app with some glFinish() calls in it. When i run the app, i can't get "glFinish GLES20" at the log file.
I can get "Mark !", and no error in the log file.
Can any one help me? Thanks!
I'am trying to create an Xposed module which hooks into the tranceive methods of nfc to find out what is transfered. But sadly the hook doesn't seam to work. I've created a sample app which sends data over the tranceive method but the logs are not written. Here is my code:
Code:
if (!lpparam.packageName.equals("android"))
return;
findAndHookMethod("android.nfc.tech.BasicTagTechnology", lpparam.classLoader, "transceive", "byte[]", "boolean", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("before");
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("after");
}
});
I've also tried to hook into the service, but no logs either:
Code:
if (!lpparam.packageName.equals("com.android.nfc"))
return;
findAndHookMethod("com.android.nfc.NfcService", lpparam.classLoader, "doTransceiveNoLock", "int", "byte[]", new XC_MethodHook() {
.....
Am I doing something wrong or is it simply not possible to hook into these methods?
I found a solution for my problem. I have to hook the transceive method of com.android.nfc.NfcService$TagService to get access to every tag transmission.
I'm not able to change the return values of a method. The hook is working. Even the logs are correct - but when i actually call the method in another app the real information is shown.
Code:
findAndHookMethod("android.net.wifi.WifiInfo", lpparam.classLoader, "getSSID",new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("getSSID1 "+(String) param.getResult());
param.setResult("\"Changed\"");
XposedBridge.log("getSSID2 "+(String) param.getResult());
}
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});
Output:
Code:
getSSID1 "realSSID"
getSSID2 "Changed"
In app the call actually produces: "realSSID"
Can you help me with that?
what about when you setResult in beforeHookedMethod instead (thus the getSSID won't be called)?
have you ensured that the app calls getSSID to receive this information, and not from cache or something?
I tried beforeHookedMethod and MethodReplacement - same result. And getSSID is called because i can see the XposedBridge logs.
is it an app you wrote? i see from this answer that it can also be retrieved from getBSSID, and it could be the app was checking the string returned by getSSID or was using it for something else
Yes i use an own app for checking if it works. So i'm 100% sure i'm calling getSSID() - the method i've hooked.
the following works for me:
in module:
Code:
if (lpparam.packageName.equals("gitfib.hooks.sdaccounts")) {
XposedHelpers.findAndHookMethod("android.net.wifi.WifiInfo", lpparam.classLoader,
"getSSID",
new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
super.afterHookedMethod(param);
param.setResult("ssid");
}
});
}
in activity (same package in onCreate):
Code:
WifiInfo info = ((WifiManager) getSystemService(WIFI_SERVICE)).getConnectionInfo();
Log.i("wifiinfo", info.getSSID());
before rebooting it showed actual ssid
The code:
Code:
updateNotifications([Lcom/samsung/android/uniform/widget/notification/NotificationItem;)V
As you can see, I need an array of "NotificationItem"
But when I do this:
Code:
XposedHelpers.findAndHookMethod(NotiContainer, "updateNotifications", NotiItem[].class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});
I get "unknown class NotiItem"
so yeah.. kinda confused.
I tried this too:
Code:
XposedHelpers.findAndHookMethod(NotiContainer, "updateNotifications", "[com.samsung.android.uniform.widget.notification.NotificationItem", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
}
});
But I get "ClassNotFound Exception: Invalid Name"
How the heck can I do this...
Solved using "com.samsung.android.uniform.widget.notification.NotificationItem[]" instead of "[com.samsung.android.uniform.widget.notification.NotificationItem" as the class name.
I am on pie so obviously its EdXposed running.
I want to hook a method which is like
Code:
public void setSensorBrightness(int var1) {
Log.d(TAG, "setSensorBrightness: " + var1);
AODCommonSettingsUtils.setBrightnessSettingValue(var1);
this.mSensorBrightness = var1;
}
this original method is located in class "com.samsung.android.app.aodservice.manager.BrightnessManager" and a package name is "com.samsung.android.app.aodservice"
I use reflection as suggested in tutorial otherwise it throws no class found exception.
My code is
Code:
@Override
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable
{
if (!lpparam.packageName.equals("com.samsung.android.app.aodservice"))
return;
XposedHelpers.findAndHookMethod(
"com.samsung.android.app.aodservice.manager.BrightnessManager",
lpparam.classLoader,
"setSensorBrightness",
"int",
new MethodHook());
}
protected static class MethodHook extends XC_MethodHook
{
@Override
protected void beforeHookedMethod(MethodHookParam param)
throws Throwable
{
int x =3;
param.args[0]=x;
Log.d("Brightness_hack :", "works");
}
@Override
public boolean equals(Object o)
{
if (o instanceof MethodHook)
{
return true;
}
return super.equals(o);
}
@Override
public int hashCode()
{
return ~MethodHook.class.hashCode() ^ 0xdeadbeef;
}
}
Now my problem is its tooooooo slow hooks in like 15-20 mins and returns no result.
Am I missing something???