提交 bf64d9f0 编写于 作者: L ljc545w

添加群艾特消息接口

上级 9516324c
#include "pch.h"
struct SendAtTextStruct
{
DWORD chatroomid;
DWORD wxid;
DWORD wxmsg;
};
int SendAtText(wchar_t* chatroomid, wchar_t* wxid, wchar_t* wxmsg) {
if (!hProcess)
return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0;
DWORD dwWriteSize = 0;
SendAtTextStruct params;
ZeroMemory(&params, sizeof(params));
LPVOID chatroomidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
LPVOID wxidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
LPVOID wxmsgaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
SendAtTextStruct* paramAndFunc = (SendAtTextStruct*)::VirtualAllocEx(hProcess, 0, sizeof(SendAtTextStruct), MEM_COMMIT, PAGE_READWRITE);
if (!chatroomidaddr || !wxidaddr || !wxmsgaddr || !paramAndFunc || !WeChatRobotBase) {
return 1;
}
DWORD dwTId = 0;
if (chatroomidaddr)
WriteProcessMemory(hProcess, chatroomidaddr, chatroomid, wcslen(chatroomid) * 2 + 2, &dwWriteSize);
if (wxidaddr)
WriteProcessMemory(hProcess, wxidaddr, wxid, wcslen(wxid) * 2 + 2, &dwWriteSize);
if (wxmsgaddr)
WriteProcessMemory(hProcess, wxmsgaddr, wxmsg, wcslen(wxmsg) * 2 + 2, &dwWriteSize);
params.chatroomid = (DWORD)chatroomidaddr;
params.wxid = (DWORD)wxidaddr;
params.wxmsg = (DWORD)wxmsgaddr;
if (paramAndFunc) {
if (!::WriteProcessMemory(hProcess, paramAndFunc, &params, sizeof(SendAtTextStruct), &dwTId))
{
return 1;
}
}
else {
return 1;
}
DWORD SendAtTextRemoteAddr = WeChatRobotBase + SendAtTextOffset;
HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)SendAtTextRemoteAddr, (LPVOID)paramAndFunc, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
}
else {
return 1;
}
CloseHandle(hThread);
VirtualFreeEx(hProcess, chatroomidaddr, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, wxidaddr, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, wxmsgaddr, 0, MEM_RELEASE);
VirtualFreeEx(hProcess, paramAndFunc, 0, MEM_RELEASE);
return 0;
}
\ No newline at end of file
#pragma once
#include<windows.h>
int SendAtText(wchar_t* chatroomid, wchar_t* wxid, wchar_t* wxmsg);
\ No newline at end of file
......@@ -31,6 +31,17 @@ STDMETHODIMP CWeChatRobot::CSendText(BSTR wxid, BSTR wxmsg, int* __result) {
return S_OK;
}
/*
* 参数1:群聊id
* 参数2:艾特的人wxid
* 参数3:文本消息内容
* 参数4:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CSendAtText(BSTR chatroomid, BSTR wxid, BSTR wxmsg, int* __result) {
*__result = SendAtText(chatroomid,wxid, wxmsg);
return S_OK;
}
/*
* 参数1:接收人wxid
* 参数2:图片绝对路径
......
......@@ -58,6 +58,7 @@ public:
STDMETHODIMP CSendFile(BSTR wxid, BSTR filepath, int* __result);
STDMETHODIMP CSendArticle(BSTR wxid, BSTR title, BSTR abstract, BSTR url, int* __result);
STDMETHODIMP CSendCard(BSTR receiver, BSTR sharedwxid, BSTR nickname, int* __result);
STDMETHODIMP CSendAtText(BSTR chatroomid, BSTR wxid, BSTR wxmsg, int* __result);
STDMETHODIMP CGetFriendList(VARIANT* __result);
STDMETHODIMP CGetFriendListString(BSTR* __result);
STDMETHODIMP CGetWxUserInfo(BSTR wxid, BSTR* __result);
......
......@@ -34,6 +34,7 @@ interface IWeChatRobot : IDispatch
[id(16)] HRESULT CStartReceiveMessage([out, retval] int* __result);
[id(17)] HRESULT CReceiveMessage([out, retval] VARIANT* __result);
[id(18)] HRESULT CStopReceiveMessage([out, retval] int* __result);
[id(19)] HRESULT CSendAtText([in] BSTR chatroomid, [in] BSTR wxid, [in] BSTR wxmsg, [out, retval] int* __result);
};
[
uuid(721abb35-141a-4aa2-94f2-762e2833fa6c),
......
此差异已折叠。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="生成的文件">
<UniqueIdentifier>{bbe1ba5c-e2d6-4aad-b97a-18ad64a9f157}</UniqueIdentifier>
<SourceControlFiles>False</SourceControlFiles>
</Filter>
<Filter Include="注入工具">
<UniqueIdentifier>{2a494b07-1ec6-45c4-960c-09875429c485}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息">
<UniqueIdentifier>{9e0389a0-4ff4-40a5-8d6a-2c446d7c10b9}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送文本">
<UniqueIdentifier>{2f5b934c-6123-4271-880a-7e185fde0fee}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送图片">
<UniqueIdentifier>{99158de3-8221-42df-8b1f-eb3c7c383e20}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送文件">
<UniqueIdentifier>{eb0eba18-3b38-466c-8978-f7d0f2bb756e}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关">
<UniqueIdentifier>{19933e02-50d4-489c-823e-4e7fe6539792}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关\好友列表">
<UniqueIdentifier>{be3e55a9-dd57-4e92-a340-cb558f3cd4f7}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关\好友信息">
<UniqueIdentifier>{cdd9e8b4-4576-499c-b20e-60e05911f6d6}</UniqueIdentifier>
</Filter>
<Filter Include="个人信息">
<UniqueIdentifier>{82fef7e4-e819-4cb2-9087-40ae1f426e73}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送文章">
<UniqueIdentifier>{1986e9ed-7cd3-4ad3-b333-a1d74cc53c28}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送名片">
<UniqueIdentifier>{9d9c2a95-9243-4809-884b-70d6d87a7128}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关\好友状态">
<UniqueIdentifier>{2543fa88-031d-42ca-9dd1-ac564ee2f744}</UniqueIdentifier>
</Filter>
<Filter Include="接收消息">
<UniqueIdentifier>{9f0d63f2-46a6-4d9c-83dd-ed19792705d0}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="xdlldata.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="WeChatRobotCOM_i.h">
<Filter>生成的文件</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="WeChatRobot.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="InjertDll.h">
<Filter>注入工具</Filter>
</ClInclude>
<ClInclude Include="SendImage.h">
<Filter>发送消息\发送图片</Filter>
</ClInclude>
<ClInclude Include="SendText.h">
<Filter>发送消息\发送文本</Filter>
</ClInclude>
<ClInclude Include="FriendList.h">
<Filter>好友相关\好友列表</Filter>
</ClInclude>
<ClInclude Include="SendFile.h">
<Filter>发送消息\发送文件</Filter>
</ClInclude>
<ClInclude Include="robotdata.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="UserInfo.h">
<Filter>好友相关\好友信息</Filter>
</ClInclude>
<ClInclude Include="SelfInfo.h">
<Filter>个人信息</Filter>
</ClInclude>
<ClInclude Include="SendArticle.h">
<Filter>发送消息\发送文章</Filter>
</ClInclude>
<ClInclude Include="SendCard.h">
<Filter>发送消息\发送名片</Filter>
</ClInclude>
<ClInclude Include="CheckFriendStatus.h">
<Filter>好友相关\好友状态</Filter>
</ClInclude>
<ClInclude Include="ReceiveMessage.h">
<Filter>接收消息</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WeChatRobotCOM.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="xdlldata.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="WeChatRobotCOM_i.c">
<Filter>生成的文件</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="WeChatRobot.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="InjertDll.cpp">
<Filter>注入工具</Filter>
</ClCompile>
<ClCompile Include="SendImage.cpp">
<Filter>发送消息\发送图片</Filter>
</ClCompile>
<ClCompile Include="SendText.cpp">
<Filter>发送消息\发送文本</Filter>
</ClCompile>
<ClCompile Include="FriendList.cpp">
<Filter>好友相关\好友列表</Filter>
</ClCompile>
<ClCompile Include="SendFile.cpp">
<Filter>发送消息\发送文件</Filter>
</ClCompile>
<ClCompile Include="UserInfo.cpp">
<Filter>好友相关\好友信息</Filter>
</ClCompile>
<ClCompile Include="SelfInfo.cpp">
<Filter>个人信息</Filter>
</ClCompile>
<ClCompile Include="SendArticle.cpp">
<Filter>发送消息\发送文章</Filter>
</ClCompile>
<ClCompile Include="SendCard.cpp">
<Filter>发送消息\发送名片</Filter>
</ClCompile>
<ClCompile Include="CheckFriendStatus.cpp">
<Filter>好友相关\好友状态</Filter>
</ClCompile>
<ClCompile Include="ReceiveMessage.cpp">
<Filter>接收消息</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="WeChatRobotCOM.rgs">
<Filter>资源文件</Filter>
</None>
<None Include="WeChatRobot.rgs">
<Filter>资源文件</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Midl Include="WeChatRobotCOM.idl">
<Filter>源文件</Filter>
</Midl>
</ItemGroup>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="生成的文件">
<UniqueIdentifier>{bbe1ba5c-e2d6-4aad-b97a-18ad64a9f157}</UniqueIdentifier>
<SourceControlFiles>False</SourceControlFiles>
</Filter>
<Filter Include="注入工具">
<UniqueIdentifier>{2a494b07-1ec6-45c4-960c-09875429c485}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息">
<UniqueIdentifier>{9e0389a0-4ff4-40a5-8d6a-2c446d7c10b9}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送文本">
<UniqueIdentifier>{2f5b934c-6123-4271-880a-7e185fde0fee}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送图片">
<UniqueIdentifier>{99158de3-8221-42df-8b1f-eb3c7c383e20}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送文件">
<UniqueIdentifier>{eb0eba18-3b38-466c-8978-f7d0f2bb756e}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关">
<UniqueIdentifier>{19933e02-50d4-489c-823e-4e7fe6539792}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关\好友列表">
<UniqueIdentifier>{be3e55a9-dd57-4e92-a340-cb558f3cd4f7}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关\好友信息">
<UniqueIdentifier>{cdd9e8b4-4576-499c-b20e-60e05911f6d6}</UniqueIdentifier>
</Filter>
<Filter Include="个人信息">
<UniqueIdentifier>{82fef7e4-e819-4cb2-9087-40ae1f426e73}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送文章">
<UniqueIdentifier>{1986e9ed-7cd3-4ad3-b333-a1d74cc53c28}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送名片">
<UniqueIdentifier>{9d9c2a95-9243-4809-884b-70d6d87a7128}</UniqueIdentifier>
</Filter>
<Filter Include="好友相关\好友状态">
<UniqueIdentifier>{2543fa88-031d-42ca-9dd1-ac564ee2f744}</UniqueIdentifier>
</Filter>
<Filter Include="接收消息">
<UniqueIdentifier>{9f0d63f2-46a6-4d9c-83dd-ed19792705d0}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送艾特">
<UniqueIdentifier>{ee92dda5-7326-49ad-a09b-b339eedbb518}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="Resource.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="xdlldata.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="WeChatRobotCOM_i.h">
<Filter>生成的文件</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="WeChatRobot.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="InjertDll.h">
<Filter>注入工具</Filter>
</ClInclude>
<ClInclude Include="SendImage.h">
<Filter>发送消息\发送图片</Filter>
</ClInclude>
<ClInclude Include="SendText.h">
<Filter>发送消息\发送文本</Filter>
</ClInclude>
<ClInclude Include="FriendList.h">
<Filter>好友相关\好友列表</Filter>
</ClInclude>
<ClInclude Include="SendFile.h">
<Filter>发送消息\发送文件</Filter>
</ClInclude>
<ClInclude Include="robotdata.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="UserInfo.h">
<Filter>好友相关\好友信息</Filter>
</ClInclude>
<ClInclude Include="SelfInfo.h">
<Filter>个人信息</Filter>
</ClInclude>
<ClInclude Include="SendArticle.h">
<Filter>发送消息\发送文章</Filter>
</ClInclude>
<ClInclude Include="SendCard.h">
<Filter>发送消息\发送名片</Filter>
</ClInclude>
<ClInclude Include="CheckFriendStatus.h">
<Filter>好友相关\好友状态</Filter>
</ClInclude>
<ClInclude Include="ReceiveMessage.h">
<Filter>接收消息</Filter>
</ClInclude>
<ClInclude Include="SendAtText.h">
<Filter>发送消息\发送艾特</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WeChatRobotCOM.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="xdlldata.c">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="WeChatRobotCOM_i.c">
<Filter>生成的文件</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="WeChatRobot.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="InjertDll.cpp">
<Filter>注入工具</Filter>
</ClCompile>
<ClCompile Include="SendImage.cpp">
<Filter>发送消息\发送图片</Filter>
</ClCompile>
<ClCompile Include="SendText.cpp">
<Filter>发送消息\发送文本</Filter>
</ClCompile>
<ClCompile Include="FriendList.cpp">
<Filter>好友相关\好友列表</Filter>
</ClCompile>
<ClCompile Include="SendFile.cpp">
<Filter>发送消息\发送文件</Filter>
</ClCompile>
<ClCompile Include="UserInfo.cpp">
<Filter>好友相关\好友信息</Filter>
</ClCompile>
<ClCompile Include="SelfInfo.cpp">
<Filter>个人信息</Filter>
</ClCompile>
<ClCompile Include="SendArticle.cpp">
<Filter>发送消息\发送文章</Filter>
</ClCompile>
<ClCompile Include="SendCard.cpp">
<Filter>发送消息\发送名片</Filter>
</ClCompile>
<ClCompile Include="CheckFriendStatus.cpp">
<Filter>好友相关\好友状态</Filter>
</ClCompile>
<ClCompile Include="ReceiveMessage.cpp">
<Filter>接收消息</Filter>
</ClCompile>
<ClCompile Include="SendAtText.cpp">
<Filter>发送消息\发送艾特</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="WeChatRobotCOM.rgs">
<Filter>资源文件</Filter>
</None>
<None Include="WeChatRobot.rgs">
<Filter>资源文件</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Midl Include="WeChatRobotCOM.idl">
<Filter>源文件</Filter>
</Midl>
</ItemGroup>
</Project>
\ No newline at end of file
/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
/* link this file in with the server and any clients */
/* File created by MIDL compiler version 8.01.0622 */
/* at Tue Jan 19 11:14:07 2038
*/
/* Compiler settings for WeChatRobotCOM.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING( ) */
#ifdef __cplusplus
extern "C"{
#endif
#include <rpc.h>
#include <rpcndr.h>
#ifdef _MIDL_USE_GUIDDEF_
#ifndef INITGUID
#define INITGUID
#include <guiddef.h>
#undef INITGUID
#else
#include <guiddef.h>
#endif
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
#else // !_MIDL_USE_GUIDDEF_
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
typedef struct _IID
{
unsigned long x;
unsigned short s1;
unsigned short s2;
unsigned char c[8];
} IID;
#endif // __IID_DEFINED__
#ifndef CLSID_DEFINED
#define CLSID_DEFINED
typedef IID CLSID;
#endif // CLSID_DEFINED
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
EXTERN_C __declspec(selectany) const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
#endif // !_MIDL_USE_GUIDDEF_
MIDL_DEFINE_GUID(IID, IID_IWeChatRobot,0xa836e359,0x59b2,0x4e01,0x9b,0x0c,0x0e,0x5a,0x5a,0x2e,0xfa,0x22);
MIDL_DEFINE_GUID(IID, LIBID_WeChatRobotCOMLib,0x721abb35,0x141a,0x4aa2,0x94,0xf2,0x76,0x2e,0x28,0x33,0xfa,0x6c);
MIDL_DEFINE_GUID(CLSID, CLSID_WeChatRobot,0x4ce7f5e1,0x2c93,0x4bfe,0x86,0xac,0x88,0x64,0x52,0xe4,0x74,0x75);
#undef MIDL_DEFINE_GUID
#ifdef __cplusplus
}
#endif
/* this ALWAYS GENERATED file contains the IIDs and CLSIDs */
/* link this file in with the server and any clients */
/* File created by MIDL compiler version 8.01.0622 */
/* at Tue Jan 19 11:14:07 2038
*/
/* Compiler settings for WeChatRobotCOM.idl:
Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 8.01.0622
protocol : dce , ms_ext, c_ext, robust
error checks: allocation ref bounds_check enum stub_data
VC __declspec() decoration level:
__declspec(uuid()), __declspec(selectany), __declspec(novtable)
DECLSPEC_UUID(), MIDL_INTERFACE()
*/
/* @@MIDL_FILE_HEADING( ) */
#ifdef __cplusplus
extern "C"{
#endif
#include <rpc.h>
#include <rpcndr.h>
#ifdef _MIDL_USE_GUIDDEF_
#ifndef INITGUID
#define INITGUID
#include <guiddef.h>
#undef INITGUID
#else
#include <guiddef.h>
#endif
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
DEFINE_GUID(name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8)
#else // !_MIDL_USE_GUIDDEF_
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
typedef struct _IID
{
unsigned long x;
unsigned short s1;
unsigned short s2;
unsigned char c[8];
} IID;
#endif // __IID_DEFINED__
#ifndef CLSID_DEFINED
#define CLSID_DEFINED
typedef IID CLSID;
#endif // CLSID_DEFINED
#define MIDL_DEFINE_GUID(type,name,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \
EXTERN_C __declspec(selectany) const type name = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
#endif // !_MIDL_USE_GUIDDEF_
MIDL_DEFINE_GUID(IID, IID_IWeChatRobot,0xa836e359,0x59b2,0x4e01,0x9b,0x0c,0x0e,0x5a,0x5a,0x2e,0xfa,0x22);
MIDL_DEFINE_GUID(IID, LIBID_WeChatRobotCOMLib,0x721abb35,0x141a,0x4aa2,0x94,0xf2,0x76,0x2e,0x28,0x33,0xfa,0x6c);
MIDL_DEFINE_GUID(CLSID, CLSID_WeChatRobot,0x4ce7f5e1,0x2c93,0x4bfe,0x86,0xac,0x88,0x64,0x52,0xe4,0x74,0x75);
#undef MIDL_DEFINE_GUID
#ifdef __cplusplus
}
#endif
此差异已折叠。
此差异已折叠。
/*********************************************************
DllData file -- generated by MIDL compiler
DO NOT ALTER THIS FILE
This file is regenerated by MIDL on every IDL file compile.
To completely reconstruct this file, delete it and rerun MIDL
on all the IDL files in this DLL, specifying this file for the
/dlldata command line option
*********************************************************/
#define PROXY_DELEGATION
#include <rpcproxy.h>
#ifdef __cplusplus
extern "C" {
#endif
EXTERN_PROXY_FILE( WeChatRobotCOM )
PROXYFILE_LIST_START
/* Start of list */
REFERENCE_PROXY_FILE( WeChatRobotCOM ),
/* End of list */
PROXYFILE_LIST_END
DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
#ifdef __cplusplus
} /*extern "C" */
#endif
/* end of generated dlldata file */
/*********************************************************
DllData file -- generated by MIDL compiler
DO NOT ALTER THIS FILE
This file is regenerated by MIDL on every IDL file compile.
To completely reconstruct this file, delete it and rerun MIDL
on all the IDL files in this DLL, specifying this file for the
/dlldata command line option
*********************************************************/
#define PROXY_DELEGATION
#include <rpcproxy.h>
#ifdef __cplusplus
extern "C" {
#endif
EXTERN_PROXY_FILE( WeChatRobotCOM )
PROXYFILE_LIST_START
/* Start of list */
REFERENCE_PROXY_FILE( WeChatRobotCOM ),
/* End of list */
PROXYFILE_LIST_END
DLLDATA_ROUTINES( aProxyFileList, GET_DLL_CLSID )
#ifdef __cplusplus
} /*extern "C" */
#endif
/* end of generated dlldata file */
......@@ -8,6 +8,7 @@ DWORD SendTextOffset = 0x0;
DWORD SendFileOffset = 0x0;
DWORD SendArticleOffset = 0x0;
DWORD SendCardOffset = 0x0;
DWORD SendAtTextOffset = 0x0;
DWORD GetFriendListInitOffset = 0x0;
DWORD GetFriendListRemoteOffset = 0x0;
......@@ -97,6 +98,8 @@ void GetProcOffset(wchar_t* workPath) {
SendArticleOffset = SendArticleProcAddr - WeChatBase;
DWORD SendCardProcAddr = (DWORD)GetProcAddress(hd, SendCardRemote);
SendCardOffset = SendCardProcAddr - WeChatBase;
DWORD SendAtTextProcAddr = (DWORD)GetProcAddress(hd, SendAtTextRemote);
SendAtTextOffset = SendAtTextProcAddr - WeChatBase;
DWORD GetFriendListInitProcAddr = (DWORD)GetProcAddress(hd, GetFriendListInit);
GetFriendListInitOffset = GetFriendListInitProcAddr - WeChatBase;
......
......@@ -5,6 +5,7 @@
#include "SendFile.h"
#include "SendArticle.h"
#include "SendCard.h"
#include "SendAtText.h"
#include "FriendList.h"
#include "UserInfo.h"
#include "SelfInfo.h"
......@@ -17,6 +18,7 @@ extern DWORD SendTextOffset;
extern DWORD SendFileOffset;
extern DWORD SendArticleOffset;
extern DWORD SendCardOffset;
extern DWORD SendAtTextOffset;
extern DWORD GetFriendListInitOffset;
extern DWORD GetFriendListRemoteOffset;
......@@ -46,6 +48,7 @@ extern DWORD PopHeadMessageRemoteOffset;
#define SendFileRemote "SendFileRemote"
#define SendArticleRemote "SendArticleRemote"
#define SendCardRemote "SendCardRemote"
#define SendAtTextRemote "SendAtTextRemote"
#define GetFriendListInit "GetFriendListInit"
#define GetFriendListRemote "GetFriendListRemote"
......
......@@ -162,6 +162,7 @@
<ClInclude Include="ReceiveMessage.h" />
<ClInclude Include="SelfInfo.h" />
<ClInclude Include="SendArticle.h" />
<ClInclude Include="SendAtText.h" />
<ClInclude Include="SendCard.h" />
<ClInclude Include="SendFile.h" />
<ClInclude Include="SendImage.h" />
......@@ -181,6 +182,7 @@
<ClCompile Include="ReceiveMessage.cpp" />
<ClCompile Include="SelfInfo.cpp" />
<ClCompile Include="SendArticle.cpp" />
<ClCompile Include="SendAtText.cpp" />
<ClCompile Include="SendCard.cpp" />
<ClCompile Include="SendFile.cpp" />
<ClCompile Include="SendImage.cpp" />
......
......@@ -55,6 +55,9 @@
<Filter Include="接收消息">
<UniqueIdentifier>{4763248d-1490-48c0-aa63-bf3265cf8178}</UniqueIdentifier>
</Filter>
<Filter Include="发送消息\发送艾特">
<UniqueIdentifier>{15310114-64cf-4426-a4ef-3c889824d2de}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
......@@ -96,6 +99,9 @@
<ClInclude Include="ReceiveMessage.h">
<Filter>接收消息</Filter>
</ClInclude>
<ClInclude Include="SendAtText.h">
<Filter>发送消息\发送艾特</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
......@@ -137,5 +143,8 @@
<ClCompile Include="ReceiveMessage.cpp">
<Filter>接收消息</Filter>
</ClCompile>
<ClCompile Include="SendAtText.cpp">
<Filter>发送消息\发送艾特</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
#include "pch.h"
#define SendAtTextCallOffset 0x6782E7B0 - 0x67370000
#define DeleteAtTextCacheCallOffset 0x67404200 - 0x67370000
struct SendAtTextStruct
{
DWORD chatroomid;
DWORD wxid;
DWORD wxmsg;
};
struct AtUserStruct {
wchar_t* wxid;
DWORD Length;
DWORD maxLength;
DWORD fill1 = 0;
DWORD fill2 = 0;
DWORD fill3 = 0;
};
struct AtStruct {
AtUserStruct* AtUser = NULL;
DWORD addr_end1;
DWORD addr_end2;
};
void SendAtTextRemote(LPVOID lpParameter) {
SendAtTextStruct* rp = (SendAtTextStruct*)lpParameter;
wchar_t* wsChatRoomId = (WCHAR*)rp->chatroomid;
wchar_t* wsWxId = (WCHAR*)rp->wxid;
wchar_t* wsTextMsg = (WCHAR*)rp->wxmsg;
SendAtText(wsChatRoomId,wsWxId, wsTextMsg);
}
void __stdcall SendAtText(wchar_t* wsChatRoomId, wchar_t* wsWxId, wchar_t* wsTextMsg) {
wchar_t* NickName = GetUserNickNameByWxId(wsWxId);
if (!NickName)
return;
wchar_t* SendTextMsg = new wchar_t[wcslen(wsTextMsg) + wcslen(NickName) + 3];
ZeroMemory(SendTextMsg, (wcslen(wsTextMsg) + wcslen(NickName) + 3) * 2);
swprintf_s(SendTextMsg, (wcslen(wsTextMsg) + wcslen(NickName) + 2) * 2,L"@%ws %ws",NickName,wsTextMsg);
WxBaseStruct wxChatRoomId(wsChatRoomId);
WxBaseStruct wxTextMsg(SendTextMsg);
AtStruct at = { 0 };
AtUserStruct AtUser = { 0 };
AtUser.wxid = wsWxId;
AtUser.Length = wcslen(wsWxId);
AtUser.maxLength = wcslen(wsWxId) * 2;
at.AtUser = &AtUser;
at.addr_end1 = (DWORD)&AtUser.fill3;
at.addr_end2 = (DWORD)&AtUser.fill3;
wchar_t** pWxmsg = &wxTextMsg.buffer;
char buffer[0x3B0] = { 0 };
DWORD dllBaseAddress = GetWeChatWinBase();
DWORD callAddress = dllBaseAddress + SendAtTextCallOffset;
DWORD DeleteTextCacheCall = dllBaseAddress + DeleteAtTextCacheCallOffset;
__asm {
pushad;
lea eax, at;
push 0x1;
push eax;
mov edi, pWxmsg;
push edi;
lea edx, wxChatRoomId;
lea ecx, buffer;
call callAddress;
add esp, 0xC;
lea ecx, buffer;
call DeleteTextCacheCall;
popad;
}
}
\ No newline at end of file
#pragma once
#include<windows.h>
void __stdcall SendAtText(wchar_t* wxChatRoomId, wchar_t* wsWxId, wchar_t* wsTextMsg);
extern "C" __declspec(dllexport) void SendAtTextRemote(LPVOID lpParameter);
\ No newline at end of file
......@@ -129,4 +129,56 @@ BOOL __stdcall GetUserInfoByWxId(wchar_t* wxid) {
popad;
}
return isSuccess;
}
wchar_t* __stdcall GetUserNickNameByWxId(wchar_t* wxid) {
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD WxGetUserInfoCall0 = WeChatWinBase + GetUserInfoCall0Offset;
DWORD WxGetUserInfoCall1 = WeChatWinBase + GetUserInfoCall1Offset;
DWORD WxGetUserInfoCall2 = WeChatWinBase + GetUserInfoCall2Offset;
DWORD WxGetUserInfoCall3 = WeChatWinBase + GetUserInfoCall3Offset;
DWORD DeleteUserInofCacheCall1 = WeChatWinBase + DeleteUserInfoCacheCall1Offset;
DWORD DeleteUserInofCacheCall2 = WeChatWinBase + DeleteUserInfoCacheCall2Offset;
char buffer[0x3FC] = { 0 };
WxBaseStruct pWxid(wxid);
DWORD address = 0;
DWORD isSuccess = 0;
__asm
{
pushad;
call WxGetUserInfoCall0;
mov edi, eax;
lea ecx, buffer;
call WxGetUserInfoCall1;
lea eax, buffer;
mov address, eax;
push eax;
sub esp, 0x14;
mov ecx, esp;
lea esi, pWxid;
push esi;
call WxGetUserInfoCall2;
mov ecx, edi;
call WxGetUserInfoCall3;
mov isSuccess, eax;
popad;
}
wchar_t* NickName = NULL;
if (isSuccess) {
DWORD length = *(DWORD*)(address + 0x6C + 0x4);
NickName = new wchar_t[length + 1];
ZeroMemory(NickName, (length + 1) * 2);
memcpy(NickName, (wchar_t*)(*(DWORD*)(address + 0x6C)), length * 2);
}
__asm {
pushad;
lea eax, buffer;
push eax;
call DeleteUserInofCacheCall1;
lea ecx, buffer;
mov esi, eax;
call DeleteUserInofCacheCall2;
popad;
}
return NickName;
}
\ No newline at end of file
......@@ -2,4 +2,5 @@
#include<windows.h>
BOOL __stdcall GetUserInfoByWxId(wchar_t* wxid);
extern "C" __declspec(dllexport) DWORD GetWxUserInfoRemote(LPVOID lparamter);
extern "C" __declspec(dllexport) VOID DeleteUserInfoCacheRemote();
\ No newline at end of file
extern "C" __declspec(dllexport) VOID DeleteUserInfoCacheRemote();
wchar_t* __stdcall GetUserNickNameByWxId(wchar_t* wxid);
\ No newline at end of file
......@@ -15,6 +15,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
printf("SendImage 0x%08X\n", (DWORD)SendImage);
printf("SendText 0x%08X\n", (DWORD)SendText);
printf("SendFile 0x%08X\n", (DWORD)SendFile);
printf("SendAtText 0x%08X\n", (DWORD)SendAtText);
printf("GetFriendList 0x%08X\n", (DWORD)GetFriendList);
printf("GetUserInfoByWxId 0x%08X\n", (DWORD)GetUserInfoByWxId);
printf("SendArticle 0x%08X\n", (DWORD)SendArticle);
......
......@@ -22,6 +22,7 @@
#include "CheckFriendStatus.h"
#include "LogMsgInfo.h"
#include "ReceiveMessage.h"
#include "SendAtText.h"
#endif //PCH_H
using namespace std;
......
......@@ -35,6 +35,11 @@ class ChatSession():
def SendCard(self,sharedwxid,nickname):
return self.robot.CSendCard(self.chatwith,sharedwxid,nickname)
def SendAtText(self,wxid,msg):
if '@chatroom' not in self.chatwith:
return 1
return self.robot.CSendAtText(self.chatwith,wxid,msg)
class WeChatRobot():
......@@ -158,7 +163,7 @@ class WeChatRobot():
while self.ReceiveMessageStarted:
try:
message = dict(ThreadRobot.robot.CReceiveMessage())
if CallBackFunc:
if CallBackFunc and message:
CallBackFunc(ThreadRobot,message)
except IndexError:
message = None
......@@ -239,7 +244,11 @@ def test_ReceiveMessage():
wx = WeChatRobot()
wx.StartService()
wx.StartReceiveMessage(CallBackFunc = ReceiveMessageCallBack)
input('按Enter可退出')
try:
while True:
pass
except KeyboardInterrupt:
pass
wx.StopService()
if __name__ == '__main__':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册