From 3cd6953920ad4bc258b34a642606f8d21b3b6c18 Mon Sep 17 00:00:00 2001 From: hugy <504650082@qq.com> Date: Mon, 29 May 2023 17:47:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=92=A4=E5=9B=9E=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_route.h | 1 + src/http_handler.cc | 7 +++++++ src/misc_mgr.cc | 41 +++++++++++++++++++++++++++++++++++++++++ src/misc_mgr.h | 1 + src/send_message_mgr.cc | 8 +++++++- src/wechat_function.h | 3 ++- 6 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/api_route.h b/src/api_route.h index b3643cf..0f39b0c 100644 --- a/src/api_route.h +++ b/src/api_route.h @@ -74,6 +74,7 @@ typedef enum HTTP_API_ROUTE { WECHAT_GET_QRCODE, WECHAT_INVITE_MEMBERS, WECHAT_GET_MEMBER_PROFILE, + WECHAT_REVOKE_MSG, } WECHAT_HTTP_APIS, *PWECHAT_HTTP_APIS; diff --git a/src/http_handler.cc b/src/http_handler.cc index 7dec252..569310e 100644 --- a/src/http_handler.cc +++ b/src/http_handler.cc @@ -614,6 +614,13 @@ string Dispatch(struct mg_connection *c, struct mg_http_message *hm) { break; } + case WECHAT_REVOKE_MSG:{ + ULONG64 msg_id = GetULong64Param(j_param, "msgId"); + int success = g_context.misc_mgr->RevokeMsg(msg_id); + json ret_data = {{"code", success}, {"result", "OK"}}; + ret = ret_data.dump(); + break; + } default: json ret_data = {{"result", "ERROR"}, {"msg", "not support api"}}; ret = ret_data.dump(); diff --git a/src/misc_mgr.cc b/src/misc_mgr.cc index d12d4e8..8bfd15d 100644 --- a/src/misc_mgr.cc +++ b/src/misc_mgr.cc @@ -415,4 +415,45 @@ int MiscMgr::SearchContactNetScene(wchar_t *keyword,UserInfo ** user) { return success; } +int MiscMgr::RevokeMsg(ULONG64 msg_id){ + int success = -1; + char chat_msg[0x2D8] = {0}; + DWORD new_chat_msg_addr = base_addr_ + WX_NEW_CHAT_MSG_OFFSET; + DWORD free_addr = base_addr_ + WX_FREE_CHAT_MSG_INSTANCE_COUNTER_OFFSET; + DWORD get_chat_mgr_addr = base_addr_ + WX_CHAT_MGR_OFFSET; + DWORD get_by_local_Id_addr = base_addr_ + WX_GET_MGR_BY_PREFIX_LOCAL_ID_OFFSET; + DWORD revoke_msg_addr = base_addr_ + WX_REVOKE_MSG_OFFSET; + + int db_index = 0; + int local_id = DB::GetInstance().GetLocalIdByMsgId(msg_id, db_index); + if (local_id < 1) { + return -2; + } + __asm{ + PUSHAD + PUSHFD + LEA ECX,chat_msg + CALL new_chat_msg_addr + CALL get_chat_mgr_addr + PUSH dword ptr [db_index] + LEA ECX,chat_msg + PUSH dword ptr [local_id] + CALL get_by_local_Id_addr + ADD ESP,0x8 + CALL get_chat_mgr_addr + LEA ECX,chat_msg + PUSH ECX + MOV ECX,EAX + CALL revoke_msg_addr + MOV success,EAX + LEA ECX,chat_msg + PUSH 0x0 + CALL free_addr + POPFD + POPAD + } + + return success; + +} } // namespace wxhelper \ No newline at end of file diff --git a/src/misc_mgr.h b/src/misc_mgr.h index 891f99c..d13f94c 100644 --- a/src/misc_mgr.h +++ b/src/misc_mgr.h @@ -18,6 +18,7 @@ class MiscMgr :public BaseMgr{ int GetVoice(ULONG64 msg_id, wchar_t* dir); int GetImgByName(wchar_t* file_path,wchar_t* save_dir); int SearchContactNetScene(wchar_t *keyword,UserInfo ** user); + int RevokeMsg(ULONG64 msg_id); }; } // namespace wxhelper diff --git a/src/send_message_mgr.cc b/src/send_message_mgr.cc index 80b23c0..9a7f8fb 100644 --- a/src/send_message_mgr.cc +++ b/src/send_message_mgr.cc @@ -9,6 +9,7 @@ SendMessageMgr::SendMessageMgr(DWORD base):BaseMgr(base) {} SendMessageMgr::~SendMessageMgr() {} int SendMessageMgr::SendText(wchar_t* wxid, wchar_t* msg) { int success = -1; + unsigned long long msgid = 0; WeChatString to_user(wxid); WeChatString text_msg(msg); wchar_t** msg_pptr = &text_msg.ptr; @@ -31,13 +32,18 @@ int SendMessageMgr::SendText(wchar_t* wxid, wchar_t* msg) { LEA ECX,chat_msg CALL send_text_msg_addr MOV success,EAX + LEA ECX,msgid + MOV EDI,dword ptr[EAX +0x2b0] + MOV ESI,dword ptr[EAX+0x2b4] + MOV [ECX],EDI + MOV [ECX + 0x4],ESI ADD ESP,0x18 LEA ECX,chat_msg CALL free_chat_msg_addr POPFD POPAD } - SPDLOG_INFO("SendText code = {}",success); + SPDLOG_INFO("SendText code = {}",msgid); SPDLOG_INFO("global log with source info"); return success; } diff --git a/src/wechat_function.h b/src/wechat_function.h index eeaca13..e94ece5 100644 --- a/src/wechat_function.h +++ b/src/wechat_function.h @@ -98,7 +98,8 @@ #define WX_DOWNLOAD_VIDEO_IMG_OFFSET 0xd46c30 - +// revoke +#define WX_REVOKE_MSG_OFFSET 0xbb6dc0 // pat