提交 6317d846 编写于 作者: L ljc545w

新增关注公众号接口

上级 4abf77fe
#include "pch.h"
BOOL AddBrandContact(wchar_t* PublicId) {
if (!hProcess)
return 1;
DWORD WeChatRobotBase = GetWeChatRobotBase();
DWORD dwId = 0;
DWORD dwWriteSize = 0;
DWORD dwRet = 1;
LPVOID PublicIdaddr = VirtualAllocEx(hProcess, NULL, 1, MEM_COMMIT, PAGE_READWRITE);
if (!PublicIdaddr)
return 1;
WriteProcessMemory(hProcess, PublicIdaddr, PublicId, wcslen(PublicId) * 2 + 2, &dwWriteSize);
DWORD AddBrandContactAddr = WeChatRobotBase + AddBrandContactRemoteOffset;
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE)AddBrandContactAddr, (LPVOID)PublicIdaddr, 0, &dwId);
if (hThread) {
WaitForSingleObject(hThread, INFINITE);
GetExitCodeThread(hThread, &dwRet);
CloseHandle(hThread);
}
VirtualFreeEx(hProcess, PublicIdaddr, 0, MEM_RELEASE);
return dwRet == 0;
}
\ No newline at end of file
......@@ -2,4 +2,5 @@
#include<windows.h>
BOOL AddFriendByWxid(wchar_t* wxid, wchar_t* message);
BOOL AddFriendByV3(wchar_t* v3, wchar_t* message,int AddType);
\ No newline at end of file
BOOL AddFriendByV3(wchar_t* v3, wchar_t* message,int AddType);
BOOL AddBrandContact(wchar_t* PublicId);
\ No newline at end of file
......@@ -300,4 +300,13 @@ STDMETHODIMP CWeChatRobot::CSearchContactByNet(BSTR keyword, VARIANT* __result)
V_ARRAY(&vsaValue) = SearchContactByNet(keyword);
*__result = vsaValue;
return S_OK;
}
/*
* 参数1:公众号id
* 参数2:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CAddBrandContact(BSTR PublicId, int* __result) {
*__result = AddBrandContact(PublicId);
return S_OK;
}
\ No newline at end of file
......@@ -80,6 +80,7 @@ public:
STDMETHODIMP CGetWeChatVer(BSTR* __result);
STDMETHODIMP CStartWeChat(int* __result);
STDMETHODIMP CSearchContactByNet(BSTR keyword, VARIANT* __result);
STDMETHODIMP CAddBrandContact(BSTR PublicId, int* __result);
};
OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot)
......@@ -45,6 +45,7 @@ interface IWeChatRobot : IDispatch
[id(27)] HRESULT CGetWeChatVer([out, retval] BSTR* __result);
[id(28)] HRESULT CStartWeChat([out, retval] int* __result);
[id(29)] HRESULT CSearchContactByNet([in] BSTR keyword, [out, retval] VARIANT* __result);
[id(30)] HRESULT CAddBrandContact([in] BSTR PublicId, [out, retval] int* __result);
};
[
uuid(721abb35-141a-4aa2-94f2-762e2833fa6c),
......
......@@ -239,6 +239,7 @@
<ClInclude Include="xdlldata.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="AddBrandContact.cpp" />
<ClCompile Include="AddFriendByV3.cpp" />
<ClCompile Include="AddFriendByWxid.cpp" />
<ClCompile Include="CheckFriendStatus.cpp" />
......
......@@ -240,6 +240,9 @@
<ClCompile Include="SearchContactByNet.cpp">
<Filter>好友相关\搜索好友</Filter>
</ClCompile>
<ClCompile Include="AddBrandContact.cpp">
<Filter>好友相关\添加好友</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
......
......@@ -206,6 +206,10 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ BSTR keyword,
/* [retval][out] */ VARIANT *__result) = 0;
virtual /* [id] */ HRESULT STDMETHODCALLTYPE CAddBrandContact(
/* [in] */ BSTR PublicId,
/* [retval][out] */ int *__result) = 0;
};
......@@ -411,6 +415,11 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ BSTR keyword,
/* [retval][out] */ VARIANT *__result);
/* [id] */ HRESULT ( STDMETHODCALLTYPE *CAddBrandContact )(
IWeChatRobot * This,
/* [in] */ BSTR PublicId,
/* [retval][out] */ int *__result);
END_INTERFACE
} IWeChatRobotVtbl;
......@@ -534,6 +543,9 @@ EXTERN_C const IID IID_IWeChatRobot;
#define IWeChatRobot_CSearchContactByNet(This,keyword,__result) \
( (This)->lpVtbl -> CSearchContactByNet(This,keyword,__result) )
#define IWeChatRobot_CAddBrandContact(This,PublicId,__result) \
( (This)->lpVtbl -> CAddBrandContact(This,PublicId,__result) )
#endif /* COBJMACROS */
......
......@@ -49,7 +49,7 @@
#include "WeChatRobotCOM_i.h"
#define TYPE_FORMAT_STRING_SIZE 1239
#define PROC_FORMAT_STRING_SIZE 1231
#define PROC_FORMAT_STRING_SIZE 1273
#define EXPR_FORMAT_STRING_SIZE 1
#define TRANSMIT_AS_TABLE_SIZE 0
#define WIRE_MARSHAL_TABLE_SIZE 2
......@@ -1184,6 +1184,43 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor
/* 1228 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CAddBrandContact */
/* 1230 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 1232 */ NdrFcLong( 0x0 ), /* 0 */
/* 1236 */ NdrFcShort( 0x24 ), /* 36 */
/* 1238 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
/* 1240 */ NdrFcShort( 0x0 ), /* 0 */
/* 1242 */ NdrFcShort( 0x24 ), /* 36 */
/* 1244 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */
0x3, /* 3 */
/* 1246 */ 0x8, /* 8 */
0x45, /* Ext Flags: new corr desc, srv corr check, has range on conformance */
/* 1248 */ NdrFcShort( 0x0 ), /* 0 */
/* 1250 */ NdrFcShort( 0x1 ), /* 1 */
/* 1252 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter PublicId */
/* 1254 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
/* 1256 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
/* 1258 */ NdrFcShort( 0x2a ), /* Type Offset=42 */
/* Parameter __result */
/* 1260 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 1262 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 1264 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Return value */
/* 1266 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 1268 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 1270 */ 0x8, /* FC_LONG */
0x0, /* 0 */
0x0
}
};
......@@ -2057,7 +2094,8 @@ static const unsigned short IWeChatRobot_FormatStringOffsetTable[] =
1062,
1116,
1152,
1188
1188,
1230
};
static const MIDL_STUBLESS_PROXY_INFO IWeChatRobot_ProxyInfo =
......@@ -2081,7 +2119,7 @@ static const MIDL_SERVER_INFO IWeChatRobot_ServerInfo =
0,
0,
0};
CINTERFACE_PROXY_VTABLE(36) _IWeChatRobotProxyVtbl =
CINTERFACE_PROXY_VTABLE(37) _IWeChatRobotProxyVtbl =
{
&IWeChatRobot_ProxyInfo,
&IID_IWeChatRobot,
......@@ -2120,7 +2158,8 @@ CINTERFACE_PROXY_VTABLE(36) _IWeChatRobotProxyVtbl =
(void *) (INT_PTR) -1 /* IWeChatRobot::CAddFriendByV3 */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetWeChatVer */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CStartWeChat */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CSearchContactByNet */
(void *) (INT_PTR) -1 /* IWeChatRobot::CSearchContactByNet */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CAddBrandContact */
};
......@@ -2158,6 +2197,7 @@ static const PRPC_STUB_FUNCTION IWeChatRobot_table[] =
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2
};
......@@ -2165,7 +2205,7 @@ CInterfaceStubVtbl _IWeChatRobotStubVtbl =
{
&IID_IWeChatRobot,
&IWeChatRobot_ServerInfo,
36,
37,
&IWeChatRobot_table[-3],
CStdStubBuffer_DELEGATING_METHODS
};
......
......@@ -41,6 +41,7 @@ DWORD BackupSQLiteDBRemoteOffset = 0x0;
DWORD AddFriendByWxidRemoteOffset = 0x0;
DWORD AddFriendByV3RemoteOffset = 0x0;
DWORD AddBrandContactRemoteOffset = 0x0;
wstring SelfInfoString = L"";
......@@ -169,6 +170,8 @@ BOOL GetProcOffset(wchar_t* workPath) {
AddFriendByWxidRemoteOffset = AddFriendByWxidRemoteAddr - WeChatBase;
DWORD AddFriendByV3RemoteAddr = (DWORD)GetProcAddress(hd, AddFriendByV3Remote);
AddFriendByV3RemoteOffset = AddFriendByV3RemoteAddr - WeChatBase;
DWORD AddBrandContactRemoteAddr = (DWORD)GetProcAddress(hd, AddBrandContactRemote);
AddBrandContactRemoteOffset = AddBrandContactRemoteAddr - WeChatBase;
FreeLibrary(hd);
delete[] dllpath;
......
......@@ -58,6 +58,7 @@ extern DWORD BackupSQLiteDBRemoteOffset;
extern DWORD AddFriendByWxidRemoteOffset;
extern DWORD AddFriendByV3RemoteOffset;
extern DWORD AddBrandContactRemoteOffset;
#define dllname L"DWeChatRobot.dll"
......@@ -99,4 +100,5 @@ extern DWORD AddFriendByV3RemoteOffset;
#define BackupSQLiteDBRemote "BackupSQLiteDBRemote"
#define AddFriendByWxidRemote "AddFriendByWxidRemote"
#define AddFriendByV3Remote "AddFriendByV3Remote"
\ No newline at end of file
#define AddFriendByV3Remote "AddFriendByV3Remote"
#define AddBrandContactRemote "AddBrandContactRemote"
\ No newline at end of file
#include "pch.h"
#define AddPublicNoticeCallOffset 0x64DAC1C4 - 0x62D70000
#define AddPublicNoticeParamOffset 0x64C51DC4 - 0x62D70000
struct AddBrandContactStruct {
DWORD handle;
WxString command;
char buffer1[0x28] = { 0 };
WxString params;
char buffer2[0x7C] = { 0 };
AddBrandContactStruct(wchar_t* param) {
command.buffer = (wchar_t*)L"quicklyAddBrandContact";
command.length = wcslen(command.buffer);
command.maxLength = command.length * 2;
params.buffer = param;
params.length = wcslen(param);
params.maxLength = wcslen(param) * 2;
}
};
BOOL __stdcall AddBrandContact(wchar_t* PublicId) {
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD AddPublicNoticeCall = WeChatWinBase + AddPublicNoticeCallOffset;
DWORD AddPublicNoticeParam = WeChatWinBase + AddPublicNoticeParamOffset;
wchar_t url[0x100] = { 0 };
swprintf_s(url, L"weixin://resourceid/Subscription/profile.html?userName=%ws", PublicId);
WxBaseStruct ptrurl(url);
wchar_t param[0x100] = { 0 };
swprintf_s(param, L"{\"username\":\"%ws\",\"webtype\":\"1\"}\n", PublicId);
AddBrandContactStruct ptrparam(param);
ptrparam.handle = AddPublicNoticeParam;
DWORD NoticeCallHandle[10] = { 0 };
NoticeCallHandle[0] = AddPublicNoticeCall;
BOOL isSuccess = 0x0;
__asm {
pushad;
pushfd;
lea eax, ptrparam;
push eax;
lea eax, NoticeCallHandle;
mov edx, dword ptr [eax];
mov ecx, eax;
lea esi, ptrurl;
push esi;
mov edi, 0x3;
push edi;
call dword ptr [edx + 0x4];
mov isSuccess, eax;
popfd;
popad;
}
return isSuccess;
}
BOOL AddBrandContactRemote(LPVOID lpParameter) {
int isSuccess = AddBrandContact((wchar_t*)lpParameter);
return isSuccess;
}
\ No newline at end of file
......@@ -3,5 +3,7 @@
BOOL __stdcall AddFriendByV3(wchar_t* v3, wchar_t* message,int AddType);
BOOL __stdcall AddFriendByWxid(wchar_t* wxid, wchar_t* message);
BOOL __stdcall AddBrandContact(wchar_t* PublicId);
extern "C" __declspec(dllexport) BOOL AddFriendByV3Remote(LPVOID lpParameter);
extern "C" __declspec(dllexport) BOOL AddFriendByWxidRemote(LPVOID lpParameter);
\ No newline at end of file
extern "C" __declspec(dllexport) BOOL AddFriendByWxidRemote(LPVOID lpParameter);
extern "C" __declspec(dllexport) BOOL AddBrandContactRemote(LPVOID lpParameter);
\ No newline at end of file
......@@ -179,6 +179,7 @@
<ItemGroup>
<ClCompile Include="AddFriendByV3.cpp" />
<ClCompile Include="AddFriendByWxid.cpp" />
<ClCompile Include="AddBrandContact.cpp" />
<ClCompile Include="CheckFriendStatus.cpp" />
<ClCompile Include="DbBackup.cpp" />
<ClCompile Include="DbExecuteSql.cpp" />
......
......@@ -215,5 +215,8 @@
<ClCompile Include="SearchContactByNet.cpp">
<Filter>好友相关\搜索好友</Filter>
</ClCompile>
<ClCompile Include="AddBrandContact.cpp">
<Filter>好友相关\添加好友</Filter>
</ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -13,7 +13,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,
#ifdef _DEBUG
if (ProcessIsWeChat()) {
PrintProcAddr();
// HookLogMsgInfo();
HookLogMsgInfo();
}
#endif
break;
......
......@@ -172,6 +172,7 @@ void PrintProcAddr() {
printf("VerifyFriendApply 0x%08X\n", (DWORD)VerifyFriendApply);
printf("AddFriendByV3 0x%08X\n", (DWORD)AddFriendByV3);
printf("AddFriendByWxid 0x%08X\n", (DWORD)AddFriendByWxid);
printf("AddBrandContact 0x%08X\n", (DWORD)AddBrandContact);
printf("SelectDataRemote 0x%08X\n", (DWORD)SelectDataRemote);
printf("SearchContactByNet 0x%08X\n", (DWORD)SearchContactByNet);
printf("SearchContactByNetRemote 0x%08X\n", (DWORD)SearchContactByNetRemote);
......
......@@ -36,6 +36,7 @@
using namespace std;
#pragma comment(lib,"version.lib")
#pragma warning(disable:4731)
// 对于导出函数,需要使用此宏修饰
#define DLLEXPORT extern "C" __declspec(dllexport)
......
......@@ -265,4 +265,7 @@ class WeChatRobot():
userinfo = self.robot.CSearchContactByNet(keyword)
if userinfo:
return dict(userinfo)
return userinfo
\ No newline at end of file
return userinfo
def AddBrandContact(self,PublicId):
return self.robot.CAddBrandContact(PublicId)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册