From 3db47a8532d00c30eb31f93145258481f7fd907d Mon Sep 17 00:00:00 2001 From: Changhua Date: Mon, 24 Mar 2025 22:35:08 +0800 Subject: [PATCH] feat(message): impl send xml --- WeChatFerry/spy/message_sender.cpp | 34 +++++++++++++----------------- WeChatFerry/spy/message_sender.h | 3 ++- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/WeChatFerry/spy/message_sender.cpp b/WeChatFerry/spy/message_sender.cpp index 2cbfac3..e565ae4 100644 --- a/WeChatFerry/spy/message_sender.cpp +++ b/WeChatFerry/spy/message_sender.cpp @@ -126,30 +126,26 @@ void Sender::send_file(const std::string &wxid, const std::string &path) void Sender::send_xml(const std::string &receiver, const std::string &xml, const std::string &path, uint64_t type) { -#if 0 - std::unique_ptr buff(new char[0x500]()); - std::unique_ptr buff2(new char[0x500]()); - char nullBuf[0x1C] = { 0 }; + char buff1[0x500] = { 0 }; + char buff2[0x500] = { 0 }; + char buff3[0x1C] = { 0 }; - func_new_chat_msg(reinterpret_cast(buff.get())); - func_new_chat_msg(reinterpret_cast(buff2.get())); + auto pBuff1 = func_new_chat_msg(reinterpret_cast(buff1)); + auto pBuff2 = func_new_chat_msg(reinterpret_cast(buff2)); + auto pBuff3 = reinterpret_cast(&buff3); - QWORD sbuf[4] = { 0, 0, 0, 0 }; - QWORD sign = func_xml_buf_sign(reinterpret_cast(buff2.get()), reinterpret_cast(sbuf), 0x1); + QWORD array[4] = { 0 }; - auto wxReceiver = new_wx_string(receiver); - auto wxXml = new_wx_string(xml); - auto wxPath = new_wx_string(path); - auto wxSender = new_wx_string(account::get_self_wxid()); + auto sign = func_xml_buf_sign(pBuff2, reinterpret_cast(&array), 0x1); - func_send_xml(reinterpret_cast(buff.get()), reinterpret_cast(wxSender.get()), - reinterpret_cast(wxReceiver.get()), reinterpret_cast(wxXml.get()), - reinterpret_cast(wxPath.get()), reinterpret_cast(nullBuf), type, 0x4, sign, - reinterpret_cast(buff2.get())); + util::WxStringHolder to(receiver); + util::WxStringHolder body(xml); + util::WxStringHolder thumb(path); + util::WxStringHolder from(account::get_self_wxid()); - func_free_chat_msg(reinterpret_cast(buff.get())); - func_free_chat_msg(reinterpret_cast(buff2.get())); -#endif + func_send_xml(pBuff1, &from.wx, &to.wx, &body.wx, &thumb.wx, pBuff3, type, 0x4, sign, pBuff2); + func_free_chat_msg(pBuff1); + func_free_chat_msg(pBuff2); } void Sender::send_emotion(const std::string &wxid, const std::string &path) diff --git a/WeChatFerry/spy/message_sender.h b/WeChatFerry/spy/message_sender.h index 7811395..c724d09 100644 --- a/WeChatFerry/spy/message_sender.h +++ b/WeChatFerry/spy/message_sender.h @@ -56,7 +56,8 @@ private: using GetEmotionMgr_t = QWORD (*)(); using SendEmotion_t = QWORD (*)(QWORD, WxString *, QWORD *, WxString *, QWORD, QWORD *, QWORD, QWORD *); using XmlBufSign_t = QWORD (*)(QWORD, QWORD, QWORD); - using SendXml_t = QWORD (*)(QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD, QWORD); + using SendXml_t + = QWORD (*)(QWORD, WxString *, WxString *, WxString *, WxString *, QWORD, QWORD, QWORD, QWORD, QWORD); New_t func_new_chat_msg; Free_t func_free_chat_msg;