SendEmotion.cpp 942 字节
Newer Older
L
ljc545w 已提交
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
#include "pch.h"

struct SendEmotionStruct
{
    DWORD wxid;
    DWORD img_path;
};

int SendEmotion(DWORD pid, wchar_t *wxid, wchar_t *img_path)
{
    WeChatProcess hp(pid);
    if (!hp.m_init)
        return 1;
    DWORD SendEmitonRemoteAddr = hp.GetProcAddr(SendEmotionRemote);
    if (SendEmitonRemoteAddr == 0)
    {
        return 1;
    }
    SendEmotionStruct params = {0};
    WeChatData<wchar_t *> r_wxid(hp.GetHandle(), wxid, TEXTLENGTH(wxid));
    WeChatData<wchar_t *> r_img_path(hp.GetHandle(), img_path, TEXTLENGTH(img_path));

    params.wxid = (DWORD)r_wxid.GetAddr();
    params.img_path = (DWORD)r_img_path.GetAddr();
    WeChatData<SendEmotionStruct *> r_params(hp.GetHandle(), &params, sizeof(params));
    if (!params.wxid || !params.img_path || !r_params.GetAddr())
    {
        return 1;
    }
    DWORD dwRet = CallRemoteFunction(hp.GetHandle(), SendEmitonRemoteAddr, r_params.GetAddr());
    return (dwRet != 1);
}