SendArticle.cpp 5.3 KB
Newer Older
G
Gogs 已提交
1 2
#include "pch.h"

L
ljc545w 已提交
3
// 发送文章CALL1偏移
L
ljc545w 已提交
4
#define SendArticleCall1Offset 0x78758A70 - 0x786A0000
L
ljc545w 已提交
5
// 发送文章CALL2偏移
L
ljc545w 已提交
6
#define SendArticleCall2Offset 0x78A8D5E0 - 0x786A0000
L
ljc545w 已提交
7
// 发送文章CALL3偏移
L
ljc545w 已提交
8
#define SendArticleCall3Offset 0x787A7F00 - 0x786A0000
L
ljc545w 已提交
9
// 发送文章CALL4偏移
L
ljc545w 已提交
10
#define SendArticleCall4Offset 0x78A8D7B0 - 0x786A0000
L
ljc545w 已提交
11
// 发送文章CALL参数偏移
L
ljc545w 已提交
12 13 14
#define SendArticleParamOffset 0x7AA26FE4 - 0x786A0000
// 个人WXID偏移
#define SelfWxidAddrOffset 0x236607C
G
Gogs 已提交
15

L
ljc545w 已提交
16
// 清空缓存CALL1偏移
L
ljc545w 已提交
17
#define SendArticleClearCacheCall1Offset 0x78D46450 - 0x786A0000
L
ljc545w 已提交
18
// 清空缓存CALL2偏移
L
ljc545w 已提交
19
#define SendArticleClearCacheCall2Offset 0x78757780 - 0x786A0000
G
Gogs 已提交
20

L
ljc545w 已提交
21 22 23 24 25 26 27
/*
* 外部调用时传递的参数结构
* wxid:接收人的保存地址
* title:文章标题的保存地址
* abstract:文章摘要的保存地址
* url:文章链接的保存地址
*/
28
#ifndef USE_SOCKET
G
Gogs 已提交
29
struct SendArticleStruct {
L
ljc545w 已提交
30
	DWORD wxid;
G
Gogs 已提交
31 32 33
	DWORD title;
	DWORD abstract;
	DWORD url;
L
ljc545w 已提交
34
	DWORD imgpath;
G
Gogs 已提交
35
};
36
#endif
G
Gogs 已提交
37

L
ljc545w 已提交
38 39 40 41 42
/*
* 供外部调用的发送文章消息接口
* lparameter:SendArticleStruct类型结构体指针
* return:void
*/
43
#ifndef USE_SOCKET
L
ljc545w 已提交
44 45 46 47 48 49
VOID SendArticleRemote(LPVOID lparameter) {
	SendArticleStruct* sas = (SendArticleStruct*)lparameter;
	wchar_t* wxid = (wchar_t*)sas->wxid;
	wchar_t* title = (wchar_t*)sas->title;
	wchar_t* abstract = (wchar_t*)sas->abstract;
	wchar_t* url = (wchar_t*)sas->url;
L
ljc545w 已提交
50 51
	wchar_t* imgpath = sas->imgpath ? (wchar_t*)sas->imgpath : NULL;
	SendArticle(wxid,title,abstract,url, imgpath);
L
ljc545w 已提交
52
}
53
#endif
G
Gogs 已提交
54

L
ljc545w 已提交
55 56 57 58
/*
* 获取自己的wxid保存地址
* return:DWORD,个人wxid保存地址
*/
59
DWORD GetSelfWxIdAddr() {
L
ljc545w 已提交
60
	DWORD baseAddr = GetWeChatWinBase() + SelfWxidAddrOffset;
61 62 63 64 65 66 67 68 69 70 71 72 73 74
	char wxidbuffer[0x100] = { 0 };
	DWORD SelfWxIdAddr = 0x0;
	sprintf_s(wxidbuffer, "%s", (char*)baseAddr);
	if (strlen(wxidbuffer) < 0x6 || strlen(wxidbuffer) > 0x14)
	{
		SelfWxIdAddr = *(DWORD*)baseAddr;
	}
	else
	{
		SelfWxIdAddr = baseAddr;
	}
	return SelfWxIdAddr;
}

L
ljc545w 已提交
75 76 77 78 79 80 81 82
/*
* 发送文章消息的具体实现
* wxid:消息接收人wxid
* title:文章标题
* abstract:文章摘要
* url:文章链接
* return:BOOL,成功返回`1`,失败返回`0`
*/
L
ljc545w 已提交
83
BOOL __stdcall SendArticle(wchar_t* wxid,wchar_t* title, wchar_t* abstract, wchar_t* url,wchar_t* imgpath) {
L
ljc545w 已提交
84
	DWORD WeChatWinBase = GetWeChatWinBase();
G
Gogs 已提交
85 86 87 88
	DWORD SendArticleCall1 = WeChatWinBase + SendArticleCall1Offset;
	DWORD SendArticleCall2 = WeChatWinBase + SendArticleCall2Offset;
	DWORD SendArticleCall3 = WeChatWinBase + SendArticleCall3Offset;
	DWORD SendArticleCall4 = WeChatWinBase + SendArticleCall4Offset;
G
Gogs 已提交
89

G
Gogs 已提交
90
	DWORD SendArticleParam = WeChatWinBase + SendArticleParamOffset;
G
Gogs 已提交
91

G
Gogs 已提交
92 93
	DWORD SendArticleClearCacheCall1 = WeChatWinBase + SendArticleClearCacheCall1Offset;
	DWORD SendArticleClearCacheCall2 = WeChatWinBase + SendArticleClearCacheCall2Offset;
L
ljc545w 已提交
94
	// 自己的wxid,发送者
95
	char* sselfwxid = (char*)GetSelfWxIdAddr();
G
Gogs 已提交
96
	wchar_t* wselfwxid = new wchar_t[strlen(sselfwxid) + 1];
L
ljc545w 已提交
97
	MultiByteToWideChar(CP_ACP, 0, sselfwxid, -1, wselfwxid, strlen(sselfwxid) + 1);
L
ljc545w 已提交
98
	// 构造xml数据
G
Gogs 已提交
99 100 101 102
	wchar_t* xmlbuffer = new wchar_t[0x2000];
	ZeroMemory(xmlbuffer, 0x2000 * 2);
	swprintf_s(xmlbuffer,0x2000, (wchar_t*)L"<msg>\n    <fromusername>%ws</fromusername>\n    <scene>0</scene>\n    <commenturl></commenturl>\n    <appmsg appid=\"\" sdkver=\"0\">\n        <title>%ws</title>\n        <des>%ws</des>\n        <action>view</action>\n        <type>5</type>\n        <showtype>0</showtype>\n        <content></content>\n        <url>%ws</url>\n        <dataurl></dataurl>\n        <lowurl></lowurl>\n        <lowdataurl></lowdataurl>\n        <recorditem>\n            <![CDATA[]]>\n        </recorditem>\n        <thumburl></thumburl>\n        <messageaction></messageaction>\n        <extinfo></extinfo>\n        <sourceusername></sourceusername>\n        <sourcedisplayname></sourcedisplayname>\n        <commenturl></commenturl>\n        <appattach>\n            <totallen>0</totallen>\n            <attachid></attachid>\n            <emoticonmd5></emoticonmd5>\n            <fileext></fileext>\n            <aeskey></aeskey>\n        </appattach>\n        <weappinfo>\n            <pagepath></pagepath>\n            <username></username>\n            <appid></appid>\n            <appservicetype>0</appservicetype>\n        </weappinfo>\n        <websearch />\n    </appmsg>\n    <appinfo>\n        <version>1</version>\n        <appname>Window wechat</appname>\n    </appinfo>\n</msg>",
		wselfwxid,title,abstract,url);
L
ljc545w 已提交
103

G
Gogs 已提交
104
	DWORD sendtype = 0x5;
L
ljc545w 已提交
105
	WxBaseStruct pSender(wselfwxid);
G
Gogs 已提交
106
	char nullbuffer[0x1C] = { 0 };
L
ljc545w 已提交
107 108 109
	WxBaseStruct pXml(xmlbuffer);
	WxBaseStruct pReceiver(wxid);
	WxString imgbuffer = { 0 };
L
ljc545w 已提交
110 111 112 113 114
	if (imgpath) {
		imgbuffer.buffer = imgpath;
		imgbuffer.length = wcslen(imgpath);
		imgbuffer.maxLength = wcslen(imgpath) * 2;
	}
L
ljc545w 已提交
115
	WxString nullStruct = { 0 };
L
ljc545w 已提交
116
	char buffer[0xFF0] = { 0 };
G
Gogs 已提交
117 118 119 120
	DWORD isSuccess = 0x0;
	__asm {
		pushad;
		pushfd;
L
ljc545w 已提交
121 122
		lea ecx, buffer;
		call SendArticleCall1;
G
Gogs 已提交
123 124 125 126 127 128 129 130 131 132 133 134
		mov eax, [sendtype];
		push eax;
		lea eax, nullbuffer;
		lea edx, pSender;
		push eax;
		lea eax, imgbuffer;
		push eax;
		lea eax, pXml;
		push eax;
		lea edi, pReceiver;
		push edi;
		lea ecx, buffer;
L
ljc545w 已提交
135
		call SendArticleCall2;
G
Gogs 已提交
136
		add esp, 0x14;
L
ljc545w 已提交
137 138 139 140 141 142 143 144 145
		lea eax, nullStruct;
		push eax;
		lea ecx, buffer;
		call SendArticleCall3;
		mov dl, 0x0;
		lea ecx, buffer;
		push SendArticleParam;
		push SendArticleParam;
		call SendArticleCall4;
G
Gogs 已提交
146
		mov isSuccess, eax;
L
ljc545w 已提交
147 148 149 150 151
		add esp, 0x8;
		lea ecx, buffer;
		call SendArticleClearCacheCall1;
		lea ecx, buffer;
		call SendArticleClearCacheCall2;
G
Gogs 已提交
152 153 154 155 156 157 158
		popfd;
		popad;
	}
	delete[] xmlbuffer;
	xmlbuffer = NULL;
	delete[] wselfwxid;
	wselfwxid = NULL;
L
ljc545w 已提交
159
	return (isSuccess == 0x1);
G
Gogs 已提交
160
}