Cannot hook Switch.class - Xposed Framework Development

Im trying to hook setSwitchMinWidth method from Switch,class
Code:
XposedHelpers.[I]findAndHookMethod[/I](Switch.[COLOR=#000080][B]class[/B][/COLOR], [COLOR=#008000][B]"setSwitchMinWidth"[/B][/COLOR],[COLOR=#008000][B]int.class[/B][/COLOR], [COLOR=#000080][B]new [/B][/COLOR]XC_MethodHook() {
[COLOR=#808000]@Override
[/COLOR][COLOR=#000080][B]protected void [/B][/COLOR]afterHookedMethod(MethodHookParam param) [COLOR=#000080][B]throws [/B][/COLOR]Throwable {
XposedBridge.[I]log[/I]([COLOR=#008000][B]"Hooked"[/B][/COLOR]);
}
});
but in xposed log "hooked" log is not display in xposed log so method can be hooked.. there is no errors. Someone can help me with this? Thanks

Hello, are you sure you can hook a class like Switch.class? I haven't seen it used anywhere yet, but I have just started. Perhaps you should use the class loader technique?

Rijul.A said:
Hello, are you sure you can hook a class like Switch.class? I haven't seen it used anywhere yet, but I have just started. Perhaps you should use the class loader technique?
Click to expand...
Click to collapse
I dont know if I can hook this class (I hooked whith sukces ProgresBar.class so I've hope that I can). I tryied whith class loader and still the same.

Could you give a try with this code
import java.lang.reflect.Method;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
public class XposedWrapper {
public static XC_MethodHook.Unhook hookMethod(Class<?> sClass,String method_Name,Object... parameterTypesAndCallback) {
Method method = XposedHelpers.findMethodBestMatch(sClass,method_Name,removeCallback(parameterTypesAndCallback));
XC_MethodHook callback = (XC_MethodHook) parameterTypesAndCallback[parameterTypesAndCallback.length-1];
return XposedBridge.hookMethod(method,callback);
}
private static Object[] removeCallback(Object... args) {
Object[] list = new Object[args.length-1];
for (int i = 0 ; i < args.length ; i++) {
if (!(args instanceof XC_MethodHook)) {
list = args;
}
}
return list;
}
}

AndroidFire said:
Could you give a try with this code
import java.lang.reflect.Method;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
public class XposedWrapper {
public static XC_MethodHook.Unhook hookMethod(Class<?> sClass,String method_Name,Object... parameterTypesAndCallback) {
Method method = XposedHelpers.findMethodBestMatch(sClass,method_Name,removeCallback(parameterTypesAndCallback));
XC_MethodHook callback = (XC_MethodHook) parameterTypesAndCallback[parameterTypesAndCallback.length-1];
return XposedBridge.hookMethod(method,callback);
}
private static Object[] removeCallback(Object... args) {
Object[] list = new Object[args.length-1];
for (int i = 0 ; i < args.length ; i++) {
if (!(args instanceof XC_MethodHook)) {
list = args;
}
}
return list;
}
}
Click to expand...
Click to collapse
Thank you but still no succes

Related

Get Picture ID

How can i get a PICTURE from a contact with just a phone number?...
Im using C# NET2.0
well its a bit tricky.
step one:
Hey dude stand still
step two
click
step three
save picture to contact.
other than that id say try search.
Not sure how you miss understood that but ..
First thing
the contact has a picture
second thing
it has to be done from code C#
third thing
I need to GET the picture from my contact if any... and then load it into a picture box
Another way i can ask is..
How can i loop through all my contacts...
one done and i find the contact how can i pull out the picture if any and load into a picturebox?
The following code shows how to loop through the contacts:
Code:
using Microsoft.WindowsMobile.PocketOutlook; // add a reference to this dll
...
public void LoadPictures()
{
OutlookSession outlookSession = new OutlookSession();
ContactCollection contactsCollection = outlookSession.Contacts.Items;
foreach (Contact contact in contactsCollection)
{
if (contact.Picture != null) // do additional checks like checking the phone number
{
}
}
}
Already got it heh...
Code:
private void LoadContactPicture(string PhoneNum)
{
Image NoImg = new Bitmap("\\Storage Card\\Debug\\avatar.png");
try
{
OutlookSession oSession = new OutlookSession();
int iCounter = 0;
int ContactIndex = 9999;
if (oSession.Contacts.Items.Count > 0)
{
while (iCounter < oSession.Contacts.Items.Count)
{
if (oSession.Contacts.Items[iCounter].MobileTelephoneNumber == PhoneNum)
{
ContactIndex = iCounter;
iCounter = oSession.Contacts.Items.Count + 1;
break;
}
iCounter++;
}
}
if (ContactIndex != 9999)
{
SetTextLbl(oSession.Contacts.Items[ContactIndex].FirstName + "... Just sent you a text message.");
if(oSession.Contacts.Items[ContactIndex].Picture != null ){
SetPictureMy(oSession.Contacts.Items[ContactIndex].Picture);
}
else
{
SetPictureMy(NoImg);
}
}
else
{
//Image NoImg = new Bitmap("\\My Documents\\My Pictures\\Flower.jpg");
SetTextLbl("Unknown Text Sender... " + PhoneNum);
SetPictureMy(NoImg);
}
}
catch
{
throw;
}
}

TypeLoadException

Hey all I'm getting a TypeLoaderException in the following:
Code:
private object RetrieveObject(string dllLocation, ClassDetails classIdentifier)
{
System.Reflection.Assembly assem = Assembly.LoadFrom(dllLocation);
try
{
// ClassIdentifier.Details() = "Service1.Service1" which is correct
Type t = assem.GetType(classIdentifier.Details(),true); // FAIL HERE
return Activator.CreateInstance(t);
}
catch(Exception ex)
{
RequestListener.AppendLog("Exception occured at SD RetrieveObject: " + ex.ToString());
}
return null;
}
The class I'm trying to resurrect is the following
Code:
namespace Service1
{
public class Service1 : System.Web.Services.WebService
{
public Service1()
{
}
[WebMethod(MessageName = "SayHello")]
public string HelloWorld()
{
return "Hello World";
}
}
}
Any ideas why this is failing?

[Q] [.net cf]Loopback

Hey guys
I'm developing a little webserver for WM with the .net cf. it's easy and works fine as long as I don't try to access it from the same device it's running on. Nothing works: localhost,127.0.0.1 or even if I'm connected to a wifi network and I use this IP. Has anyone the solution for this issue?
ta you
a yeah I use the TcpListener-Class and I implemted some simple HTTP.
chabun
Code
Hey guys
Noone has an idea??
Here is the code which I use to setup the HttpListener and answer connections.
Code:
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using StedySoft.SenseSDK;
using System.Threading;
using System.IO;
namespace WebServer
{
public partial class ServerForm : Form
{
IPEndPoint local;
TcpListener listener;
private volatile bool stop;
private volatile bool handled;
SensePanelItem state;
SensePanelTextboxItem response;
Thread serverThread;
public ServerForm(IPEndPoint local)
{
InitializeComponent();
this.local = local;
SetupList();
}
private void SetupList()
{
SensePanelDividerItem infos = new SensePanelDividerItem("infd", "Infos");
mainList.AddItem(infos);
mainList.AddItem(new SensePanelItem("Local-Endpoint") { PrimaryText = "Local-Endpoint", SecondaryText = local.ToString() });
mainList.AddItem(state = new SensePanelItem("Status") { PrimaryText = "Status", SecondaryText = "Wird gestartet..." });
mainList.AddItem(new SensePanelDividerItem("Response", "Response"));
mainList.AddItem(response = new SensePanelTextboxItem("body") { LabelText = "HTML-Body, welcher auf Requests gesendet wird.", Text = "<span style =\"color:red;font-size:30pt\">It works!!</span>" });
mainList.AddItem(new SensePanelDividerItem("Requests", "Requests"));
}
private void StartServer()
{
if (listener != null)
{
StopServer(true);
}
listener = new TcpListener(local.Port);
listener.Start();
serverThread = new Thread(listen);
serverThread.IsBackground = true;
stop = false;
serverThread.Start();
state.SecondaryText = "Gestartet...";
}
private void listen()
{
while (!stop)
{
while (listener.Pending())
{
handled = false;
Thread handlingThread = new Thread(handler);
handlingThread.Start();
while (!handled)
Thread.Sleep(50);
}
Thread.Sleep(200);
}
}
private void handler()
{
// Get the current connection
TcpClient client = (TcpClient)this.Invoke(new Func<TcpClient>(listener.AcceptTcpClient));
IPEndPoint remote = (IPEndPoint)client.Client.RemoteEndPoint;
handled = true;
NetworkStream stream = client.GetStream();
StreamReader reader = new StreamReader(stream);
ReadHttpRequest(reader);
StreamWriter writer = new StreamWriter(stream);
StringBuilder response = new StringBuilder(); ;
StartHTML(response);
response.AppendLine((string)this.Invoke(new Func<IPEndPoint, string>(GetResponse), remote));
EndHTML(response);
WriteHTTPResponse(writer, response.Length);
writer.WriteLine(response.ToString());
writer.Flush();
stream.Close();
client.Close();
}
private void WriteHTTPResponse(StreamWriter writer, int length)
{
writer.WriteLine("HTTP/1.1 200 OK");
writer.WriteLine("Date: " + DateTime.Now.ToString());
writer.WriteLine("Content-Length: "+ length.ToString());
writer.WriteLine("Connection: close");
writer.WriteLine("Content-Type: text/html; charset=utf-8");
writer.WriteLine();
}
private void ReadHttpRequest(StreamReader reader)
{
string buffer = null;
while (buffer != "")
buffer = reader.ReadLine();
}
int counter = 0;
private string GetResponse(IPEndPoint remote)
{
counter++;
mainList.AddItem(new SensePanelItem(counter.ToString()) { PrimaryText = remote.ToString(), SecondaryText = "Response:" + counter.ToString() });
return response.Text;
}
private void EndHTML(StringBuilder writer)
{
writer.AppendLine("</body>");
writer.AppendLine("</html>");
}
private void StartHTML(StringBuilder writer)
{
writer.AppendLine("<?xml version=\"1.0\"?>");
writer.AppendLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">");
writer.AppendLine("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"de\" lang=\"de\">");
writer.AppendLine("<head>");
writer.AppendLine("<title>SmartWebServer</title>");
writer.AppendLine("<meta name=\"author\" content=\"Alexander Kayed\">");
writer.AppendLine("</head>");
writer.AppendLine("<body>");
}
private void StopServer(bool restart)
{
stop = true;
serverThread.Join();
if (restart)
StartServer();
}
private void ServerForm_Load(object sender, EventArgs e)
{
StartServer();
}
private void ServerForm_Closed(object sender, EventArgs e)
{
StopServer(false);
}
private void menuItem1_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
The user can choose the IPEndPoint(constructor), which the server will be bound to, in a prevouis form:
Code:
foreach (IPAddress ip in Dns.GetHostEntry(Dns.GetHostName()).AddressList)
{
item = new SensePanelRadioItem(ip.ToString());
item.PrimaryText = ip.ToString();
item.SecondaryText = ip.AddressFamily.ToString();
item.Tag = ChoosedIp = ip;
item.OnStatusChanged += new SensePanelRadioItem.StatusEventHandler(item_OnStatusChanged);
IPList.AddItem(item);
}
So the user can choose between IPs I got from the DNS (e.g. 127.0.0.1, 192.168.0.1) and type a free (valid) port number (eg. 80, 8080, 8888)
Thanks for Your help!!
Still no answer...
I will post my experiences with this issue as long as I solved it - like small blog. Maybe some of you have the same problem...
I found another strange thing:
I'm able to connect to my Server from a TcpClient from another self-written App (own exectuable, different AppDomain):
Code:
void test()
{
Action<string> setText = new Action<string>(setTestText);
try
{
this.Invoke(setText, "Connect...");
TcpClient client = new TcpClient();
client.Connect(local);
this.Invoke(setText, "Connected...");
NetworkStream stream = client.GetStream();
StreamWriter writer = new StreamWriter(stream);
StreamReader reader = new StreamReader(stream);
writer.WriteLine();
writer.Flush();
this.Invoke(setText, "Read answer");
string buffer = reader.ReadToEnd();
this.Invoke(setText, "Test succeeded");
testing = false;
}
catch
{
this.Invoke(setText, "Test failed");
}
}
And I got a the right answer as well. It's strange, really strange that the browsers (IE,Opera etc.) can't loopback to it?

[SOLVED] java.lang.NoSuchMethodError where such a method exists

Hello, I get the following exception in logcat
Code:
E/Xposed (10014): java.lang.NoSuchMethodError: com.android.keyguard.KeyguardSecurityContainer#updateSecurityView(android.view.View,java.lang.Boolean)#exact
and my code is
Code:
public class XposedMod implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) && (lpparam.packageName.contains("android.keyguard") || lpparam.packageName.contains("com.android.systemui")))
{
Class<?> KeyguardHostView = XposedHelpers.findClass("com.android.keyguard.KeyguardSecurityContainer", lpparam.classLoader);
findAndHookMethod(KeyguardHostView, "updateSecurityView", View.class, Boolean.class, mUpdateSecurityViewHook);
}
}
The method exists here https://github.com/android/platform.../keyguard/KeyguardSecurityContainer.java#L139
What should I do? Thanks for your help!
Code:
findAndHookMethod(KeyguardHostView, "updateSecurityView", View.class, boolean.class, mUpdateSecurityViewHook);
The primitive boolean was to be used instead of the boxed Boolean
Rijul.A said:
Hello, I get the following exception in logcat
Code:
E/Xposed (10014): java.lang.NoSuchMethodError: com.android.keyguard.KeyguardSecurityContainer#updateSecurityView(android.view.View,java.lang.Boolean)#exact
and my code is
Code:
public class XposedMod implements IXposedHookLoadPackage {
@Override
public void handleLoadPackage(LoadPackageParam lpparam) throws Throwable {
if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) && (lpparam.packageName.contains("android.keyguard") || lpparam.packageName.contains("com.android.systemui")))
{
Class<?> KeyguardHostView = XposedHelpers.findClass("com.android.keyguard.KeyguardSecurityContainer", lpparam.classLoader);
findAndHookMethod(KeyguardHostView, "updateSecurityView", View.class, Boolean.class, mUpdateSecurityViewHook);
}
}
The method exists here https://github.com/android/platform.../keyguard/KeyguardSecurityContainer.java#L139
What should I do? Thanks for your help!
Click to expand...
Click to collapse
Make class and paste this content
PHP:
import java.lang.reflect.Method;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;
public class XposedWrapper {
public static XC_MethodHook.Unhook hookMethod(Class<?> sClass,String method_Name,Object... parameterTypesAndCallback) {
Method method = XposedHelpers.findMethodBestMatch(sClass,method_Name,removeCallback(parameterTypesAndCallback));
XC_MethodHook callback = (XC_MethodHook) parameterTypesAndCallback[parameterTypesAndCallback.length-1];
return XposedBridge.hookMethod(method,callback);
}
private static Object[] removeCallback(Object... args) {
Object[] list = new Object[args.length-1];
for (int i = 0 ; i < args.length ; i++) {
if (!(args[i] instanceof XC_MethodHook)) {
list[i] = args[i];
}
}
return list;
}
}
Now in the xposed class
do like this
PHP:
XposedWrapper.hookMethod(KeyguardHostView, "updateSecurityView", View.class, Boolean.class, new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
XposedBridge.log("Hooked");
}
});

Boolean Replacement

Hey Guys..
I have a problem with my xposed module.
I will a class to boolean false not true if rooted device..
Code:
public static boolean isRooted()
This to return false if rooted device..
Code:
XposedHelpers.findAndHockMethod("com.example.utils.RootCheck", lpparam.classLoader, "isRooted", boolean.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.args[0] = false;
}
});
Xposed say me nosuchmethoderror com.example.utils.RootCheck#isRooted(boolean)..
Can help me..
Thanks
Sorry for my bad English i m a german.
what class is it, is it your own?
are you filtering by package name?
Is not my own class..
From another Application..
This is the class. i have decoded.
I want replace "public static final String" , public static boolean isRooted() to ever false and private static boolean a(String str) to ever false..
can help me?
Code:
public final class RootCheck {
public static final String VALUE_DEVICE_FLAG_SU = "su";
public static final String VALUE_DEVICE_FLAG_SUPER_USER_APK = "superuser.apk";
public static final String VALUE_DEVICE_FLAG_TEST_KEYS = "testkeys";
private RootCheck() {
}
public static boolean isRooted() {
BuildConfig.IS_PROD.booleanValue();
return false;
}
public static Object[] getFlags() {
int i;
int i2;
List arrayList;
Object[] objArr;
int i3 = 1;
String str = Build.TAGS;
if (str == null || !str.contains("test-keys")) {
i = 0;
} else {
i = 1;
}
try {
if (new File("/system/app/Superuser.apk").exists()) {
i2 = 1;
if (!(a("/system/xbin/which su") || a("/system/bin/which su") || a("which su"))) {
i3 = 0;
}
arrayList = new ArrayList();
if (i3 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SU);
}
if (i2 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SUPER_USER_APK);
}
if (i != 0) {
arrayList.add(VALUE_DEVICE_FLAG_TEST_KEYS);
}
objArr = new Object[0];
if (arrayList.isEmpty()) {
return arrayList.toArray(objArr);
}
return objArr;
}
} catch (Exception e) {
}
i2 = 0;
i3 = 0;
arrayList = new ArrayList();
if (i3 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SU);
}
if (i2 != 0) {
arrayList.add(VALUE_DEVICE_FLAG_SUPER_USER_APK);
}
if (i != 0) {
arrayList.add(VALUE_DEVICE_FLAG_TEST_KEYS);
}
objArr = new Object[0];
if (arrayList.isEmpty()) {
return objArr;
}
return arrayList.toArray(objArr);
}
private static boolean a(String str) {
try {
Runtime.getRuntime().exec(str);
return true;
} catch (Exception e) {
return false;
}
}
}
oh wait, isRooted doesn't take any arguments and you're trying to hook isRooted with a boolean argument, which would be a different method
return values are called result here (getResult, setResult.) args is only for arguments
Oh thx
Code:
06-17 22:21:05.373: E/Xposed(30470): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
06-17 22:21:05.373: E/Xposed(30470): at de.bozja.hrh.Hidder$1.beforeHookedMethod(Hidder.java:22)
Error why?
class
Code:
findAndHookMethod("com.example.RootCheck", lpparam.classLoader, "isRooted", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
boolean isRoot = (Boolean) param.getResult(); //Error on this line
if(isRoot == true)
isRoot = false;
param.setResult(isRoot);
}
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
boolean isRoot = (Boolean) param.getResult();
if(isRoot == true)
isRoot = false;
param.setResult(isRoot);
}
});
beforeHookedMethod is called before the method is executed, so there can't be any result. so it's null
Just setresult to false in beforehooked dont add extra junk
And dont hook method afterhook no need before will do what u need
gitfib said:
oh wait, isRooted doesn't take any arguments and you're trying to hook isRooted with a boolean argument, which would be a different method
return values are called result here (getResult, setResult.) args is only for arguments
Click to expand...
Click to collapse
i am also facing the same issue today when trying to hook some certain method that doesnt take in any argument. And i really didnt get the answer you gave. Could you be more elaborate please?
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
gitfib said:
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
Click to expand...
Click to collapse
thanks. Will try this too. Couldn't find it on Google
gitfib said:
that was a long time. necrobumping from Google?
I think I meant to use param.setResult instead of param.args[0] to set the return value
Click to expand...
Click to collapse
this is the method i want to hook. I want it to return false
public boolean vpn() {
try {
Iterator it = Collections.list(NetworkInterface.getNetworkInterfaces()).iterator();
String str = "";
do {
if (!it.hasNext()) {
return false;
}
NetworkInterface networkInterface = (NetworkInterface) it.next();
if (networkInterface.isUp()) {
str = networkInterface.getName();
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("IFACE NAME: ");
stringBuilder.append(str);
Log.d("DEBUG", stringBuilder.toString());
if (str.contains("tun") || str.contains("ppp")) {
Toast.makeText(getContext(), "Hello vpn detected", 1).show();
}
} while (!str.contains("pptp"));
Toast.makeText(getContext(), "Hello vpn detected", 1).show();
return true;
} catch (SocketException e) {
e.printStackTrace();
}
}
and this is my kotlin class
package app.devzeus.yesvpn.hook
import de.robv.android.xposed.IXposedHookLoadPackage
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XposedHelpers
import de.robv.android.xposed.callbacks.XC_LoadPackage
class hook: IXposedHookLoadPackage {
override fun handleLoadPackage(lpparam: XC_LoadPackage.LoadPackageParam?) {
val pakage = "com.eclipse.gamonyapp"
val className = "com.eclipse.gamonyapp.Fragments.OffersFragment"
val method = "vpn"
if (lpparam?.packageName == pakage){
XposedHelpers.findAndHookMethod(className, lpparam.classLoader, method, object: XC_MethodHook(){
override fun beforeHookedMethod(param: MethodHookParam?) {
super.beforeHookedMethod(param)
param?.result = false
}
})
}
}
}
am i doing it wrong? it still doesnt work. The class and method locations are correct
devzeus_ke said:
XposedHelpers.findAndHookMethod(className, lpparam.classLoader, method, object: XC_MethodHook(){
override fun beforeHookedMethod(param: MethodHookParam?) {
super.beforeHookedMethod(param)
param?.result = false
}
Click to expand...
Click to collapse
this should be a separate thread imo
XC_MethodHook | Xposed Framework API
api.xposed.info
in Java there would be no need for the super call and the syntax is .setResult, but I'm not sure in Kotlin
gitfib said:
this should be a separate thread imo
XC_MethodHook | Xposed Framework API
api.xposed.info
in Java there would be no need for the super call and the syntax is .setResult, but I'm not sure in Kotlin
Click to expand...
Click to collapse
about the .setResult(false) the compiler suggests .result = false

Categories

Resources