[APP][XPOSED][7.0+] WeiJu2 - Scriptable Xposed Module
source link: https://forum.xda-developers.com/t/app-xposed-7-0-weiju2-scriptable-xposed-module.4482585/page-2#post-88295947
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[APP][XPOSED][7.0+] WeiJu2 - Scriptable Xposed Module
wanting2521
New member
File access causes me a lot of headache, and current implementation still have some flaw it.
Why would want load script from file?
ref: https://github.com/ikws4/WeiJu2/issues/7#issuecomment-1248109818
I have multiple devices and code on computer will be a lot faster than Android.
Currently I try to override function getAllCellInfo of TelephonyManager class.
But the return is a List<CellInfo>. I don't know how to write the return for a List. Could you help me, please? Both return=List and return=List<CellInfo> doesn't work
local TelephonyManager = import("android.telephony.TelephonyManager")
local List = import("java.util.List")
hook {
class = TelephonyManager,
returns = List,
method = "getAllCellInfo",
params = {
},
replace = function(this, params)
return nil
end,
}
Certainly, I will give a try.
I Love XPrivacyLua but it doesn't provide a full integration from Lua to Java.
I have two questions:
Can I set specific hooks to specific apps or all hooks are applied to all apps ?
Can I set variables on hooks and then set a different variable for each app ?
Try this one, If it doesn't work, could you paste the debug log?I have multiple devices and code on computer will be a lot faster than Android.
Currently I try to override function getAllCellInfo of TelephonyManager class.
But the return is a List<CellInfo>. I don't know how to write the return for a List. Could you help me, please? Both return=List and return=List<CellInfo> doesn't workThank you in advance.Code:local TelephonyManager = import("android.telephony.TelephonyManager") local List = import("java.util.List") hook { class = TelephonyManager, returns = List, method = "getAllCellInfo", params = { }, replace = function(this, params) return nil end, }
local TelephonyManager = import("android.telephony.TelephonyManager")
local ArrayList = import("java.util.ArrayList")
local List = import("java.util.List")
hook {
class = TelephonyManager,
returns = List,
method = "getAllCellInfo",
replace = function(this, params)
local ret = ArrayList()
return ret
end,
}
Reactions: wanting2521
Can I set specific hooks to specific apps or all hooks are applied to all apps ?
For now, the workflow is you write a script for a specific app. But I am prepare to implement a "global app" feature (the script you write can be injected for all other apps).
Can I set variables on hooks and then set a different variable for each app ?
Yes, this is what the WeiJu2's package feature made for, you can import any script.
check them out on https://github.com/ikws4/WeiJu2-Scripts
Reactions: VD171 and wanting2521
wanting2521
New member
Try this one, If it doesn't work, could you paste the debug log?Code:local TelephonyManager = import("android.telephony.TelephonyManager") local ArrayList = import("java.util.ArrayList") local List = import("java.util.List") hook { class = TelephonyManager, returns = List, method = "getAllCellInfo", replace = function(this, params) local ret = ArrayList() return ret end, }
Thank you. It works after I change List to ArrayList
One more thing, Can I view or copy 'My Scripts' directly from Android Studio/computer, instead of editing directly from Weiju app?
I mean the path to 'My Scripts' on the device, so we can copy/paste the script?
Thank you. It works after I change List to ArrayList
One more thing, Can I view or copy 'My Scripts' directly from Android Studio/computer, instead of editing directly from Weiju app?
I mean the path to 'My Scripts' on the device, so we can copy/paste the script?
Can or can't that depends you, for now the script are save inside a share preferences called `script_store`, and script are encoded in base64, you can take look at it.
Reactions: wanting2521
wanting2521
New member
Can or can't that depends you, for now the script are save inside a share preferences called `script_store`, and script are encoded in base64, you can take look at it.
Strangely, I check both path:
- data/data/io.ikws4.weiju
- /data/user_de/0/io.ikws4.weiju
But no shared_prefs folder there. where can it be, sir?
Attachments
Oops, I recall that, the XSharedPreferences was store in a random path, trickyStrangely, I check both path:
- data/data/io.ikws4.weiju
- /data/user_de/0/io.ikws4.weiju
But no shared_prefs folder there. where can it be, sir?
New XSharedPreferences
To read the preference from the hooked app, you can simply use XSharedPreferences(String packageName) or XSharedPreferences(String packageName, String prefFileName) to retrieve the preference. Notice that you cannot use the XSharedPreferences(File prefFile) because the preference file is stored in a random directory.
Reactions: VD171 and wanting2521
try global search the file name. In my case, it was located atStrangely, I check both path:
- data/data/io.ikws4.weiju
- /data/user_de/0/io.ikws4.weiju
But no shared_prefs folder there. where can it be, sir?
/data/misc/b7076e05-6693-44af-990c-d5a46af38289/prefs/io.ikws4.weiju/script_store.xml
Reactions: VD171 and wanting2521
For now, the workflow is you write a script for a specific app. But I am prepare to implement a "global app" feature (the script you write can be injected for all other apps).
Yes, this is what the WeiJu2's package feature made for, you can import any script.
check them out on https://github.com/ikws4/WeiJu2-Scripts
Nice !
Definitely, global scripts are totally useful.
About package feature, why not some place/activity for setting each variable for each app, like XPrivacyLua Pro feature? Instead of opening and editting each script.
Attachments
Nice !
Definitely, global scripts are totally useful.
About package feature, why not some place/activity for setting each variable for each app, like XPrivacyLua Pro feature? Instead of opening and editting each script.
Not a big fan of making these ui, I think using code to define the behaviors is much better way to manage configurations and it gives the user more flexibility.
anuraag.neo
Senior Member
anuraag.neo
Senior Member
Maybe, I can write a convertor for this.
will you do this?
Can i hook android framework methods using this?
Yes.
Schroeder09
Senior Member
will you do this?
After some investigating, I found that it has many custom parameters and other stuff going on, so creating a complete compatible converter would be very difficult. Therefore, I probably won’t work on it, sorry.
Reactions: anuraag.neo
anuraag.neo
Senior Member
After some investigating, I found that it has many custom parameters and other stuff going on, so creating a complete compatible converter would be very difficult. Therefore, I probably won’t work on it, sorry.
ok but there is a hook which i wonder how to do.
"className": "android.content.Intent",
"methodName": "CREATOR:createFromParcel",
"parameterTypes": [
"android.os.Parcel"
],
"returnType": "android.content.Intent",
Another one
"className": "android.content.ClipData",
"methodName": "CREATOR:createFromParcel",
"parameterTypes": [
"android.os.Parcel"
],
"returnType": "android.content.ClipData",
ok but there is a hook which i wonder how to do.It's hooking intent.Code:"className": "android.content.Intent", "methodName": "CREATOR:createFromParcel", "parameterTypes": [ "android.os.Parcel" ], "returnType": "android.content.Intent",
Another oneCode:"className": "android.content.ClipData", "methodName": "CREATOR:createFromParcel", "parameterTypes": [ "android.os.Parcel" ], "returnType": "android.content.ClipData",
local Intent = import("android.content.Intent")
local Parcel = import("android.os.Parcel")
local ClipData = import("android.content.ClipData")
hook {
class = Intent.CREATOR:getClass(),
returns = Intent,
method = "createFromParcel",
params = {
Parcel
},
replace = function(this, params)
print("replace Intent.CREATOR.createFromParcel")
return Intent(params[1])
end
}
hook {
class = ClipData.CREATOR:getClass(),
returns = ClipData,
method = "createFromParcel",
params = {
Parcel
},
replace = function(this, params)
print("replace ClipData.CREATOR.createFromParcel")
return Intent(params[1])
end
}
XPrivacyLua/XLua.java at 85a1e498d5a9dbb902ca3d83e987ae6eec377d7a · M66B/XPrivacyLua
XPrivacyLua/DEFINE.md at master · M66B/XPrivacyLua
Reactions: VD171 and anuraag.neo
anuraag.neo
Senior Member
Code:local Intent = import("android.content.Intent") local Parcel = import("android.os.Parcel") local ClipData = import("android.content.ClipData") hook { class = Intent.CREATOR:getClass(), returns = Intent, method = "createFromParcel", params = { Parcel }, replace = function(this, params) print("replace Intent.CREATOR.createFromParcel") return Intent(params[1]) end } hook { class = ClipData.CREATOR:getClass(), returns = ClipData, method = "createFromParcel", params = { Parcel }, replace = function(this, params) print("replace ClipData.CREATOR.createFromParcel") return Intent(params[1]) end }
Thanks for this but I'm still struggling to find Intent action. XprivicyLua has getResult() function which returns Intent.
I think below code will give me action?
Intent(params[1]):getAction()
Try this snippet, If any error please send to me.Thanks for this but I'm still struggling to find Intent action. XprivicyLua has getResult() function which returns Intent.
I think below code will give me action?Code:Intent(params[1]):getAction()
local Intent = import("android.content.Intent")
local Parcel = import("android.os.Parcel")
hook {
class = Intent.CREATOR:getClass(),
returns = Intent,
method = "createFromParcel",
params = {
Parcel
},
replace = function(this, params)
print("replace Intent.CREATOR.createFromParcel")
local ret = Intent(params[1])
print("action " .. ret:getAction())
return ret
end
}
local Intent = import("android.content.Intent")
local Parcel = import("android.os.Parcel")
hook {
class = Intent.CREATOR:getClass(),
returns = Intent,
method = "createFromParcel",
params = {
Parcel
},
-- Not Implemented: Should have access for original return value
-- v
after = function(this, params, ret)
print("action " .. ret:getAction())
return ret
end
}
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK