diff --git a/CWeChatRobot/DeleteUser.cpp b/CWeChatRobot/DeleteUser.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3701239d926ee19683c9dde72b89fadb3a91ce28 --- /dev/null +++ b/CWeChatRobot/DeleteUser.cpp @@ -0,0 +1,22 @@ +#include "pch.h" + +BOOL DeleteUser(wchar_t* wxid) { + if (!hProcess) + return 1; + DWORD DeleteUserRemoteAddr = GetWeChatRobotBase() + DeleteUserRemoteOffset; + LPVOID wxidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE); + DWORD dwWriteSize = 0; + DWORD dwId = 0; + DWORD dwRet = 0; + if (!wxidaddr) + return 1; + WriteProcessMemory(hProcess, wxidaddr, wxid, wcslen(wxid) * 2 + 2, &dwWriteSize); + HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)DeleteUserRemoteAddr, wxidaddr, 0, &dwId); + if (hThread) { + WaitForSingleObject(hThread, INFINITE); + GetExitCodeThread(hThread, &dwRet); + CloseHandle(hThread); + } + VirtualFreeEx(hProcess, wxidaddr, 0, MEM_RELEASE); + return dwRet == 0; +} \ No newline at end of file diff --git a/CWeChatRobot/DeleteUser.h b/CWeChatRobot/DeleteUser.h new file mode 100644 index 0000000000000000000000000000000000000000..5b0e830192680debce3b5634257fa1f84ea77121 --- /dev/null +++ b/CWeChatRobot/DeleteUser.h @@ -0,0 +1,4 @@ +#pragma once +#include + +BOOL DeleteUser(wchar_t* wxid); \ No newline at end of file diff --git a/CWeChatRobot/SendAppMsg.cpp b/CWeChatRobot/SendAppMsg.cpp new file mode 100644 index 0000000000000000000000000000000000000000..86edde33955fc6a1820b0ed2270223460a5a408d --- /dev/null +++ b/CWeChatRobot/SendAppMsg.cpp @@ -0,0 +1,49 @@ +#include "pch.h" + +struct SendAppMsgStruct +{ + DWORD wxid; + DWORD appid; +}; + +BOOL SendAppMsg(wchar_t* wxid, wchar_t* appid) { + if (!hProcess) + return 1; + DWORD WeChatRobotBase = GetWeChatRobotBase(); + DWORD dwId = 0; + DWORD dwWriteSize = 0; + DWORD dwRet = 0x0; + SendAppMsgStruct params; + ZeroMemory(¶ms, sizeof(params)); + LPVOID wxidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE); + LPVOID appidaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE); + SendAppMsgStruct* paramAndFunc = (SendAppMsgStruct*)::VirtualAllocEx(hProcess, 0, sizeof(SendAppMsgStruct), MEM_COMMIT, PAGE_READWRITE); + if (!wxidaddr || !appidaddr || !paramAndFunc || !WeChatRobotBase) { + return 1; + } + + if (wxidaddr) + WriteProcessMemory(hProcess, wxidaddr, wxid, wcslen(wxid) * 2 + 2, &dwWriteSize); + + if (appidaddr) + WriteProcessMemory(hProcess, appidaddr, appid, wcslen(appid) * 2 + 2, &dwWriteSize); + + params.wxid = (DWORD)wxidaddr; + params.appid = (DWORD)appidaddr; + + if (paramAndFunc) + WriteProcessMemory(hProcess, paramAndFunc, ¶ms, sizeof(params), &dwWriteSize); + + DWORD SendAppMsgRemoteAddr = WeChatRobotBase + SendAppMsgRemoteOffset; + HANDLE hThread = ::CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)SendAppMsgRemoteAddr, (LPVOID)paramAndFunc, 0, &dwId); + if (hThread) { + WaitForSingleObject(hThread, INFINITE); + GetExitCodeThread(hThread, &dwRet); + CloseHandle(hThread); + } + + VirtualFreeEx(hProcess, wxidaddr, 0, MEM_RELEASE); + VirtualFreeEx(hProcess, appidaddr, 0, MEM_RELEASE); + VirtualFreeEx(hProcess, paramAndFunc, 0, MEM_RELEASE); + return dwRet == 0; +} \ No newline at end of file diff --git a/CWeChatRobot/SendAppMsg.h b/CWeChatRobot/SendAppMsg.h new file mode 100644 index 0000000000000000000000000000000000000000..24b26f3d2088a1ee75d23a78ba660ba37b317dc8 --- /dev/null +++ b/CWeChatRobot/SendAppMsg.h @@ -0,0 +1,3 @@ +#pragma once +#include +BOOL SendAppMsg(wchar_t* wxid, wchar_t* appid); \ No newline at end of file diff --git a/CWeChatRobot/WeChatRobot.cpp b/CWeChatRobot/WeChatRobot.cpp index 52e16cc398fe395ad38698916b2f3cb1a172cbc2..a9d4e83fe6531adbb2f17586b1392eede75b997c 100644 --- a/CWeChatRobot/WeChatRobot.cpp +++ b/CWeChatRobot/WeChatRobot.cpp @@ -354,4 +354,23 @@ STDMETHODIMP CWeChatRobot::CUnHookImageMsg(int* __result) { STDMETHODIMP CWeChatRobot::CChangeWeChatVer(BSTR verStr, int* __result) { *__result = ChangeWeChatVer(verStr); return S_OK; +} + +/* +* 参数1:接收人wxid +* 参数2:小程序id +* 参数3:预返回的值,调用时无需提供 +*/ +STDMETHODIMP CWeChatRobot::CSendAppMsg(BSTR wxid,BSTR appid,int* __result) { + *__result = SendAppMsg(wxid,appid); + return S_OK; +} + +/* +* 参数1:要删除的人wxid +* 参数3:预返回的值,调用时无需提供 +*/ +STDMETHODIMP CWeChatRobot::CDeleteUser(BSTR wxid, int* __result) { + *__result = DeleteUser(wxid); + return S_OK; } \ No newline at end of file diff --git a/CWeChatRobot/WeChatRobot.h b/CWeChatRobot/WeChatRobot.h index 818e13441545a6d5bc90a35044810b58019e85b3..4b31b516480841443cfe3a0f19c18e3b00623ca4 100644 --- a/CWeChatRobot/WeChatRobot.h +++ b/CWeChatRobot/WeChatRobot.h @@ -86,6 +86,8 @@ public: STDMETHODIMP CHookImageMsg(BSTR savepath, int* __result); STDMETHODIMP CUnHookImageMsg(int* __result); STDMETHODIMP CChangeWeChatVer(BSTR verStr, int* __result); + STDMETHODIMP CSendAppMsg(BSTR wxid, BSTR appid, int* __result); + STDMETHODIMP CDeleteUser(BSTR wxid, int* __result); }; OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot) diff --git a/CWeChatRobot/WeChatRobotCOM.idl b/CWeChatRobot/WeChatRobotCOM.idl index df379fb888a7213efe64edcab94da2695dc58cc4..c053a9bdba2d0ea28c3140f2415af002c1329127 100644 --- a/CWeChatRobot/WeChatRobotCOM.idl +++ b/CWeChatRobot/WeChatRobotCOM.idl @@ -51,6 +51,8 @@ interface IWeChatRobot : IDispatch [id(33)] HRESULT CHookImageMsg([in] BSTR savepath, [out, retval] int* __result); [id(34)] HRESULT CUnHookImageMsg([out, retval] int* __result); [id(35)] HRESULT CChangeWeChatVer([in] BSTR verStr, [out, retval] int* __result); + [id(36)] HRESULT CSendAppMsg([in] BSTR wxid, [in] BSTR appid, [out, retval] int* __result); + [id(37)] HRESULT CDeleteUser([in] BSTR wxid, [out, retval] int* __result); }; [ uuid(721abb35-141a-4aa2-94f2-762e2833fa6c), diff --git a/CWeChatRobot/WeChatRobotCOM.vcxproj b/CWeChatRobot/WeChatRobotCOM.vcxproj index b979bff7d7c7712f6face7700228edc36217eecf..51a359d84371c8f3f458c33f481255d3df622101 100644 --- a/CWeChatRobot/WeChatRobotCOM.vcxproj +++ b/CWeChatRobot/WeChatRobotCOM.vcxproj @@ -215,6 +215,7 @@ + @@ -225,6 +226,7 @@ + @@ -246,6 +248,7 @@ + @@ -261,6 +264,7 @@ + diff --git a/CWeChatRobot/WeChatRobotCOM.vcxproj.filters b/CWeChatRobot/WeChatRobotCOM.vcxproj.filters index 3d4162de3327449d0d6aaf13885afc958d1d9a42..df28623ad49e41cf087d77f1066bfb86d454e18b 100644 --- a/CWeChatRobot/WeChatRobotCOM.vcxproj.filters +++ b/CWeChatRobot/WeChatRobotCOM.vcxproj.filters @@ -86,6 +86,12 @@ {4214a216-3efc-48db-8fda-8a33066b2db2} + + {85b30d50-eaf9-4576-9416-c6083438389c} + + + {68a69a6f-dba9-412e-9030-a9dc0544d31c} + @@ -169,6 +175,12 @@ 微信版本 + + 发送消息\发送小程序 + + + 好友相关\删除好友 + @@ -258,6 +270,12 @@ 微信版本 + + 发送消息\发送小程序 + + + 好友相关\删除好友 + diff --git a/CWeChatRobot/WeChatRobotCOM_i.h b/CWeChatRobot/WeChatRobotCOM_i.h index c64ba96731e93d798fff61cd5c58f37a09f8ff47..cfd6c2585028263be540fbe0ac3824f9822dbf99 100644 --- a/CWeChatRobot/WeChatRobotCOM_i.h +++ b/CWeChatRobot/WeChatRobotCOM_i.h @@ -230,6 +230,15 @@ EXTERN_C const IID IID_IWeChatRobot; /* [in] */ BSTR verStr, /* [retval][out] */ int *__result) = 0; + virtual /* [id] */ HRESULT STDMETHODCALLTYPE CSendAppMsg( + /* [in] */ BSTR wxid, + /* [in] */ BSTR appid, + /* [retval][out] */ int *__result) = 0; + + virtual /* [id] */ HRESULT STDMETHODCALLTYPE CDeleteUser( + /* [in] */ BSTR wxid, + /* [retval][out] */ int *__result) = 0; + }; @@ -465,6 +474,17 @@ EXTERN_C const IID IID_IWeChatRobot; /* [in] */ BSTR verStr, /* [retval][out] */ int *__result); + /* [id] */ HRESULT ( STDMETHODCALLTYPE *CSendAppMsg )( + IWeChatRobot * This, + /* [in] */ BSTR wxid, + /* [in] */ BSTR appid, + /* [retval][out] */ int *__result); + + /* [id] */ HRESULT ( STDMETHODCALLTYPE *CDeleteUser )( + IWeChatRobot * This, + /* [in] */ BSTR wxid, + /* [retval][out] */ int *__result); + END_INTERFACE } IWeChatRobotVtbl; @@ -606,6 +626,12 @@ EXTERN_C const IID IID_IWeChatRobot; #define IWeChatRobot_CChangeWeChatVer(This,verStr,__result) \ ( (This)->lpVtbl -> CChangeWeChatVer(This,verStr,__result) ) +#define IWeChatRobot_CSendAppMsg(This,wxid,appid,__result) \ + ( (This)->lpVtbl -> CSendAppMsg(This,wxid,appid,__result) ) + +#define IWeChatRobot_CDeleteUser(This,wxid,__result) \ + ( (This)->lpVtbl -> CDeleteUser(This,wxid,__result) ) + #endif /* COBJMACROS */ diff --git a/CWeChatRobot/WeChatRobotCOM_p.c b/CWeChatRobot/WeChatRobotCOM_p.c index 135b7f475a4ca454422143c5fb551e42ec1a1362..d454b053f00217e21eaf283c31e4f9a6e6cdad2b 100644 --- a/CWeChatRobot/WeChatRobotCOM_p.c +++ b/CWeChatRobot/WeChatRobotCOM_p.c @@ -49,7 +49,7 @@ #include "WeChatRobotCOM_i.h" #define TYPE_FORMAT_STRING_SIZE 1239 -#define PROC_FORMAT_STRING_SIZE 1483 +#define PROC_FORMAT_STRING_SIZE 1573 #define EXPR_FORMAT_STRING_SIZE 1 #define TRANSMIT_AS_TABLE_SIZE 0 #define WIRE_MARSHAL_TABLE_SIZE 2 @@ -1407,6 +1407,86 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor /* 1480 */ 0x8, /* FC_LONG */ 0x0, /* 0 */ + /* Procedure CSendAppMsg */ + +/* 1482 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 1484 */ NdrFcLong( 0x0 ), /* 0 */ +/* 1488 */ NdrFcShort( 0x2a ), /* 42 */ +/* 1490 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */ +/* 1492 */ NdrFcShort( 0x0 ), /* 0 */ +/* 1494 */ NdrFcShort( 0x24 ), /* 36 */ +/* 1496 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x4, /* 4 */ +/* 1498 */ 0x8, /* 8 */ + 0x45, /* Ext Flags: new corr desc, srv corr check, has range on conformance */ +/* 1500 */ NdrFcShort( 0x0 ), /* 0 */ +/* 1502 */ NdrFcShort( 0x1 ), /* 1 */ +/* 1504 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter wxid */ + +/* 1506 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ +/* 1508 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 1510 */ NdrFcShort( 0x2a ), /* Type Offset=42 */ + + /* Parameter appid */ + +/* 1512 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ +/* 1514 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 1516 */ NdrFcShort( 0x2a ), /* Type Offset=42 */ + + /* Parameter __result */ + +/* 1518 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ +/* 1520 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 1522 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Return value */ + +/* 1524 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 1526 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ +/* 1528 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Procedure CDeleteUser */ + +/* 1530 */ 0x33, /* FC_AUTO_HANDLE */ + 0x6c, /* Old Flags: object, Oi2 */ +/* 1532 */ NdrFcLong( 0x0 ), /* 0 */ +/* 1536 */ NdrFcShort( 0x2b ), /* 43 */ +/* 1538 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */ +/* 1540 */ NdrFcShort( 0x0 ), /* 0 */ +/* 1542 */ NdrFcShort( 0x24 ), /* 36 */ +/* 1544 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */ + 0x3, /* 3 */ +/* 1546 */ 0x8, /* 8 */ + 0x45, /* Ext Flags: new corr desc, srv corr check, has range on conformance */ +/* 1548 */ NdrFcShort( 0x0 ), /* 0 */ +/* 1550 */ NdrFcShort( 0x1 ), /* 1 */ +/* 1552 */ NdrFcShort( 0x0 ), /* 0 */ + + /* Parameter wxid */ + +/* 1554 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */ +/* 1556 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */ +/* 1558 */ NdrFcShort( 0x2a ), /* Type Offset=42 */ + + /* Parameter __result */ + +/* 1560 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */ +/* 1562 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */ +/* 1564 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + + /* Return value */ + +/* 1566 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */ +/* 1568 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */ +/* 1570 */ 0x8, /* FC_LONG */ + 0x0, /* 0 */ + 0x0 } }; @@ -2286,7 +2366,9 @@ static const unsigned short IWeChatRobot_FormatStringOffsetTable[] = 1326, 1362, 1404, - 1440 + 1440, + 1482, + 1530 }; static const MIDL_STUBLESS_PROXY_INFO IWeChatRobot_ProxyInfo = @@ -2310,7 +2392,7 @@ static const MIDL_SERVER_INFO IWeChatRobot_ServerInfo = 0, 0, 0}; -CINTERFACE_PROXY_VTABLE(42) _IWeChatRobotProxyVtbl = +CINTERFACE_PROXY_VTABLE(44) _IWeChatRobotProxyVtbl = { &IWeChatRobot_ProxyInfo, &IID_IWeChatRobot, @@ -2355,7 +2437,9 @@ CINTERFACE_PROXY_VTABLE(42) _IWeChatRobotProxyVtbl = (void *) (INT_PTR) -1 /* IWeChatRobot::CUnHookVoiceMsg */ , (void *) (INT_PTR) -1 /* IWeChatRobot::CHookImageMsg */ , (void *) (INT_PTR) -1 /* IWeChatRobot::CUnHookImageMsg */ , - (void *) (INT_PTR) -1 /* IWeChatRobot::CChangeWeChatVer */ + (void *) (INT_PTR) -1 /* IWeChatRobot::CChangeWeChatVer */ , + (void *) (INT_PTR) -1 /* IWeChatRobot::CSendAppMsg */ , + (void *) (INT_PTR) -1 /* IWeChatRobot::CDeleteUser */ }; @@ -2399,6 +2483,8 @@ static const PRPC_STUB_FUNCTION IWeChatRobot_table[] = NdrStubCall2, NdrStubCall2, NdrStubCall2, + NdrStubCall2, + NdrStubCall2, NdrStubCall2 }; @@ -2406,7 +2492,7 @@ CInterfaceStubVtbl _IWeChatRobotStubVtbl = { &IID_IWeChatRobot, &IWeChatRobot_ServerInfo, - 42, + 44, &IWeChatRobot_table[-3], CStdStubBuffer_DELEGATING_METHODS }; diff --git a/CWeChatRobot/pch.cpp b/CWeChatRobot/pch.cpp index 4b5949296256ab7b1f0ec0a2f0f7c72b56fc8cc6..fa20ab235faf4671d6bff732c7bcdf05f54e6ed6 100644 --- a/CWeChatRobot/pch.cpp +++ b/CWeChatRobot/pch.cpp @@ -9,6 +9,7 @@ DWORD SendFileOffset = 0x0; DWORD SendArticleOffset = 0x0; DWORD SendCardOffset = 0x0; DWORD SendAtTextOffset = 0x0; +DWORD SendAppMsgRemoteOffset = 0x0; DWORD GetFriendListInitOffset = 0x0; DWORD GetFriendListRemoteOffset = 0x0; @@ -41,6 +42,7 @@ DWORD BackupSQLiteDBRemoteOffset = 0x0; DWORD AddFriendByWxidRemoteOffset = 0x0; DWORD AddFriendByV3RemoteOffset = 0x0; +DWORD DeleteUserRemoteOffset = 0x0; DWORD AddBrandContactRemoteOffset = 0x0; DWORD HookImageMsgRemoteOffset = 0x0; @@ -122,6 +124,8 @@ BOOL GetProcOffset(wchar_t* workPath) { SendCardOffset = SendCardProcAddr - WeChatBase; DWORD SendAtTextProcAddr = (DWORD)GetProcAddress(hd, SendAtTextRemote); SendAtTextOffset = SendAtTextProcAddr - WeChatBase; + DWORD SendAppMsgProcAddr = (DWORD)GetProcAddress(hd, SendAppMsgRemote); + SendAppMsgRemoteOffset = SendAppMsgProcAddr - WeChatBase; DWORD GetFriendListInitProcAddr = (DWORD)GetProcAddress(hd, GetFriendListInit); GetFriendListInitOffset = GetFriendListInitProcAddr - WeChatBase; @@ -177,6 +181,8 @@ BOOL GetProcOffset(wchar_t* workPath) { AddFriendByWxidRemoteOffset = AddFriendByWxidRemoteAddr - WeChatBase; DWORD AddFriendByV3RemoteAddr = (DWORD)GetProcAddress(hd, AddFriendByV3Remote); AddFriendByV3RemoteOffset = AddFriendByV3RemoteAddr - WeChatBase; + DWORD DeleteUserRemoteAddr = (DWORD)GetProcAddress(hd, DeleteUserRemote); + DeleteUserRemoteOffset = DeleteUserRemoteAddr - WeChatBase; DWORD AddBrandContactRemoteAddr = (DWORD)GetProcAddress(hd, AddBrandContactRemote); AddBrandContactRemoteOffset = AddBrandContactRemoteAddr - WeChatBase; diff --git a/CWeChatRobot/robotdata.h b/CWeChatRobot/robotdata.h index e70d0a4a91686477e9bcac12f68ae3e7a0c3e68b..cfde5073252e47495acd98bf3af48a9d14f48eb0 100644 --- a/CWeChatRobot/robotdata.h +++ b/CWeChatRobot/robotdata.h @@ -18,6 +18,8 @@ #include "VerifyFriendApply.h" #include "AddFriend.h" #include "wechatver.h" +#include "DeleteUser.h" +#include "SendAppMsg.h" extern HANDLE hProcess; extern DWORD SendImageOffset; @@ -26,6 +28,7 @@ extern DWORD SendFileOffset; extern DWORD SendArticleOffset; extern DWORD SendCardOffset; extern DWORD SendAtTextOffset; +extern DWORD SendAppMsgRemoteOffset; extern DWORD GetFriendListInitOffset; extern DWORD GetFriendListRemoteOffset; @@ -59,6 +62,7 @@ extern DWORD BackupSQLiteDBRemoteOffset; extern DWORD AddFriendByWxidRemoteOffset; extern DWORD AddFriendByV3RemoteOffset; +extern DWORD DeleteUserRemoteOffset; extern DWORD AddBrandContactRemoteOffset; extern DWORD HookImageMsgRemoteOffset; @@ -69,51 +73,53 @@ extern DWORD UnHookVoiceMsgRemoteOffset; extern DWORD ChangeWeChatVerRemoteOffset; -#define dllname L"DWeChatRobot.dll" +#define dllname L"DWeChatRobot.dll" -#define SendTextRemote "SendTextRemote" -#define SendImageRemote "SendImageRemote" -#define SendFileRemote "SendFileRemote" -#define SendArticleRemote "SendArticleRemote" -#define SendCardRemote "SendCardRemote" -#define SendAtTextRemote "SendAtTextRemote" +#define SendTextRemote "SendTextRemote" +#define SendImageRemote "SendImageRemote" +#define SendFileRemote "SendFileRemote" +#define SendArticleRemote "SendArticleRemote" +#define SendCardRemote "SendCardRemote" +#define SendAtTextRemote "SendAtTextRemote" +#define SendAppMsgRemote "SendAppMsgRemote" -#define GetFriendListInit "GetFriendListInit" -#define GetFriendListRemote "GetFriendListRemote" -#define GetFriendListFinish "GetFriendListFinish" +#define GetFriendListInit "GetFriendListInit" +#define GetFriendListRemote "GetFriendListRemote" +#define GetFriendListFinish "GetFriendListFinish" -#define GetWxUserInfoRemote "GetWxUserInfoRemote" -#define DeleteUserInfoCacheRemote "DeleteUserInfoCacheRemote" +#define GetWxUserInfoRemote "GetWxUserInfoRemote" +#define DeleteUserInfoCacheRemote "DeleteUserInfoCacheRemote" -#define GetSelfInfoRemote "GetSelfInfoRemote" -#define DeleteSelfInfoCacheRemote "DeleteSelfInfoCacheRemote" -#define SearchContactByNetRemote "SearchContactByNetRemote" +#define GetSelfInfoRemote "GetSelfInfoRemote" +#define DeleteSelfInfoCacheRemote "DeleteSelfInfoCacheRemote" +#define SearchContactByNetRemote "SearchContactByNetRemote" -#define VerifyFriendApplyRemote "VerifyFriendApplyRemote" +#define VerifyFriendApplyRemote "VerifyFriendApplyRemote" -#define CheckFriendStatusInitRemote "CheckFriendStatusInitRemote" -#define CheckFriendStatusRemote "CheckFriendStatusRemote" -#define CheckFriendStatusFinishRemote "CheckFriendStatusFinishRemote" +#define CheckFriendStatusInitRemote "CheckFriendStatusInitRemote" +#define CheckFriendStatusRemote "CheckFriendStatusRemote" +#define CheckFriendStatusFinishRemote "CheckFriendStatusFinishRemote" -#define HookReceiveMessageRemote "HookReceiveMessage" -#define UnHookReceiveMessageRemote "UnHookReceiveMessage" -#define GetHeadMessageRemote "GetHeadMessage" -#define PopHeadMessageRemote "PopHeadMessage" +#define HookReceiveMessageRemote "HookReceiveMessage" +#define UnHookReceiveMessageRemote "UnHookReceiveMessage" +#define GetHeadMessageRemote "GetHeadMessage" +#define PopHeadMessageRemote "PopHeadMessage" -#define GetChatRoomMembersRemote "GetChatRoomMembersRemote" +#define GetChatRoomMembersRemote "GetChatRoomMembersRemote" -#define GetDbHandlesRemote "GetDbHandlesRemote" -#define ExecuteSQLRemote "ExecuteSQLRemote" -#define SelectDataRemote "SelectDataRemote" -#define BackupSQLiteDBRemote "BackupSQLiteDBRemote" +#define GetDbHandlesRemote "GetDbHandlesRemote" +#define ExecuteSQLRemote "ExecuteSQLRemote" +#define SelectDataRemote "SelectDataRemote" +#define BackupSQLiteDBRemote "BackupSQLiteDBRemote" -#define AddFriendByWxidRemote "AddFriendByWxidRemote" -#define AddFriendByV3Remote "AddFriendByV3Remote" -#define AddBrandContactRemote "AddBrandContactRemote" +#define AddFriendByWxidRemote "AddFriendByWxidRemote" +#define AddFriendByV3Remote "AddFriendByV3Remote" +#define DeleteUserRemote "DeleteUserRemote" +#define AddBrandContactRemote "AddBrandContactRemote" -#define HookImageMsgRemote "HookImageMsgRemote" -#define UnHookImageMsgRemote "UnHookImageMsg" -#define HookVoiceMsgRemote "HookVoiceMsgRemote" -#define UnHookVoiceMsgRemote "UnHookVoiceMsg" +#define HookImageMsgRemote "HookImageMsgRemote" +#define UnHookImageMsgRemote "UnHookImageMsg" +#define HookVoiceMsgRemote "HookVoiceMsgRemote" +#define UnHookVoiceMsgRemote "UnHookVoiceMsg" -#define ChangeWeChatVerRemote "ChangeWeChatVerRemote" \ No newline at end of file +#define ChangeWeChatVerRemote "ChangeWeChatVerRemote" \ No newline at end of file diff --git a/ComWeChatRobot.sln b/ComWeChatRobot.sln index 747313538b1edb96ac5a60687e7b2d8b2d81001e..ecb0fd164fd833e1630f5b071f789bda343c908e 100644 --- a/ComWeChatRobot.sln +++ b/ComWeChatRobot.sln @@ -13,7 +13,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wxRobot", "wxRobot", "{8E5B EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Python", "Python", "{9533FA77-5AB8-473D-83D5-55E07137401E}" ProjectSection(SolutionItems) = preProject - wxRobot.py = wxRobot.py + Python\wxRobot.py = Python\wxRobot.py EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CSharp", "CSharp", "{4DE1F624-3F17-44E8-9B1F-28D88285D25F}" diff --git a/DWeChatRobot/DeleteUser.cpp b/DWeChatRobot/DeleteUser.cpp index e9a058ca7cf7fa04ac7cce73e2d461f6f9800725..7bcff42780d47ebb4e1aca2a42f2d741e91a729a 100644 --- a/DWeChatRobot/DeleteUser.cpp +++ b/DWeChatRobot/DeleteUser.cpp @@ -29,4 +29,9 @@ BOOL __stdcall DeleteUser(wchar_t* wxid) { popad; } return isSuccess; +} + +BOOL DeleteUserRemote(LPVOID lpParameter) { + BOOL isSuccess = DeleteUser((wchar_t*)lpParameter); + return isSuccess; } \ No newline at end of file diff --git a/DWeChatRobot/DeleteUser.h b/DWeChatRobot/DeleteUser.h index 225175d961f7b3320a7486efb52c1a414faf4ce0..3b6d82698d9f1618def9e89708778579e2879e07 100644 --- a/DWeChatRobot/DeleteUser.h +++ b/DWeChatRobot/DeleteUser.h @@ -1,3 +1,4 @@ #pragma once #include -BOOL __stdcall DeleteUser(wchar_t* wxid); \ No newline at end of file +BOOL __stdcall DeleteUser(wchar_t* wxid); +extern "C" __declspec(dllexport) BOOL DeleteUserRemote(LPVOID lpParameter); \ No newline at end of file diff --git a/DWeChatRobot/SendAppMsg.cpp b/DWeChatRobot/SendAppMsg.cpp index eb16285533abcbcab9e305ebbfca8e5f741a82ad..ae6d587cf641bbf3cba8041227fbaf112e0cbd5a 100644 --- a/DWeChatRobot/SendAppMsg.cpp +++ b/DWeChatRobot/SendAppMsg.cpp @@ -13,6 +13,11 @@ struct VectorStruct { DWORD v_end2; }; +struct SendAppMsgStruct { + wchar_t* wxid; + wchar_t* appid; +}; + BOOL __stdcall SendAppMsg(wchar_t* wxid,wchar_t* appid) { DWORD WeChatWinBase = GetWeChatWinBase(); DWORD SendAppMsgCall1 = WeChatWinBase + SendAppMsgCall1Offset; @@ -48,4 +53,10 @@ BOOL __stdcall SendAppMsg(wchar_t* wxid,wchar_t* appid) { popad; } return isSuccess; +} + +BOOL SendAppMsgRemote(LPVOID lpParameter) { + SendAppMsgStruct* sams = (SendAppMsgStruct*)lpParameter; + BOOL isSuccess = SendAppMsg(sams->wxid, sams->appid); + return isSuccess; } \ No newline at end of file diff --git a/DWeChatRobot/SendAppMsg.h b/DWeChatRobot/SendAppMsg.h index f09eea20fa81024a6236654592af1aa13ed09895..cbf8aead76aff8a4fe13f15d588971beedd052d2 100644 --- a/DWeChatRobot/SendAppMsg.h +++ b/DWeChatRobot/SendAppMsg.h @@ -1,3 +1,4 @@ #pragma once #include -BOOL __stdcall SendAppMsg(wchar_t* wxid, wchar_t* appid); \ No newline at end of file +BOOL __stdcall SendAppMsg(wchar_t* wxid, wchar_t* appid); +extern "C" __declspec(dllexport) BOOL SendAppMsgRemote(LPVOID lpParameter); \ No newline at end of file diff --git a/Python/wxRobot.py b/Python/wxRobot.py index 097ba19d66be8a5ac0dc4a33a39f08bb1cb53be6..f3b9daeb17a51a2800c8f6b34f601dc9a9c1cc03 100644 --- a/Python/wxRobot.py +++ b/Python/wxRobot.py @@ -55,6 +55,9 @@ class ChatSession(): if '@chatroom' not in self.chatwith: return 1 return self.robot.CSendAtText(self.chatwith,wxid,msg,AutoNickName) + + def SendAppMsg(self,appid): + return self.robot.CSendAppMsg(self.chatwith,appid) class WeChatRobot(): @@ -69,6 +72,26 @@ class WeChatRobot(): status = self.robot.CStartRobotService() return status + def SendText(self,receiver,msg): + return self.robot.CSendText(receiver,msg) + + def SendImage(self,receiver,imgpath): + return self.robot.CSendImage(receiver,imgpath) + + def SendFile(self,receiver,filepath): + return self.robot.CSendFile(receiver,filepath) + + def SendArticle(self,receiver,title,abstract,url,imgpath = None): + return self.robot.CSendArticle(receiver,title,abstract,url,imgpath) + + def SendCard(self,receiver,sharedwxid,nickname): + return self.robot.CSendCard(receiver,sharedwxid,nickname) + + def SendAtText(self,chatroomid,AtUsers:list or str or tuple,msg,AutoNickName = True): + if '@chatroom' not in chatroomid: + return 1 + return self.robot.CSendAtText(chatroomid,AtUsers,msg,AutoNickName) + def GetSelfInfo(self): myinfo = self.robot.CGetSelfInfo().replace('\n','\\n') try: @@ -301,4 +324,10 @@ class WeChatRobot(): return self.robot.CHookVoiceMsg(savepath) def UnHookVoiceMsg(self): - return self.robot.CUnHookVoiceMsg() \ No newline at end of file + return self.robot.CUnHookVoiceMsg() + + def DeleteUser(self,wxid): + return self.robot.CDeleteUser(wxid) + + def SendAppMsg(self,wxid,appid): + return self.robot.CSendAppMsg(wxid,appid) \ No newline at end of file diff --git a/README.md b/README.md index d13bf31f0edc8c6a812ec40147ad24e32e6b53be..2bcd0704ed38d4dbbca736b944ff2b795728889d 100644 --- a/README.md +++ b/README.md @@ -49,8 +49,8 @@ CWeChatRobot.exe /unregserver 参考[Program.cs](/wxRobot/Program.cs) # 更多功能 后续计划功能: -1. 好友相关操作,删除好友、修改备注等 -2. 分享小程序接口 +1. 修改好友备注 +2. 优化语音和图片Hook 有空的时候会按照上述顺序进行开发,不过嘛,计划只是计划,如果未实现也请见谅 **也欢迎您提交PR** @@ -88,6 +88,11 @@ CWeChatRobot.exe /unregserver ## 2022.06.10 1. 新增关注公众号、网络查询用户信息、Hook语音、未加密图片、自定义微信版本号接口 2. Hook语音和图片的接口暂时还有瑕疵,图片收到后有可能不会自动下载;语音消息的文件名暂时是时间戳,计划替换为该条消息id。有空再做优化。 +## 2022.06.13 +1. 优化发送艾特消息接口,新增一个参数,指示是否自动填充被艾特人昵称 +2. 优化发送文章消息接口,新增一个参数,用于展示消息卡片缩略图 +3. 新增删除好友接口 +4. 新增发送小程序接口 # 打赏作者 请给作者一个star,感谢感谢 # 免责声明 diff --git a/Release/CWeChatRobot.exe b/Release/CWeChatRobot.exe index e6ecc3738673d3653b31d97509490c98e5cf5d22..5b756837d02ab29e8cbbd1a943b7cf9b17a7d6fb 100644 Binary files a/Release/CWeChatRobot.exe and b/Release/CWeChatRobot.exe differ diff --git a/Release/DWeChatRobot.dll b/Release/DWeChatRobot.dll index b2c8f23eb059937e1feb30de2fc2e04906ee18ec..24b8274b802d27bb35a993ad9867d433cb11dff3 100644 Binary files a/Release/DWeChatRobot.dll and b/Release/DWeChatRobot.dll differ