Skip to content

Commit

Permalink
添加新的支持
Browse files Browse the repository at this point in the history
  • Loading branch information
ljc545w committed Nov 2, 2022
1 parent 2369f90 commit d3c5e60
Show file tree
Hide file tree
Showing 34 changed files with 941 additions and 116 deletions.
28 changes: 28 additions & 0 deletions CWeChatRobot/GetMsgCDN.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "pch.h"

wstring GetMsgCND(DWORD pid, ULONG64 msgid)
{
WeChatProcess hp(pid);
if (!hp.m_init)
return L"";
DWORD GetMsgCDNRemoteAddr = hp.GetProcAddr(GetMsgCDNRemote);
if (GetMsgCDNRemoteAddr == 0)
{
return L"";
}
WeChatData<ULONG64 *> r_msgid(hp.GetHandle(), &msgid, sizeof(ULONG64));
if (!r_msgid.GetAddr())
{
return L"";
}
DWORD dwRet = CallRemoteFunction(hp.GetHandle(), GetMsgCDNRemoteAddr, r_msgid.GetAddr());
if (dwRet == 0)
return L"";
DWORD get_cdn_resp[2] = {0};
ReadProcessMemory(hp.GetHandle(), (LPVOID)dwRet, &get_cdn_resp, sizeof(get_cdn_resp), 0);
if (!get_cdn_resp[0] || !get_cdn_resp[1])
return L"";
unique_ptr<wchar_t[]> path_buf = make_unique<wchar_t[]>(get_cdn_resp[1] + 1);
ReadProcessMemory(hp.GetHandle(), (LPVOID)get_cdn_resp[0], path_buf.get(), get_cdn_resp[1] * 2, 0);
return wstring(path_buf.get(), get_cdn_resp[1]);
}
13 changes: 8 additions & 5 deletions CWeChatRobot/ReceiveMessage.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#pragma once
#include<windows.h>
BOOL StartReceiveMessage(DWORD pid,int port);
#include <windows.h>
#include <iostream>
using namespace std;
BOOL StartReceiveMessage(DWORD pid, int port);
BOOL StopReceiveMessage(DWORD pid);

BOOL HookImageMsg(DWORD pid,wchar_t* savepath);
BOOL HookVoiceMsg(DWORD pid,wchar_t* savepath);
BOOL HookImageMsg(DWORD pid, wchar_t *savepath);
BOOL HookVoiceMsg(DWORD pid, wchar_t *savepath);
void UnHookImageMsg(DWORD pid);
void UnHookVoiceMsg(DWORD pid);
void UnHookVoiceMsg(DWORD pid);
wstring GetMsgCND(DWORD pid, ULONG64 msgid);
32 changes: 32 additions & 0 deletions CWeChatRobot/SendEmotion.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
}
4 changes: 4 additions & 0 deletions CWeChatRobot/SendEmotion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#include <windows.h>

int SendEmotion(DWORD pid, wchar_t *wxid, wchar_t *img_path);
24 changes: 24 additions & 0 deletions CWeChatRobot/WeChatRobot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,3 +626,27 @@ STDMETHODIMP CWeChatRobot::CGetTransfer(DWORD pid, BSTR wxid, BSTR transcationid
*__result = GetTransfer(pid, wxid, transcationid, transferid);
return S_OK;
}

/*
* 参数0:目标进程pid
* 参数1:接收人wxid
* 参数2:表情绝对路径
* 参数3:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CSendEmotion(DWORD pid, BSTR wxid, BSTR img_path, int *__result)
{
*__result = SendEmotion(pid, wxid, img_path);
return S_OK;
}

/*
* 参数0:目标进程pid
* 参数1:消息id
* 参数2:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CGetMsgCDN(DWORD pid, ULONG64 msgid, BSTR *__result)
{
_bstr_t path = (_bstr_t)GetMsgCND(pid, msgid).c_str();
*__result = path;
return S_OK;
}
2 changes: 2 additions & 0 deletions CWeChatRobot/WeChatRobot.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class ATL_NO_VTABLE CWeChatRobot : public CComObjectRootEx<CComSingleThreadModel
STDMETHODIMP CSendXmlMsg(DWORD pid, BSTR wxid, BSTR xml, BSTR imgpath, int *__result);
STDMETHODIMP CLogout(DWORD pid, int *__result);
STDMETHODIMP CGetTransfer(DWORD pid, BSTR wxid, BSTR transcationid, BSTR transferid, int *__result);
STDMETHODIMP CSendEmotion(DWORD pid, BSTR wxid, BSTR img_path, int *__result);
STDMETHODIMP CWeChatRobot::CGetMsgCDN(DWORD pid, ULONG64 msgid, BSTR *__result);
};

OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot)
2 changes: 2 additions & 0 deletions CWeChatRobot/WeChatRobotCOM.idl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ interface IWeChatRobot : IDispatch
[id(51), helpstring("发送xml消息")] HRESULT CSendXmlMsg([in] DWORD pid, [in] BSTR wxid, [in] BSTR xml, [in] BSTR imgpath,[out, retval] int *__result);
[id(52), helpstring("退出登录")] HRESULT CLogout([in] DWORD pid,[out, retval] int *__result);
[id(53), helpstring("收款")] HRESULT CGetTransfer([in] DWORD pid, [in] BSTR wxid, [in] BSTR transcationid, [in] BSTR transferid, [out, retval] int *__result);
[id(54), helpstring("发送表情")] HRESULT CSendEmotion([in] DWORD pid, [in] BSTR wxid, [in] BSTR img_path, [ out, retval ] int *__result);
[id(55), helpstring("获取CDN")] HRESULT CGetMsgCDN([in] DWORD pid, [in] ULONG64 msgid, [ out, retval ] BSTR *__result);
};
[
object,
Expand Down
3 changes: 3 additions & 0 deletions CWeChatRobot/WeChatRobotCOM.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
<ClInclude Include="SendArticle.h" />
<ClInclude Include="SendAtText.h" />
<ClInclude Include="SendCard.h" />
<ClInclude Include="SendEmotion.h" />
<ClInclude Include="SendFile.h" />
<ClInclude Include="SendImage.h" />
<ClInclude Include="SendText.h" />
Expand Down Expand Up @@ -289,6 +290,7 @@
<ClCompile Include="GetChatRoomMembers.cpp" />
<ClCompile Include="GetDbHandles.cpp" />
<ClCompile Include="GetHistoryPublicMsg.cpp" />
<ClCompile Include="GetMsgCDN.cpp" />
<ClCompile Include="GetTransfer.cpp" />
<ClCompile Include="HookImageMessage.cpp" />
<ClCompile Include="HookVoiceMessage.cpp" />
Expand All @@ -311,6 +313,7 @@
<ClCompile Include="SendArticle.cpp" />
<ClCompile Include="SendAtText.cpp" />
<ClCompile Include="SendCard.cpp" />
<ClCompile Include="SendEmotion.cpp" />
<ClCompile Include="SendFile.cpp" />
<ClCompile Include="SendImage.cpp" />
<ClCompile Include="SendText.cpp" />
Expand Down
12 changes: 12 additions & 0 deletions CWeChatRobot/WeChatRobotCOM.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@
<Filter Include="未分类\收款">
<UniqueIdentifier>{79bb1058-041b-4bdc-8678-0369c294e570}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送表情">
<UniqueIdentifier>{75c46b26-c4df-4772-862b-839be6a2bf95}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
Expand Down Expand Up @@ -298,6 +301,9 @@
<ClInclude Include="GetTransfer.h">
<Filter>未分类\收款</Filter>
</ClInclude>
<ClInclude Include="SendEmotion.h">
<Filter>发送消息\发送表情</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WeChatRobotCOM.cpp">
Expand Down Expand Up @@ -447,6 +453,12 @@
<ClCompile Include="GetTransfer.cpp">
<Filter>未分类\收款</Filter>
</ClCompile>
<ClCompile Include="SendEmotion.cpp">
<Filter>发送消息\发送表情</Filter>
</ClCompile>
<ClCompile Include="GetMsgCDN.cpp">
<Filter>接收消息</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
Expand Down
30 changes: 30 additions & 0 deletions CWeChatRobot/WeChatRobotCOM_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,17 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ BSTR transferid,
/* [retval][out] */ int *__result) = 0;

virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CSendEmotion(
/* [in] */ DWORD pid,
/* [in] */ BSTR wxid,
/* [in] */ BSTR img_path,
/* [retval][out] */ int *__result) = 0;

virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE CGetMsgCDN(
/* [in] */ DWORD pid,
/* [in] */ ULONG64 msgid,
/* [retval][out] */ BSTR *__result) = 0;

};


Expand Down Expand Up @@ -750,6 +761,19 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ BSTR transferid,
/* [retval][out] */ int *__result);

/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *CSendEmotion )(
IWeChatRobot * This,
/* [in] */ DWORD pid,
/* [in] */ BSTR wxid,
/* [in] */ BSTR img_path,
/* [retval][out] */ int *__result);

/* [helpstring][id] */ HRESULT ( STDMETHODCALLTYPE *CGetMsgCDN )(
IWeChatRobot * This,
/* [in] */ DWORD pid,
/* [in] */ ULONG64 msgid,
/* [retval][out] */ BSTR *__result);

END_INTERFACE
} IWeChatRobotVtbl;

Expand Down Expand Up @@ -936,6 +960,12 @@ EXTERN_C const IID IID_IWeChatRobot;
#define IWeChatRobot_CGetTransfer(This,pid,wxid,transcationid,transferid,__result) \
( (This)->lpVtbl -> CGetTransfer(This,pid,wxid,transcationid,transferid,__result) )

#define IWeChatRobot_CSendEmotion(This,pid,wxid,img_path,__result) \
( (This)->lpVtbl -> CSendEmotion(This,pid,wxid,img_path,__result) )

#define IWeChatRobot_CGetMsgCDN(This,pid,msgid,__result) \
( (This)->lpVtbl -> CGetMsgCDN(This,pid,msgid,__result) )

#endif /* COBJMACROS */


Expand Down
Loading

0 comments on commit d3c5e60

Please sign in to comment.