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

L
ljc545w 已提交
3
// 发送名片的CALL偏移
L
ljc545w 已提交
4
#define SendCardCallOffset 0x78BC1D30 - 0x786A0000
L
ljc545w 已提交
5
// 清空缓存的CALL偏移
L
ljc545w 已提交
6
#define DeleteCardCacheCallOffset 0x78757780 - 0x786A0000
G
Gogs 已提交
7

L
ljc545w 已提交
8
/*
L
ljc545w 已提交
9 10 11 12 13
 * 外部调用时提供的参数结构
 * receiver:名片消息接收人wxid保存地址
 * sharedwxid:被推荐人的wxid保存地址
 * nickname:名片显示的昵称保存地址
 */
14
#ifndef USE_SOCKET
L
ljc545w 已提交
15 16 17 18 19
struct SendCardStruct
{
    DWORD receiver;
    DWORD sharedwxid;
    DWORD nickname;
G
Gogs 已提交
20
};
21
#endif
G
Gogs 已提交
22

L
ljc545w 已提交
23
/*
L
ljc545w 已提交
24 25 26 27
 * 供外部调用的发送名片接口
 * lparameter:SendCardStruct类型结构体指针
 * return:void
 */
28
#ifndef USE_SOCKET
L
ljc545w 已提交
29 30 31 32 33 34 35
VOID SendCardRemote(LPVOID lparameter)
{
    SendCardStruct *scs = (SendCardStruct *)lparameter;
    wchar_t *receiver = (WCHAR *)scs->receiver;
    wchar_t *sharedwxid = (WCHAR *)scs->sharedwxid;
    wchar_t *nickname = (WCHAR *)scs->nickname;
    SendCard(receiver, sharedwxid, nickname);
G
Gogs 已提交
36
}
37
#endif
G
Gogs 已提交
38

L
ljc545w 已提交
39
/*
L
ljc545w 已提交
40 41 42 43 44 45
 * 发送名片消息的具体实现
 * receiver:消息接收人wxid
 * sharedwxid:被推荐人wxid
 * nickname:名片显示的昵称
 * return:BOOL,发送成功返回`1`,发送失败返回`0`
 */
L
ljc545w 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58
BOOL __stdcall SendCard(wchar_t *receiver, wchar_t *sharedwxid, wchar_t *nickname)
{
    DWORD WeChatWinBase = GetWeChatWinBase();
    DWORD SendCardCall = WeChatWinBase + SendCardCallOffset;
    DWORD DeleteCardCacheCall = WeChatWinBase + DeleteCardCacheCallOffset;
    wchar_t *xml = new wchar_t[0x2000];
    ZeroMemory(xml, 0x2000 * 2);
    swprintf_s(xml, 0x2000, L"<?xml version=\"1.0\"?><msg bigheadimgurl=\"\" smallheadimgurl=\"\" username=\"%ws\" nickname=\"%ws\" fullpy=\"?\" shortpy=\"\" alias=\"%ws\" imagestatus=\"3\" scene=\"17\" province=\"北京\" city=\"中国\" sign=\"\" sex=\"2\" certflag=\"0\" certinfo=\"\" brandIconUrl=\"\" brandHomeUrl=\"\" brandSubscriptConfigUrl= \"\" brandFlags=\"0\" regionCode=\"CN_BeiJing_BeiJing\" />",
               sharedwxid, nickname, sharedwxid);
    WxString pReceiver(receiver);
    WxString pXml(xml);
    char buffer[0x2D0] = {0};
    DWORD isSuccess = 0x1;
G
Gogs 已提交
59

L
ljc545w 已提交
60
    __asm {
G
Gogs 已提交
61 62 63 64 65 66 67 68 69 70 71
		pushad;
		push 0x2A;
		lea eax, pXml;
		lea edx, pReceiver;
		push 0x0;
		push eax;
		lea ecx, buffer;
		call SendCardCall;
		add esp, 0xC;
		lea ecx, buffer;
		call DeleteCardCacheCall;
L
ljc545w 已提交
72
        mov isSuccess, eax;
G
Gogs 已提交
73
		popad;
L
ljc545w 已提交
74 75 76
    }
    delete[] xml;
    xml = NULL;
L
ljc545w 已提交
77
    return isSuccess == 0;
L
ljc545w 已提交
78
}