提交 e9e251cd 编写于 作者: L ljc545w

解决接收消息时会捕获发送消息问题

上级 6fd0ac13
......@@ -24,6 +24,9 @@ DWORD ReceiveMessageNextCall = GetWeChatWinBase() + ReceiveMessageNextCallOffset
DWORD JmpBackAddress = ReceiveMessageHookAddress + 0x5;
VOID ReceiveMessage(DWORD messageAddr) {
DWORD isSendMessage = *(DWORD*)(messageAddr + 0x3C);
if (isSendMessage)
return;
messageStruct message = { 0 };
message.messagetype = *(DWORD*)(messageAddr + 0x38);
......@@ -53,6 +56,9 @@ VOID ReceiveMessage(DWORD messageAddr) {
memcpy(message.message, (wchar_t*)(*(DWORD*)(messageAddr + 0x70)), length * 2);
message.l_message = length;
// FileSavePath:messageAddr + 0x1AC
messageVector.push_back(message);
}
......
......@@ -149,16 +149,15 @@ class WeChatRobot():
try:
return _EnumFriendStatus[status]
except KeyError:
return "未知状态:{}".format(
hex(status).upper().replace('0X','0x'))
return "未知状态:{}".format(hex(status).upper().replace('0X','0x'))
def ReceiveMessage(self,CallBackFunc = None):
comtypes.CoInitialize()
ThreadRobot = comtypes.client.CreateObject("WeChatRobot.CWeChatRobot")
# 线程中必须新建一个对象,但无需重复注入
ThreadRobot = WeChatRobot()
while self.ReceiveMessageStarted:
try:
message = dict(ThreadRobot.CReceiveMessage())
message = dict(ThreadRobot.robot.CReceiveMessage())
if CallBackFunc:
CallBackFunc(ThreadRobot,message)
except IndexError:
......@@ -187,8 +186,11 @@ class WeChatRobot():
# 一个示例回调,将收到的文本消息转发给filehelper
def ReceiveMessageCallBack(robot,message):
if message['type'] == 1 and message['sender'] != 'filehelper':
robot.CSendText('filehelper',message['message'])
if message['sender'] != 'filehelper': print(message)
robot.robot.CSendText('filehelper',message['message'])
if message['sender'] != 'filehelper':
wxSender = robot.GetWxUserInfo(message['sender'])
sender = wxSender['wxNickName'] if wxSender['wxNickName'] != 'null' else message['sender']
print("{}:{}".format(sender,message['message']))
def test_SendText():
import os
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册