SendImage.cpp 2.0 KB
Newer Older
L
ljc545w 已提交
1 2
#include "pch.h"

L
ljc545w 已提交
3
// 发送图片CALL1偏移
L
ljc545w 已提交
4
#define SendImageCall1Offset (0x7875D780 - 0x786A0000)
L
ljc545w 已提交
5
// 发送图片CALL2偏移
L
ljc545w 已提交
6
#define SendImageCall2Offset (0x78E11980 - 0x786A0000)
L
ljc545w 已提交
7
// 发送图片CALL3偏移
L
ljc545w 已提交
8
#define SendImageCall3Offset (0x78BC1640 - 0x786A0000)
L
ljc545w 已提交
9
// 清空缓存的CALL偏移
L
ljc545w 已提交
10
#define DeleteSendImageCacheCallOffset (0x78757780 - 0x786A0000)
L
ljc545w 已提交
11

L
ljc545w 已提交
12
/*
L
ljc545w 已提交
13 14 15 16
 * 外部调用时传递的参数结构
 * wxid:保存wxid的地址
 * imagepath:保存图片绝对路径的地址
 */
17
#ifndef USE_SOCKET
L
ljc545w 已提交
18 19 20 21
struct ImageParamStruct
{
    DWORD wxid;
    DWORD imagepath;
L
ljc545w 已提交
22
};
23
#endif
L
ljc545w 已提交
24

L
ljc545w 已提交
25
/*
L
ljc545w 已提交
26 27 28 29
 * 供外部调用的发送图片消息接口
 * lpParamStruct:ImageParamStruct类型结构体指针
 * return:void
 */
30
#ifndef USE_SOCKET
L
ljc545w 已提交
31 32 33 34
void SendImageRemote(LPVOID lpParamStruct)
{
    ImageParamStruct *params = (ImageParamStruct *)lpParamStruct;
    SendImage((WCHAR *)params->wxid, (WCHAR *)params->imagepath);
L
ljc545w 已提交
35
}
36
#endif
L
ljc545w 已提交
37

L
ljc545w 已提交
38
/*
L
ljc545w 已提交
39 40 41 42 43 44
 * 发送图片消息的具体实现
 * receiver:接收人wxid
 * ImagePath:图片绝对路径
 * return:BOOL,发送成功返回`1`,发送失败返回`0`
 */
BOOL __stdcall SendImage(wchar_t *receiver, wchar_t *ImagePath)
L
ljc545w 已提交
45 46 47 48 49 50 51 52 53 54 55 56
{
    DWORD WeChatWinBase = GetWeChatWinBase();
    DWORD SendImageCall1 = WeChatWinBase + SendImageCall1Offset;
    DWORD SendImageCall2 = WeChatWinBase + SendImageCall2Offset;
    DWORD SendImageCall3 = WeChatWinBase + SendImageCall3Offset;
    DWORD DeleteSendImageCacheCall = WeChatWinBase + DeleteSendImageCacheCallOffset;
    char nullbuffer[0x50] = {0};
    char buffer[0x3B0] = {0};
    WxString pReceiver(receiver);
    WxString pImagePath(ImagePath);
    WxString nullStruct = {0};
    DWORD tempeax = 0;
L
ljc545w 已提交
57
    int isSuccess = 0;
L
ljc545w 已提交
58
    __asm {
L
ljc545w 已提交
59 60 61
		pushad;
		call SendImageCall1;
		sub esp, 0x14;
L
ljc545w 已提交
62
		mov tempeax, eax;
L
ljc545w 已提交
63 64 65 66 67
		lea eax, nullStruct;
		mov ecx, esp;
		lea edi, pImagePath;
		push eax;
		call SendImageCall2;
L
ljc545w 已提交
68
		mov ecx, dword ptr [tempeax] ;
L
ljc545w 已提交
69 70 71 72 73 74
		lea eax, pReceiver;
		push edi;
		push eax;
		lea eax, buffer;
		push eax;
		call SendImageCall3;
L
ljc545w 已提交
75
		mov isSuccess,eax;
L
ljc545w 已提交
76 77 78
		lea ecx, buffer;
		call DeleteSendImageCacheCall;
		popad;
L
ljc545w 已提交
79
    }
L
ljc545w 已提交
80
    return isSuccess == 1;
L
ljc545w 已提交
81
}