From 753c2b43d072bdbb15e0f8c1b12ae7df30ecd2fc Mon Sep 17 00:00:00 2001 From: Changhua Date: Sat, 19 Apr 2025 22:44:56 +0800 Subject: [PATCH] fix(chatroom): fix #379 --- WeChatFerry/spy/chatroom_manager.cpp | 35 ++++++++++++++++++---------- WeChatFerry/spy/offsets.h | 3 ++- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/WeChatFerry/spy/chatroom_manager.cpp b/WeChatFerry/spy/chatroom_manager.cpp index 912bda2..5763283 100644 --- a/WeChatFerry/spy/chatroom_manager.cpp +++ b/WeChatFerry/spy/chatroom_manager.cpp @@ -12,10 +12,11 @@ namespace chatroom { namespace OsRoom = Offsets::Chatroom; +using new_t = QWORD (*)(QWORD, WxString *); using get_mgr_t = QWORD (*)(); using add_member_t = QWORD (*)(QWORD, QWORD, WxString *, QWORD); using delete_member_t = QWORD (*)(QWORD, QWORD, WxString *); -using invite_members_t = QWORD (*)(const wchar_t *, QWORD, WxString *, QWORD); +using invite_members_t = QWORD (*)(const wchar_t *, QWORD, QWORD, QWORD); template bool rpc_chatroom_common(const MemberMgmt &m, uint8_t *out, size_t *len, Func func) @@ -36,9 +37,11 @@ int add_chatroom_member(const string &roomid, const string &wxids) WxString *wx_roomid = util::CreateWxString(roomid); - QWORD tmp[2] = { 0 }; - auto wx_members = util::parse_wxids(wxids).wxWxids; - QWORD p_members = reinterpret_cast(&wx_members); + QWORD tmp[2] = { 0 }; + + auto split = util::parse_wxids(wxids); + auto &wx_members = split.wxWxids; + QWORD p_members = reinterpret_cast(&wx_members); return static_cast(add_members(get_chatroom_mgr(), p_members, wx_roomid, reinterpret_cast(tmp))); } @@ -49,24 +52,32 @@ int del_chatroom_member(const string &roomid, const string &wxids) auto del_members = Spy::getFunction(OsRoom::DEL); WxString *wx_roomid = util::CreateWxString(roomid); - auto wx_members = util::parse_wxids(wxids).wxWxids; - QWORD p_members = reinterpret_cast(&wx_members); + + auto split = util::parse_wxids(wxids); + auto &wx_members = split.wxWxids; + QWORD p_members = reinterpret_cast(&wx_members); return static_cast(del_members(get_chatroom_mgr(), p_members, wx_roomid)); } int invite_chatroom_member(const string &roomid, const string &wxids) { + auto init_roomid = Spy::getFunction(OsRoom::NEW); auto invite_members = Spy::getFunction(OsRoom::INV); - wstring ws_roomid = util::s2w(roomid); - WxString *wx_roomid = util::CreateWxString(roomid); + wstring ws_roomid = util::s2w(roomid); + WxString wx_roomid(ws_roomid); - QWORD tmp[2] = { 0 }; - auto wx_members = util::parse_wxids(wxids).wxWxids; - QWORD p_members = reinterpret_cast(&wx_members); + QWORD tmp[2] = { 0 }; + QWORD array[4] = { 0 }; - return static_cast(invite_members(ws_roomid.c_str(), p_members, wx_roomid, reinterpret_cast(tmp))); + auto split = util::parse_wxids(wxids); + auto &wx_members = split.wxWxids; + QWORD p_members = reinterpret_cast(&wx_members); + QWORD p_roomid = init_roomid(reinterpret_cast(&array), &wx_roomid); + LOG_BUFFER((uint8_t *)*(QWORD *)(*(QWORD *)p_members), 40); + + return static_cast(invite_members(ws_roomid.c_str(), p_members, p_roomid, reinterpret_cast(tmp))); } bool rpc_add_chatroom_member(const MemberMgmt &m, uint8_t *out, size_t *len) diff --git a/WeChatFerry/spy/offsets.h b/WeChatFerry/spy/offsets.h index 74e98f6..a29370e 100644 --- a/WeChatFerry/spy/offsets.h +++ b/WeChatFerry/spy/offsets.h @@ -19,6 +19,7 @@ namespace Account namespace Chatroom { constexpr uint64_t MGR = 0x1B8AE40; + constexpr uint64_t NEW = 0x262D800; constexpr uint64_t DEL = 0x2163070; constexpr uint64_t ADD = 0x2162A30; constexpr uint64_t INV = 0x2162410; @@ -37,7 +38,7 @@ namespace Contact constexpr uint64_t GENDER = 0x0E; constexpr uint64_t STEP = 0x6A8; - constexpr uint64_t VERIFY_NEW = 0x262D800; + constexpr uint64_t VERIFY_NEW = Chatroom::NEW; constexpr uint64_t VERIFY_OK = 0x1F48850; constexpr uint64_t ADD_FRIEND_HELPER = 0x4F7FB18; // a1 constexpr uint64_t FVDF = 0x4F9DE28; // FriendVeriyDialogFragment