xposed开发5-修改微信我的零钱的金额

xposed开发5-修改微信我的零钱的金额

终于在virtualxposed上安装好微信了.

1.找到零钱的界面.

进入adb

adb shell

开发android微信零钱界面

dumpsys activity | grep mResumedActivity

找到对应的类
dumpsys

2.编写hook代码

搭建module的步骤请查看前面的文章
步骤:
1.遍历界面所有的TextView, 使用反射, 通过textView.addTextChangedListener(TextWatcher watcher)给找出的每一个TextView都添加一个文本监听;
2.当文本含有¥, 则设置新的值;

public class MainHook implements IXposedHookLoadPackage {
    @Override
    public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {
        if (lpparam.packageName.equals("com.tencent.mm")) {
            String hookClass = "com.tencent.mm.plugin.wallet.balance.ui.WalletBalanceManagerUI";
            String hookMethodName = "onCreate";

            XposedHelpers.findAndHookMethod(hookClass, lpparam.classLoader, hookMethodName, Bundle.class, new XC_MethodHook() {
                @Override
                protected void afterHookedMethod(MethodHookParam param) throws Throwable {
                    Object walletBalanceActivity = param.thisObject;
                    Field[] allField = walletBalanceActivity.getClass().getDeclaredFields();
                    for (Field field : allField) {
                        field.setAccessible(true);
                        Object fieldObject = field.get(walletBalanceActivity);
                        if (fieldObject != null && fieldObject instanceof TextView) {
                            TextView textView = (TextView) fieldObject;
                            textView.addTextChangedListener(new TextViewWatcher(textView));
                            XposedBridge.log(field.getName() + ", " + textView.getText().toString());
                        }
                    }
                }
            });
        }
    }
}

public class TextViewWatcher implements TextWatcher {
    public static final String LAST_TEXT = "200000.00";
    private TextView textView;

    public TextViewWatcher(TextView textView) {
        this.textView = textView;
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        String text = s.toString();
        XposedBridge.log("textView内容: " + text);
        if (text.contains("¥")) {
            textView.removeTextChangedListener(this);
            textView.setText(LAST_TEXT);
            textView.addTextChangedListener(this);
        }
    }
}
  • 运行插件, 生效:
    xposed开发5-修改微信我的零钱的金额_第1张图片

你可能感兴趣的:(xposed开发)