Impl revoke message. Close #62

This commit is contained in:
Changhua 2023-11-27 20:04:41 +08:00
parent 9fc3dcd599
commit 03a954916c
8 changed files with 99 additions and 3 deletions

View File

@ -25,6 +25,7 @@ enum Functions {
FUNC_REFRESH_PYQ = 0x53;
FUNC_DOWNLOAD_ATTACH = 0x54;
FUNC_GET_CONTACT_INFO = 0x55;
FUNC_REVOKE_MSG = 0x56;
FUNC_DECRYPT_IMAGE = 0x60;
FUNC_ADD_ROOM_MEMBERS = 0x70;
FUNC_DEL_ROOM_MEMBERS = 0x71;

View File

@ -268,3 +268,48 @@ int DownloadAttach(uint64_t id, string thumb, string extra)
return status;
}
int RevokeMsg(uint64_t id)
{
int status = -1;
uint64_t localId;
uint32_t dbIdx;
if (GetLocalIdandDbidx(id, &localId, &dbIdx) != 0) {
LOG_ERROR("Failed to get localId, Please check id: {}", to_string(id));
return status;
}
char chat_msg[0x2D8] = { 0 };
DWORD rmCall1 = g_WeChatWinDllAddr + g_WxCalls.rm.call1;
DWORD rmCall2 = g_WeChatWinDllAddr + g_WxCalls.rm.call2;
DWORD rmCall3 = g_WeChatWinDllAddr + g_WxCalls.rm.call3;
DWORD rmCall4 = g_WeChatWinDllAddr + g_WxCalls.rm.call4;
DWORD rmCall5 = g_WeChatWinDllAddr + g_WxCalls.rm.call5;
__asm {
pushad;
pushfd;
lea ecx, chat_msg;
call rmCall1;
call rmCall2;
push dword ptr [dbIdx];
lea ecx, chat_msg;
push dword ptr [localId];
call rmCall3;
add esp, 0x8;
call rmCall2;
lea ecx, chat_msg;
push ecx;
mov ecx, eax;
call rmCall4;
mov status, eax;
lea ecx, chat_msg;
push 0x0;
call rmCall5;
popfd;
popad;
}
return status;
}

View File

@ -6,3 +6,4 @@
string DecryptImage(std::string src, std::string dst);
int RefreshPyq(uint64_t id);
int DownloadAttach(uint64_t id, std::string thumb, std::string extra);
int RevokeMsg(uint64_t id);

View File

@ -29,7 +29,9 @@ WxCalls_t wxCalls = {
hook, call, call1, call2, call3, start, end, ts, wxid, content, xml, step*/
{ 0x14F9E15, 0x14FA0A0, 0xC39680, 0x14E2140, 0x14E21E0, 0x20, 0x24, 0x2C, 0x18, 0x3C, 0x384, 0xB48 },
/* call1, call2, call3, call4, call5, call6*/
{ 0x76F010, 0x792700, 0xBC0370, 0x80F110, 0x82BB40, 0x756E30}
{ 0x76F010, 0x792700, 0xBC0370, 0x80F110, 0x82BB40, 0x756E30},
/* call1, call2, call3, call4, call5*/
{0x76F010, 0x792700, 0xBC0370, 0xBB5F70, 0x756E30}
};
int LoadCalls(const wchar_t *version, WxCalls_t *calls)

View File

@ -556,6 +556,24 @@ bool func_get_contact_info(string wxid, uint8_t *out, size_t *len)
return true;
}
bool func_revoke_msg(uint64_t id, uint8_t *out, size_t *len)
{
Response rsp = Response_init_default;
rsp.func = Functions_FUNC_REVOKE_MSG;
rsp.which_msg = Response_status_tag;
rsp.msg.status = RevokeMsg(id);
pb_ostream_t stream = pb_ostream_from_buffer(out, *len);
if (!pb_encode(&stream, Response_fields, &rsp)) {
LOG_ERROR("Encoding failed: {}", PB_GET_ERROR(&stream));
return false;
}
*len = stream.bytes_written;
return true;
}
bool func_decrypt_image(DecPath dec, uint8_t *out, size_t *len)
{
Response rsp = Response_init_default;
@ -742,6 +760,11 @@ static bool dispatcher(uint8_t *in, size_t in_len, uint8_t *out, size_t *out_len
ret = func_get_contact_info(req.msg.str, out, out_len);
break;
}
case Functions_FUNC_REVOKE_MSG: {
LOG_DEBUG("[Functions_FUNC_REVOKE_MSG]");
ret = func_revoke_msg(req.msg.ui64, out, out_len);
break;
}
case Functions_FUNC_DECRYPT_IMAGE: {
LOG_DEBUG("[FUNCTIONS_FUNC_DECRYPT_IMAGE]");
ret = func_decrypt_image(req.msg.dec, out, out_len);

View File

@ -112,6 +112,14 @@ typedef struct DlAttach {
DWORD call6;
} DlAttach_t;
typedef struct RevokeMsg {
DWORD call1;
DWORD call2;
DWORD call3;
DWORD call4;
DWORD call5;
} RevokeMsg_t;
typedef struct WxCalls {
DWORD login; // 登录状态
UserInfoCall_t ui; // 用户信息
@ -129,6 +137,7 @@ typedef struct WxCalls {
TF_t tf; // 接收转账
Pyq_t pyq; // 接收朋友圈消息
DlAttach_t da; // 下载资源(图片、文件、视频)
RevokeMsg_t rm; // 撤回消息
} WxCalls_t;
struct WxString {

View File

@ -635,6 +635,21 @@ class Wcf():
return contact
def revoke_msg(self, id: int = 0) -> int:
"""撤回消息
Args:
id (int): 待撤回消息的 id
Returns:
int: 1 为成功其他失败
"""
req = wcf_pb2.Request()
req.func = wcf_pb2.FUNC_REVOKE_MSG # FUNC_REVOKE_MSG
req.ui64 = id
rsp = self._send_request(req)
return rsp.status
def decrypt_image(self, src: str, dir: str) -> str:
"""解密图片:

File diff suppressed because one or more lines are too long