feat: 撤回消息

This commit is contained in:
hugy 2023-05-29 17:47:36 +08:00
parent 83886fe464
commit 3cd6953920
6 changed files with 59 additions and 2 deletions

View File

@ -74,6 +74,7 @@ typedef enum HTTP_API_ROUTE {
WECHAT_GET_QRCODE, WECHAT_GET_QRCODE,
WECHAT_INVITE_MEMBERS, WECHAT_INVITE_MEMBERS,
WECHAT_GET_MEMBER_PROFILE, WECHAT_GET_MEMBER_PROFILE,
WECHAT_REVOKE_MSG,
} WECHAT_HTTP_APIS, } WECHAT_HTTP_APIS,
*PWECHAT_HTTP_APIS; *PWECHAT_HTTP_APIS;

View File

@ -614,6 +614,13 @@ string Dispatch(struct mg_connection *c, struct mg_http_message *hm) {
break; 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: default:
json ret_data = {{"result", "ERROR"}, {"msg", "not support api"}}; json ret_data = {{"result", "ERROR"}, {"msg", "not support api"}};
ret = ret_data.dump(); ret = ret_data.dump();

View File

@ -415,4 +415,45 @@ int MiscMgr::SearchContactNetScene(wchar_t *keyword,UserInfo ** user) {
return success; 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 } // namespace wxhelper

View File

@ -18,6 +18,7 @@ class MiscMgr :public BaseMgr{
int GetVoice(ULONG64 msg_id, wchar_t* dir); int GetVoice(ULONG64 msg_id, wchar_t* dir);
int GetImgByName(wchar_t* file_path,wchar_t* save_dir); int GetImgByName(wchar_t* file_path,wchar_t* save_dir);
int SearchContactNetScene(wchar_t *keyword,UserInfo ** user); int SearchContactNetScene(wchar_t *keyword,UserInfo ** user);
int RevokeMsg(ULONG64 msg_id);
}; };
} // namespace wxhelper } // namespace wxhelper

View File

@ -9,6 +9,7 @@ SendMessageMgr::SendMessageMgr(DWORD base):BaseMgr(base) {}
SendMessageMgr::~SendMessageMgr() {} SendMessageMgr::~SendMessageMgr() {}
int SendMessageMgr::SendText(wchar_t* wxid, wchar_t* msg) { int SendMessageMgr::SendText(wchar_t* wxid, wchar_t* msg) {
int success = -1; int success = -1;
unsigned long long msgid = 0;
WeChatString to_user(wxid); WeChatString to_user(wxid);
WeChatString text_msg(msg); WeChatString text_msg(msg);
wchar_t** msg_pptr = &text_msg.ptr; wchar_t** msg_pptr = &text_msg.ptr;
@ -31,13 +32,18 @@ int SendMessageMgr::SendText(wchar_t* wxid, wchar_t* msg) {
LEA ECX,chat_msg LEA ECX,chat_msg
CALL send_text_msg_addr CALL send_text_msg_addr
MOV success,EAX 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 ADD ESP,0x18
LEA ECX,chat_msg LEA ECX,chat_msg
CALL free_chat_msg_addr CALL free_chat_msg_addr
POPFD POPFD
POPAD POPAD
} }
SPDLOG_INFO("SendText code = {}",success); SPDLOG_INFO("SendText code = {}",msgid);
SPDLOG_INFO("global log with source info"); SPDLOG_INFO("global log with source info");
return success; return success;
} }

View File

@ -98,7 +98,8 @@
#define WX_DOWNLOAD_VIDEO_IMG_OFFSET 0xd46c30 #define WX_DOWNLOAD_VIDEO_IMG_OFFSET 0xd46c30
// revoke
#define WX_REVOKE_MSG_OFFSET 0xbb6dc0
// pat // pat