Skip to content

Commit

Permalink
Merge pull request #141 from ljc545w/add/voipAck-support
Browse files Browse the repository at this point in the history
新增收款功能与部分接口优化
  • Loading branch information
ljc545w authored Oct 20, 2022
2 parents 97c2b6b + 3d5b4fe commit 042327a
Show file tree
Hide file tree
Showing 28 changed files with 399 additions and 68 deletions.
27 changes: 27 additions & 0 deletions CWeChatRobot/GetTransfer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include "pch.h"

struct GetTransferStruct
{
DWORD wxid = 0;
DWORD transcationid = 0;
DWORD transferid = 0;
};

int GetTransfer(DWORD pid, wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid)
{
WeChatProcess hp(pid);
if (hp.m_init == false)
return 1;
DWORD GetTransferRemoteAddr = hp.GetProcAddr(GetTransferRemote);
if (GetTransferRemoteAddr == 0)
return 1;
WeChatData<wchar_t *> r_wxid(hp.GetHandle(), wxid, TEXTLENGTH(wxid));
WeChatData<wchar_t *> r_transcationid(hp.GetHandle(), transcationid, TEXTLENGTH(transcationid));
WeChatData<wchar_t *> r_transferid(hp.GetHandle(), transferid, TEXTLENGTH(transferid));
GetTransferStruct param = {(DWORD)r_wxid.GetAddr(), (DWORD)r_transcationid.GetAddr(), (DWORD)r_transferid.GetAddr()};
WeChatData<GetTransferStruct *> r_param(hp.GetHandle(), &param, sizeof(GetTransferStruct));
if (!r_param.GetAddr() || !r_wxid.GetAddr() || !r_transcationid.GetAddr() || !r_transferid.GetAddr())
return 1;
DWORD dwRet = CallRemoteFunction(hp.GetHandle(), GetTransferRemoteAddr, r_param.GetAddr());
return (dwRet != 1);
}
3 changes: 3 additions & 0 deletions CWeChatRobot/GetTransfer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once
#include <windows.h>
int GetTransfer(DWORD pid, wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid);
25 changes: 15 additions & 10 deletions CWeChatRobot/SendImage.cpp
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
#include "pch.h"

struct ImageParamStruct {
struct ImageParamStruct
{
DWORD wxid;
DWORD imagepath;
};

int SendImage(DWORD pid,wchar_t* wxid, wchar_t* imagepath) {
int SendImage(DWORD pid, wchar_t *wxid, wchar_t *imagepath)
{
WeChatProcess hp(pid);
if (!hp.m_init) return 1;
if (!hp.m_init)
return 1;
DWORD SendImageRemoteAddr = hp.GetProcAddr(SendImageRemote);
if (SendImageRemoteAddr == 0) {
if (SendImageRemoteAddr == 0)
{
return 1;
}
ImageParamStruct params = { 0 };
WeChatData<wchar_t*> r_wxid(hp.GetHandle(), wxid, TEXTLENGTH(wxid));
WeChatData<wchar_t*> r_imagepath(hp.GetHandle(), imagepath, TEXTLENGTH(imagepath));
ImageParamStruct params = {0};
WeChatData<wchar_t *> r_wxid(hp.GetHandle(), wxid, TEXTLENGTH(wxid));
WeChatData<wchar_t *> r_imagepath(hp.GetHandle(), imagepath, TEXTLENGTH(imagepath));

params.wxid = (DWORD)r_wxid.GetAddr();
params.imagepath = (DWORD)r_imagepath.GetAddr();
WeChatData<ImageParamStruct*> r_params(hp.GetHandle(), &params, sizeof(params));
if (!params.wxid || !params.imagepath || !r_params.GetAddr()) {
WeChatData<ImageParamStruct *> r_params(hp.GetHandle(), &params, sizeof(params));
if (!params.wxid || !params.imagepath || !r_params.GetAddr())
{
return 1;
}
DWORD dwRet = CallRemoteFunction(hp.GetHandle(), SendImageRemoteAddr, r_params.GetAddr());
return 0;
return (dwRet != 1);
}
13 changes: 13 additions & 0 deletions CWeChatRobot/WeChatRobot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,3 +613,16 @@ STDMETHODIMP CWeChatRobot::CLogout(DWORD pid, int *__result)
*__result = Logout(pid);
return S_OK;
}

/*
* 参数0:目标进程pid
* 参数1:转账人wxid
* 参数2:从xml中获取的transcationid
* 参数3:从xml中获取的transferid
* 参数4:预返回的值,调用时无需提供
*/
STDMETHODIMP CWeChatRobot::CGetTransfer(DWORD pid, BSTR wxid, BSTR transcationid, BSTR transferid, int *__result)
{
*__result = GetTransfer(pid, wxid, transcationid, transferid);
return S_OK;
}
1 change: 1 addition & 0 deletions CWeChatRobot/WeChatRobot.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class ATL_NO_VTABLE CWeChatRobot : public CComObjectRootEx<CComSingleThreadModel
STDMETHODIMP CGetA8Key(DWORD pid, BSTR url, BSTR *__result);
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);
};

OBJECT_ENTRY_AUTO(__uuidof(WeChatRobot), CWeChatRobot)
1 change: 1 addition & 0 deletions CWeChatRobot/WeChatRobotCOM.idl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ interface IWeChatRobot : IDispatch
[id(50), helpstring("获取A8Key")] HRESULT CGetA8Key([in] DWORD pid, [in] BSTR url, [ out, retval ] BSTR * __result);
[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);
};
[
object,
Expand Down
2 changes: 2 additions & 0 deletions CWeChatRobot/WeChatRobotCOM.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@
<ClInclude Include="GetChatRoomMembers.h" />
<ClInclude Include="GetDbHandles.h" />
<ClInclude Include="GetHistoryPublicMsg.h" />
<ClInclude Include="GetTransfer.h" />
<ClInclude Include="InjectDll.h" />
<ClInclude Include="Logout.h" />
<ClInclude Include="ntapi.h" />
Expand Down Expand Up @@ -288,6 +289,7 @@
<ClCompile Include="GetChatRoomMembers.cpp" />
<ClCompile Include="GetDbHandles.cpp" />
<ClCompile Include="GetHistoryPublicMsg.cpp" />
<ClCompile Include="GetTransfer.cpp" />
<ClCompile Include="HookImageMessage.cpp" />
<ClCompile Include="HookVoiceMessage.cpp" />
<ClCompile Include="InjectDll.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 @@ -143,6 +143,12 @@
<Filter Include="登录相关\退出登录">
<UniqueIdentifier>{33279923-8158-4b6f-af06-e7f093852e5d}</UniqueIdentifier>
</Filter>
<Filter Include="未分类">
<UniqueIdentifier>{26820c31-881e-44a6-8c53-b26379ce9b39}</UniqueIdentifier>
</Filter>
<Filter Include="未分类\收款">
<UniqueIdentifier>{79bb1058-041b-4bdc-8678-0369c294e570}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
Expand Down Expand Up @@ -289,6 +295,9 @@
<ClInclude Include="Logout.h">
<Filter>登录相关\退出登录</Filter>
</ClInclude>
<ClInclude Include="GetTransfer.h">
<Filter>未分类\收款</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WeChatRobotCOM.cpp">
Expand Down Expand Up @@ -435,6 +444,9 @@
<ClCompile Include="Logout.cpp">
<Filter>登录相关\退出登录</Filter>
</ClCompile>
<ClCompile Include="GetTransfer.cpp">
<Filter>未分类\收款</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
Expand Down
18 changes: 18 additions & 0 deletions CWeChatRobot/WeChatRobotCOM_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ DWORD pid,
/* [retval][out] */ int *__result) = 0;

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

};


Expand Down Expand Up @@ -735,6 +742,14 @@ EXTERN_C const IID IID_IWeChatRobot;
/* [in] */ DWORD pid,
/* [retval][out] */ int *__result);

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

END_INTERFACE
} IWeChatRobotVtbl;

Expand Down Expand Up @@ -918,6 +933,9 @@ EXTERN_C const IID IID_IWeChatRobot;
#define IWeChatRobot_CLogout(This,pid,__result) \
( (This)->lpVtbl -> CLogout(This,pid,__result) )

#define IWeChatRobot_CGetTransfer(This,pid,wxid,transcationid,transferid,__result) \
( (This)->lpVtbl -> CGetTransfer(This,pid,wxid,transcationid,transferid,__result) )

#endif /* COBJMACROS */


Expand Down
Loading

0 comments on commit 042327a

Please sign in to comment.