企微hook源码

企微hook源码已经在QQ群内开源。速度进群下载,避免和谐。

QQ群:649480745


//pc端发送消息回调
void RecvPcMsgRes(DWORD eax)
{

    // OutputDebugStringA("pc发送消息");

    PWX_STRING pMsgPb = (PWX_STRING)(eax);//消息pb结构体
    string pbData = WxStringToString(pMsgPb);//消息pb
    // OutputDebugStringA(StringToHex(pbData).c_str());
    ResMessageData pmd;
    pmd.ParseFromString(pbData);
    sessiondata sd = pmd.sessiondata();
    BaseResponse brs = pmd.baseresponse();
    for (int i = 0; i < sd.msg_size(); i++) {

        nlohmann::json root;
        root["errcode"] = brs.ret();
        if (brs.errmsg().size() > 0) {
            root["errmsg"] = brs.errmsg();
        }
        msgdata md = sd.msg(i);

        // OutputDebugStringA(md.appinfo().c_str());
        string syncKey = "";
        string file = "";
        long source = 0L;
        //同步发送消息
        //for (auto it = SsenMsgQueue.begin(); it != SsenMsgQueue.end(); ++it)
        //{
        //    map<string, string> resVal = *it;
        //    if (resVal.count(md.appinfo())>0) {
        //        syncKey = resVal[md.appinfo()];
        //        SsenMsgQueue.erase(it);
        //        break;
        //    }
        //}
        //OutputDebugStringA("当前消息队列长度");
        //OutputDebugStringA(to_string(SsenMsgQueue.size()).c_str());

        if (SsenMsgQueue.count(md.appinfo()) > 0)
        {
            string json = SsenMsgQueue[md.appinfo()];
            auto j3 = json::parse(json);
            syncKey = j3["syncKey"];
            file = j3["file"];
            if (!j3["data"]["source"].is_null() && j3["data"]["source"].is_number() == TRUE) {
                // 存在字段进行校验
                source = j3["data"]["source"];
            }
            SsenMsgQueueDel(md.appinfo());
        }

        nlohmann::json item;
        item["is_pc_send"] = 1;
        item["synckey"] = syncKey;
        item["source"] = source;
        item["msg_id"] = md.id();
        item["server_id"] = md.seq();
        msgMap[md.appinfo()] = "val";
        item["sender"] = to_string(md.sender());
        item["receiver"] = to_string(md.receiver());
        item["sendtime"] = md.sendtime();
        item["msgtype"] = md.contenttype();

        if (md.messagetype() == 1) {
            string strRoomId = to_string(md.roomid());
            item["room_conversation_id"] = ("R:" + strRoomId);
            item["is_room"] = 1;
        }
        else if (md.messagetype() == 4) {
            item["receiver"] = "FILEASSIST";
            item["is_room"] = 0;
        }
        else {
            item["is_room"] = 0;
        }
        string msgPb = md.content();

        switch (md.contenttype())
        {
        case 0: //文本消息
            //root["type"] = SEND_MSG_TEXT;
            ThisPcTestMsg(msgPb, item, root);
            break;
        case 2: //文本消息
            //root["type"] = SEND_MSG_TEXT;
            ThisPcTestMsg(msgPb, item, root);
            break;
        case 6://位置消息
            root["type"] = SEND_LOCATION_MSG;
            RecvPositionMsg(msgPb, item, root);
            break;
        case 29://gif消息
            root["type"] = SEND_MSG_GIF;
            ExpressionMsg(msgPb, item, root);

            break;
        case 78://小程序
            root["type"] = SEND_MSG_APPLETS;
            AppletsPcMsg(msgPb, item, root);

            break;
        case 141://视频号
            root["type"] = SEND_WECHAT_SPH_FEED;
            WechatSphFeedMeg(msgPb, item, root);

            break;
        case 13://链接
            root["type"] = SEND_LINK_MSG;
            LinkPcMsg(msgPb, item, root);

            break;
        case 0x29://名片消息
            root["type"] = SEND_BUSSINESS_CARD;
            BusinessCardMsg(msgPb, item, root);

            break;
        case 14://图片消息
            root["type"] = SEND_MSG_IMG;
            item["file"] = file;
            ImgMsg(msgPb, item, root);

            break;
        case 15://文件消息
            root["type"] = SEND_FILE_MSG;
            item["file"] = file;
            FileMsg(msgPb, item, root);

            break;
        case 16://语音消息
            root["type"] = SEND_VOICE_MSG;
            VoiceMsg(msgPb, item, root);
            break;
        case 23://视频消息
            root["type"] = SEND_VIDEO_MSG;
            item["file"] = file;
            VideoMsg(msgPb, item, root);

            break;
        default:
            break;
        }
    }


}
 

相关推荐

  1. 魔盒V15.6独立版+搭建环境教程

    2024-03-11 04:00:01       16 阅读
  2. React Hooks usestate示例

    2024-03-11 04:00:01       32 阅读
  3. React16: Hooks实现

    2024-03-11 04:00:01       36 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-11 04:00:01       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-11 04:00:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-11 04:00:01       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-11 04:00:01       20 阅读

热门阅读

  1. 笔记:Linux下的Oracle日常简单检查

    2024-03-11 04:00:01       18 阅读
  2. linux Shell 命令行-01-intro 入门介绍

    2024-03-11 04:00:01       26 阅读
  3. 第三章:R语言编程 第六节:模块模式

    2024-03-11 04:00:01       22 阅读
  4. Qt如何将视频获取单帧

    2024-03-11 04:00:01       22 阅读
  5. Web前端_html5+css3

    2024-03-11 04:00:01       20 阅读
  6. TMGM中国官网平台合作的MT4交易软件MT5

    2024-03-11 04:00:01       23 阅读
  7. 服务器防火墙和安全组放开

    2024-03-11 04:00:01       22 阅读
  8. 线程池的执行流程

    2024-03-11 04:00:01       37 阅读
  9. SSL证书怎么开启?

    2024-03-11 04:00:01       21 阅读
  10. Python基础学习(9)迭代器/生成器

    2024-03-11 04:00:01       20 阅读
  11. SQL注入攻击 - 堆叠注入(Stacked Injection)

    2024-03-11 04:00:01       22 阅读
  12. python实现数据爬虫

    2024-03-11 04:00:01       25 阅读