Refactor SendTextMessage and SendImageMessage
This commit is contained in:
parent
d6633c3aed
commit
ffbef43d60
@ -170,7 +170,7 @@ bool func_send_txt(TextMsg txt, uint8_t *out, size_t *len)
|
|||||||
string receiver(txt.receiver);
|
string receiver(txt.receiver);
|
||||||
string aters(txt.aters ? txt.aters : "");
|
string aters(txt.aters ? txt.aters : "");
|
||||||
|
|
||||||
SendTextMessage(String2Wstring(receiver), String2Wstring(msg), String2Wstring(aters));
|
SendTextMessage(receiver, msg, aters);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb_ostream_t stream = pb_ostream_from_buffer(out, *len);
|
pb_ostream_t stream = pb_ostream_from_buffer(out, *len);
|
||||||
@ -193,7 +193,7 @@ bool func_send_img(char *path, char *receiver, uint8_t *out, size_t *len)
|
|||||||
if ((path == NULL) || (receiver == NULL)) {
|
if ((path == NULL) || (receiver == NULL)) {
|
||||||
rsp.msg.status = -1;
|
rsp.msg.status = -1;
|
||||||
} else {
|
} else {
|
||||||
SendImageMessage(String2Wstring(receiver), String2Wstring(path));
|
SendImageMessage(receiver, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb_ostream_t stream = pb_ostream_from_buffer(out, *len);
|
pb_ostream_t stream = pb_ostream_from_buffer(out, *len);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include <sstream>
|
#include "framework.h"
|
||||||
#include <string>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "send_msg.h"
|
#include "send_msg.h"
|
||||||
#include "spy_types.h"
|
#include "spy_types.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
extern HANDLE g_hEvent;
|
extern HANDLE g_hEvent;
|
||||||
extern WxCalls_t g_WxCalls;
|
extern WxCalls_t g_WxCalls;
|
||||||
@ -15,7 +16,7 @@ typedef struct AtList {
|
|||||||
DWORD end2;
|
DWORD end2;
|
||||||
} AtList_t;
|
} AtList_t;
|
||||||
|
|
||||||
void SendTextMessage(wstring wxid, wstring msg, wstring atWxids)
|
void SendTextMessage(string wxid, string msg, string atWxids)
|
||||||
{
|
{
|
||||||
char buffer[0x3B0] = { 0 };
|
char buffer[0x3B0] = { 0 };
|
||||||
AtList_t atList = { 0 };
|
AtList_t atList = { 0 };
|
||||||
@ -26,17 +27,20 @@ void SendTextMessage(wstring wxid, wstring msg, wstring atWxids)
|
|||||||
// 发送消息Call地址 = 微信基址 + 偏移
|
// 发送消息Call地址 = 微信基址 + 偏移
|
||||||
DWORD sendCallAddress = g_WeChatWinDllAddr + g_WxCalls.sendTextMsg;
|
DWORD sendCallAddress = g_WeChatWinDllAddr + g_WxCalls.sendTextMsg;
|
||||||
|
|
||||||
txtMsg.text = (wchar_t *)msg.c_str();
|
wstring wsWxid = String2Wstring(wxid);
|
||||||
txtMsg.size = msg.size();
|
wstring wsMsg = String2Wstring(msg);
|
||||||
txtMsg.capacity = msg.capacity();
|
|
||||||
|
|
||||||
txtWxid.text = (wchar_t *)wxid.c_str();
|
txtMsg.text = (wchar_t *)wsMsg.c_str();
|
||||||
txtWxid.size = wxid.size();
|
txtMsg.size = wsMsg.size();
|
||||||
txtWxid.capacity = wxid.capacity();
|
txtMsg.capacity = wsMsg.capacity();
|
||||||
|
|
||||||
wstring tmp = atWxids;
|
txtWxid.text = (wchar_t *)wsWxid.c_str();
|
||||||
if (!tmp.empty()) {
|
txtWxid.size = wsWxid.size();
|
||||||
int i = 0;
|
txtWxid.capacity = wsWxid.capacity();
|
||||||
|
|
||||||
|
if (!atWxids.empty()) {
|
||||||
|
int i = 0;
|
||||||
|
wstring tmp = String2Wstring(atWxids);
|
||||||
wstring wstr;
|
wstring wstr;
|
||||||
vector<wstring> vAtWxids;
|
vector<wstring> vAtWxids;
|
||||||
wstringstream wss(tmp);
|
wstringstream wss(tmp);
|
||||||
@ -78,7 +82,7 @@ void SendTextMessage(wstring wxid, wstring msg, wstring atWxids)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendImageMessage(wstring wxid, wstring path)
|
void SendImageMessage(string wxid, string path)
|
||||||
{
|
{
|
||||||
if (g_WeChatWinDllAddr == 0) {
|
if (g_WeChatWinDllAddr == 0) {
|
||||||
return;
|
return;
|
||||||
@ -89,13 +93,16 @@ void SendImageMessage(wstring wxid, wstring path)
|
|||||||
TextStruct_t imgWxid = { 0 };
|
TextStruct_t imgWxid = { 0 };
|
||||||
TextStruct_t imgPath = { 0 };
|
TextStruct_t imgPath = { 0 };
|
||||||
|
|
||||||
imgWxid.text = (wchar_t *)wxid.c_str();
|
wstring wsWxid = String2Wstring(wxid);
|
||||||
imgWxid.size = wxid.size();
|
wstring wspath = String2Wstring(path);
|
||||||
imgWxid.capacity = wxid.capacity();
|
|
||||||
|
|
||||||
imgPath.text = (wchar_t *)path.c_str();
|
imgWxid.text = (wchar_t *)wsWxid.c_str();
|
||||||
imgPath.size = path.size();
|
imgWxid.size = wsWxid.size();
|
||||||
imgPath.capacity = path.capacity();
|
imgWxid.capacity = wsWxid.capacity();
|
||||||
|
|
||||||
|
imgPath.text = (wchar_t *)wspath.c_str();
|
||||||
|
imgPath.size = wspath.size();
|
||||||
|
imgPath.capacity = wspath.capacity();
|
||||||
|
|
||||||
// 发送图片Call地址 = 微信基址 + 偏移
|
// 发送图片Call地址 = 微信基址 + 偏移
|
||||||
DWORD sendCall1 = g_WeChatWinDllAddr + g_WxCalls.sendImg.call1;
|
DWORD sendCall1 = g_WeChatWinDllAddr + g_WxCalls.sendImg.call1;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "framework.h"
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void SendTextMessage(wstring wxid, wstring msg, wstring atWxids);
|
void SendTextMessage(string wxid, string msg, string atWxids);
|
||||||
void SendImageMessage(wstring wxid, wstring path);
|
void SendImageMessage(string wxid, string path);
|
||||||
|
Loading…
Reference in New Issue
Block a user