-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathsendmsg.cpp
More file actions
156 lines (129 loc) · 4.21 KB
/
sendmsg.cpp
File metadata and controls
156 lines (129 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#include "stdafx.h"
#include "weixin.h"
const SuppWxCfg g_Supported_WxSendTextMsg_Version[] = {
{ TEXT("2.6.6.44"), 0x2DA4A0 ,{0}}, //voiicemsg
{ TEXT("2.6.7.40"), 0x2E3E20 ,{0}}, //voiicemsg
};
const SuppWxCfg g_Supported_WxMsgPackFree_Version[] = {
{ TEXT("2.6.6.44"), 0x4B550 ,{0}}, //voiicemsg
{ TEXT("2.6.7.40"), 0x4DC80 ,{0}}, //voiicemsg
};
const SuppWxCfg g_Supported_WxSendMsgMgrInstance_Version[] = {
{ TEXT("2.6.6.44"), 0x7D390 ,{0}}, //voiicemsg
{ TEXT("2.6.7.40"), 0x7FC90 ,{0}}, //voiicemsg
};
const SuppWxCfg g_Supported_SendImageMsg_Version[] = {
{ TEXT("2.6.6.44"), 0x2D9EA0 ,{0}}, //voiicemsg
{ TEXT("2.6.7.40"), 0x2E3810 ,{0}}, //voiicemsg
};
typedef void(__cdecl* PFN_WXSendTextMsg)(wxstring* msg, char* unk, int flag);
typedef void(__stdcall* PFN_WXMsgPackFree)();
PFN_WXSendTextMsg pfn_WxSendTextMsg = NULL;
PFN_WXMsgPackFree pfn_WxMsgPackFree = NULL;
typedef void* (__stdcall* PFN_SendMessageMgr_Instance)();
typedef void* (__stdcall* PFN_SendMessageMgr_SendImageMsg)(char* msgpack, wxstring* wxid, wxstring* imagepath);
PFN_SendMessageMgr_Instance pfn_WxSendMsgMgrInstance = NULL;
PFN_SendMessageMgr_SendImageMsg pfn_WxSendMsgMgr_SendImageMsg = NULL;
void WxSendTextMsg(wxstring* wxid, wxstring* msg)
{
char v65[0x1000] = { 0 };
char unk[0x14] = { 0 };
__asm {
lea ecx, v65;
mov edx, wxid;
}
//pfn_WxSendTextMsg(msg, unk, 1);
__asm {
push 1;
lea eax, unk;
push eax;
mov eax, msg;
push eax;
call pfn_WxSendTextMsg;
add esp, 0Ch;
}
//f_free_1004B550(&v65); // ÊÍ·ÅÄÚ´æ
/*__asm {
lea ecx, v65;
call pfn_WxMsgPackFree;
}*/
}
int InitFunction()
{
if (pfn_WxSendTextMsg == NULL)
{
HMODULE hMod = GetModuleHandleA("WechatWin.dll");
if (hMod == NULL) {
return ERROR_NOT_ALL_ASSIGNED;
}
DWORD SendTextMsgOffset = 0;
DWORD MsgFreeOffset = 0;
DWORD SendMsgMgrInstanceOffset = 0;
DWORD SendImageMsgOffset = 0;
if (!IsSupportedWxVersion(
g_Supported_WxSendTextMsg_Version,
ARRAYSIZE(g_Supported_WxSendTextMsg_Version),
&SendTextMsgOffset) ||
!IsSupportedWxVersion(
g_Supported_WxMsgPackFree_Version,
ARRAYSIZE(g_Supported_WxMsgPackFree_Version),
&MsgFreeOffset) ||
!IsSupportedWxVersion(
g_Supported_WxSendMsgMgrInstance_Version,
ARRAYSIZE(g_Supported_WxSendMsgMgrInstance_Version),
&SendMsgMgrInstanceOffset) ||
!IsSupportedWxVersion(
g_Supported_SendImageMsg_Version,
ARRAYSIZE(g_Supported_SendImageMsg_Version),
&SendImageMsgOffset))
{
return ERROR_NOT_SUPPORTED;
}
pfn_WxSendTextMsg = (PFN_WXSendTextMsg)((DWORD)hMod + SendTextMsgOffset);
pfn_WxMsgPackFree = (PFN_WXMsgPackFree)((DWORD)hMod + MsgFreeOffset);
pfn_WxSendMsgMgrInstance = (PFN_SendMessageMgr_Instance)((DWORD)hMod + SendMsgMgrInstanceOffset);
pfn_WxSendMsgMgr_SendImageMsg = (PFN_SendMessageMgr_SendImageMsg)((DWORD)hMod + SendImageMsgOffset);
}
return ERROR_SUCCESS;
}
int CoreSendTxtMsg(WCHAR* wxid, WCHAR* msg)
{
int ret = InitFunction();
if (ret != ERROR_SUCCESS) {
return ret;
}
wxstring pmsg;
wxstring pwxid;
pwxid.buf = wxid;
pwxid.len = wcslen(wxid);
pwxid.maxlen = wcslen(wxid) + 2;
pmsg.buf = msg;
pmsg.len = wcslen(msg);
pmsg.maxlen = wcslen(msg) + 2;
WxSendTextMsg(&pwxid, &pmsg);
return ret;
}
//˽ÓÐ
int CoreSendImageMsg(WCHAR* wxid, WCHAR* path)
{
int ret = InitFunction();
if (ret != ERROR_SUCCESS) {
return ret;
}
/*wxstring pimage;
wxstring pwxid;
char msgpack[0x1000] = { 0 };
pwxid.buf = wxid;
pwxid.len = wcslen(wxid);
pwxid.maxlen = wcslen(wxid) + 2;
pimage.buf = path;
pimage.len = wcslen(path);
pimage.maxlen = wcslen(path) + 2;
void* p = pfn_WxSendMsgMgrInstance();
if (p)
{
__asm mov ecx, p;
pfn_WxSendMsgMgr_SendImageMsg(msgpack, &pwxid, &pimage);
}*/
return ret;
}