首页
社区
课程
招聘
[求助]Xposed微信发送图片方法
发表于: 2020-9-14 18:38 3319

[求助]Xposed微信发送图片方法

2020-9-14 18:38
3319

基于微信7.0.3
发送文本
发送文件的方法都已经找到了(从其他地方复制到了)
但是发送图片方法一直找不到,就算找到了也会报错

插入代码

import android.content.Intent;
import android.net.Uri;
import android.os.Environment;
import android.util.Log;


import java.io.File;
import java.util.ArrayList;

import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.XposedHelpers;


public class WXMessageUtils {

    public static void sendText(final String wxId,
                                String strContent) {

        if (MainXposed.classLoader == null) {
            XposedBridge.log("微信助手未初始化");
            return;
        }
        //构造new里面的参数:l iVar = new i(aao, str, hQ, i2, mVar.cvb().fD(talkerUserName, str));
        //Class<?> classiVar = ;
        Object objectiVar = XposedHelpers.newInstance(
                XposedHelpers.findClassIfExists("com.tencent.mm.modelmulti.h", MainXposed.classLoader),
                wxId, strContent, 1);

        //创建静态实例对象au.DF(),转换为com.tencent.mm.ab.o对象

        Object objectG = XposedHelpers.callStaticMethod(
                XposedHelpers.findClassIfExists("com.tencent.mm.model.av", MainXposed.classLoader),
                "Pw");
        //调用发消息方法
        try {
            XposedHelpers.callMethod(objectG, "a", objectiVar, 0);
            XposedBridge.log("发送消息成功-----");
        } catch (Exception e) {
            XposedBridge.log("发送消息失败XXXXXXX");
            XposedBridge.log(e.getMessage());
        }
    }

    public static void sendImage(final String wxId, String imgPath) {
        Class findClass = XposedHelpers.findClass("com.tencent.mm.av.n",  MainXposed.wxLpparam.classLoader);
        Object obj = XposedHelpers.callStaticMethod(findClass, "alL");
        if (obj == null) {
            obj = XposedHelpers.newInstance(findClass);
        }
        XposedHelpers.callMethod(obj, "a", 0, 0, imgPath, wxId, Boolean.TRUE);
        final ArrayList<String> arrayList = new ArrayList<>();
        arrayList.add(imgPath);
        final Object finalObj = obj;
        XposedHelpers.callMethod(finalObj,"b", arrayList, Boolean.TRUE, 0, 0, wxId);

        //-------------------------------------------------------------------------------------------------------------------------

        //  paramClassLoader, WechatEntity paramWechatEntity, paramString1, paramString2, paramString3,
//        Object[] arrayOfObject = new Object[2];
//        String sendPic_class_1 = "com.tencent.mm.av.n";
//        String sendPic_class_2 = "com.tencent.mm.ae.n";
//        String sendPic_field_1 = "hzX";
//        String sendPic_method_1 = "a";
//
//        arrayOfObject[0] = XposedHelpers.newInstance(XposedHelpers.findClass(sendPic_class_1, MainXposed.classLoader),
//                new Object[]{Integer.valueOf(3), "", wxId, imgPath,
//                        Integer.valueOf(1), null, Integer.valueOf(1), "", "", Boolean.valueOf(true), Integer.valueOf(2130837923)});
//
//        arrayOfObject[1] = Integer.valueOf(1);
//
//        XposedHelpers.callMethod(XposedHelpers.getStaticObjectField(
//                XposedHelpers.findClass(sendPic_class_2, MainXposed.classLoader), sendPic_field_1), sendPic_method_1, arrayOfObject);
//

    }


    /**
     * 发送文件方法
     *
     * @param wxId     对方用户ID
     * @param filePath 文件路径
     */
    public static void sendFile(String wxId, String filePath) {
        File file = new File(filePath);
        ClassLoader cl = MainXposed.classLoader;
        Class IMediaObject = XposedHelpers.findClass("com.tencent.mm.opensdk.modelmsg.WXMediaMessage$IMediaObject", cl);
        Class fileObjectClz = XposedHelpers.findClass("com.tencent.mm.opensdk.modelmsg.WXFileObject", cl);
        Class mediaMessageClz = XposedHelpers.findClass("com.tencent.mm.opensdk.modelmsg.WXMediaMessage", cl);
        Class mediaMsgSenderClz = XposedHelpers.findClass("com.tencent.mm.pluginsdk.model.app.l", cl);
        if (file.exists() && file.isFile()) {
            Object fileObject = XposedHelpers.newInstance(fileObjectClz);
            XposedHelpers.callMethod(fileObject, "setFilePath", filePath);
            Object mediaObject = XposedHelpers.newInstance(mediaMessageClz);
            XposedHelpers.setObjectField(mediaObject, "mediaObject", IMediaObject.cast(fileObject));
            XposedHelpers.setObjectField(mediaObject, "title", file.getName());
            XposedHelpers.setObjectField(mediaObject, "description", getFileDesc(file.length()));
            XposedHelpers.callStaticMethod(mediaMsgSenderClz, "a", mediaObject, "", "", wxId, 4, null);
            XposedBridge.log("发送完毕==" + filePath);
        } else {
            Log.e("文件不存在,无法发送 %s", filePath);
        }
    }

    /**
     * 获取文件大小
     *
     * @param filesize
     * @return
     */
    private static String getFileDesc(long filesize) {
        long j = filesize;
        if ((j >> 30) > 0) {
            // GB
            return (((double) Math.round((((double) j) * 10.0d) / 1.073741824E9d)) / 10.0d) + " GB";
        }
        if ((j >> 20) > 0) {
            // MB
            return (((double) Math.round((((double) j) * 10.0d) / 1048576.0d)) / 10.0d) + " MB";
        }
        if ((j >> 9) <= 0) {
            return j + " B";
        }
        return (((double) Math.round((((double) j) * 10.0d) / 1024.0d)) / 10.0d) + " KB";

    }

}

有没有大佬指导一下?


[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (3)
雪    币: 2081
活跃值: (2685)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
2
7.0.3这么老的版本你还搞 登陆都受限制了
2020-9-15 11:28
0
雪    币:
活跃值: (62)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
世界美景 7.0.3这么老的版本你还搞 登陆都受限制了
不会啊,我现在登录也没被限制啊,新的版本没抄袭到有用的方法。。。自己刚入门,不知道如何自己找方法,老哥有没有教程之类的指导一下?
2020-9-15 14:25
0
雪    币: 2081
活跃值: (2685)
能力值: ( LV6,RANK:90 )
在线值:
发帖
回帖
粉丝
4
批量登录会有大面积出现 提示更新最新版本 私聊我 你想要的我全部都有
2020-9-15 14:46
0
游客
登录 | 注册 方可回帖
返回
//