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

L
ljc545w 已提交
3
// 发送文章CALL1偏移
L
ljc545w 已提交
4
#define SendArticleCall1Offset 0x54328A10 - 0x54270000
L
ljc545w 已提交
5
// 发送文章CALL2偏移
L
ljc545w 已提交
6
#define SendArticleCall2Offset 0x5465D5E0 - 0x54270000
L
ljc545w 已提交
7
// 发送文章CALL3偏移
L
ljc545w 已提交
8
#define SendArticleCall3Offset 0x54377EB0 - 0x54270000
L
ljc545w 已提交
9
// 发送文章CALL4偏移
L
ljc545w 已提交
10
#define SendArticleCall4Offset 0x5465D7B0 - 0x54270000
L
ljc545w 已提交
11
// 发送文章CALL参数偏移
L
ljc545w 已提交
12
#define SendArticleParamOffset 0x565F3FE4 - 0x54270000
G
Gogs 已提交
13

L
ljc545w 已提交
14
// 清空缓存CALL1偏移
L
ljc545w 已提交
15
#define SendArticleClearCacheCall1Offset 0x54916450 - 0x54270000
L
ljc545w 已提交
16
// 清空缓存CALL2偏移
L
ljc545w 已提交
17
#define SendArticleClearCacheCall2Offset 0x54327720 - 0x54270000
G
Gogs 已提交
18

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

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

L
ljc545w 已提交
53 54 55 56
/*
* 获取自己的wxid保存地址
* return:DWORD,个人wxid保存地址
*/
57
DWORD GetSelfWxIdAddr() {
L
ljc545w 已提交
58
	DWORD baseAddr = GetWeChatWinBase() + 0x236307C;
59 60 61 62 63 64 65 66 67 68 69 70 71 72
	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 已提交
73 74 75 76 77 78 79 80
/*
* 发送文章消息的具体实现
* wxid:消息接收人wxid
* title:文章标题
* abstract:文章摘要
* url:文章链接
* return:BOOL,成功返回`1`,失败返回`0`
*/
L
ljc545w 已提交
81
BOOL __stdcall SendArticle(wchar_t* wxid,wchar_t* title, wchar_t* abstract, wchar_t* url,wchar_t* imgpath) {
L
ljc545w 已提交
82
	DWORD WeChatWinBase = GetWeChatWinBase();
G
Gogs 已提交
83 84 85 86
	DWORD SendArticleCall1 = WeChatWinBase + SendArticleCall1Offset;
	DWORD SendArticleCall2 = WeChatWinBase + SendArticleCall2Offset;
	DWORD SendArticleCall3 = WeChatWinBase + SendArticleCall3Offset;
	DWORD SendArticleCall4 = WeChatWinBase + SendArticleCall4Offset;
G
Gogs 已提交
87

G
Gogs 已提交
88
	DWORD SendArticleParam = WeChatWinBase + SendArticleParamOffset;
G
Gogs 已提交
89

G
Gogs 已提交
90 91
	DWORD SendArticleClearCacheCall1 = WeChatWinBase + SendArticleClearCacheCall1Offset;
	DWORD SendArticleClearCacheCall2 = WeChatWinBase + SendArticleClearCacheCall2Offset;
L
ljc545w 已提交
92
	// 自己的wxid,发送者
93
	char* sselfwxid = (char*)GetSelfWxIdAddr();
G
Gogs 已提交
94
	wchar_t* wselfwxid = new wchar_t[strlen(sselfwxid) + 1];
L
ljc545w 已提交
95
	MultiByteToWideChar(CP_ACP, 0, sselfwxid, -1, wselfwxid, strlen(sselfwxid) + 1);
L
ljc545w 已提交
96
	// 构造xml数据
G
Gogs 已提交
97 98 99 100
	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 已提交
101

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