未验证 提交 042327af 编写于 作者: J Jack Li 提交者: GitHub

Merge pull request #141 from ljc545w/add/voipAck-support

新增收款功能与部分接口优化
#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);
}
#pragma once
#include <windows.h>
int GetTransfer(DWORD pid, wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid);
#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);
}
......@@ -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;
}
......@@ -90,6 +90,7 @@ public:
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)
......@@ -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,
......
......@@ -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" />
......@@ -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" />
......
......@@ -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">
......@@ -289,6 +295,9 @@
<ClInclude Include="Logout.h">
<Filter>登录相关\退出登录</Filter>
</ClInclude>
<ClInclude Include="GetTransfer.h">
<Filter>未分类\收款</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="WeChatRobotCOM.cpp">
......@@ -435,6 +444,9 @@
<ClCompile Include="Logout.cpp">
<Filter>登录相关\退出登录</Filter>
</ClCompile>
<ClCompile Include="GetTransfer.cpp">
<Filter>未分类\收款</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="WeChatRobotCOM.rc">
......
......@@ -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;
};
......@@ -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;
......@@ -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 */
......
......@@ -49,7 +49,7 @@
#include "WeChatRobotCOM_i.h"
#define TYPE_FORMAT_STRING_SIZE 1239
#define PROC_FORMAT_STRING_SIZE 2533
#define PROC_FORMAT_STRING_SIZE 2593
#define EXPR_FORMAT_STRING_SIZE 1
#define TRANSMIT_AS_TABLE_SIZE 0
#define WIRE_MARSHAL_TABLE_SIZE 2
......@@ -2331,14 +2331,14 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor
/* 2422 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CPostMessage */
/* Procedure CGetTransfer */
/* 2424 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 2426 */ NdrFcLong( 0x0 ), /* 0 */
/* 2430 */ NdrFcShort( 0x7 ), /* 7 */
/* 2432 */ NdrFcShort( 0x20 ), /* x86 Stack size/offset = 32 */
/* 2434 */ NdrFcShort( 0x20 ), /* 32 */
/* 2430 */ NdrFcShort( 0x38 ), /* 56 */
/* 2432 */ NdrFcShort( 0x1c ), /* x86 Stack size/offset = 28 */
/* 2434 */ NdrFcShort( 0x8 ), /* 8 */
/* 2436 */ NdrFcShort( 0x24 ), /* 36 */
/* 2438 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */
0x6, /* 6 */
......@@ -2355,55 +2355,53 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor
/* 2452 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Parameter msgtype */
/* Parameter wxid */
/* 2454 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
/* 2454 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
/* 2456 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 2458 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* 2458 */ NdrFcShort( 0x2a ), /* Type Offset=42 */
/* Parameter msgid */
/* Parameter transcationid */
/* 2460 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
/* 2460 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
/* 2462 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 2464 */ 0xb, /* FC_HYPER */
0x0, /* 0 */
/* 2464 */ NdrFcShort( 0x2a ), /* Type Offset=42 */
/* Parameter msg */
/* Parameter transferid */
/* 2466 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */
/* 2468 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */
/* 2470 */ NdrFcShort( 0x4cc ), /* Type Offset=1228 */
/* 2466 */ NdrFcShort( 0x8b ), /* Flags: must size, must free, in, by val, */
/* 2468 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
/* 2470 */ NdrFcShort( 0x2a ), /* Type Offset=42 */
/* Parameter __result */
/* 2472 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 2474 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */
/* 2474 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */
/* 2476 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Return value */
/* 2478 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 2480 */ NdrFcShort( 0x1c ), /* x86 Stack size/offset = 28 */
/* 2480 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */
/* 2482 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CRegisterWxPidWithCookie */
/* Procedure CPostMessage */
/* 2484 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 2486 */ NdrFcLong( 0x0 ), /* 0 */
/* 2490 */ NdrFcShort( 0x8 ), /* 8 */
/* 2492 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */
/* 2494 */ NdrFcShort( 0x10 ), /* 16 */
/* 2490 */ NdrFcShort( 0x7 ), /* 7 */
/* 2492 */ NdrFcShort( 0x20 ), /* x86 Stack size/offset = 32 */
/* 2494 */ NdrFcShort( 0x20 ), /* 32 */
/* 2496 */ NdrFcShort( 0x24 ), /* 36 */
/* 2498 */ 0x44, /* Oi2 Flags: has return, has ext, */
0x4, /* 4 */
/* 2498 */ 0x46, /* Oi2 Flags: clt must size, has return, has ext, */
0x6, /* 6 */
/* 2500 */ 0x8, /* 8 */
0x41, /* Ext Flags: new corr desc, has range on conformance */
0x45, /* Ext Flags: new corr desc, srv corr check, has range on conformance */
/* 2502 */ NdrFcShort( 0x0 ), /* 0 */
/* 2504 */ NdrFcShort( 0x0 ), /* 0 */
/* 2504 */ NdrFcShort( 0x1 ), /* 1 */
/* 2506 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter pid */
......@@ -2413,25 +2411,83 @@ static const WeChatRobotCOM_MIDL_PROC_FORMAT_STRING WeChatRobotCOM__MIDL_ProcFor
/* 2512 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Parameter cookie */
/* Parameter msgtype */
/* 2514 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
/* 2516 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 2518 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Parameter __result */
/* Parameter msgid */
/* 2520 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 2520 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
/* 2522 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 2524 */ 0x8, /* FC_LONG */
/* 2524 */ 0xb, /* FC_HYPER */
0x0, /* 0 */
/* Parameter msg */
/* 2526 */ NdrFcShort( 0x10b ), /* Flags: must size, must free, in, simple ref, */
/* 2528 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */
/* 2530 */ NdrFcShort( 0x4cc ), /* Type Offset=1228 */
/* Parameter __result */
/* 2532 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 2534 */ NdrFcShort( 0x18 ), /* x86 Stack size/offset = 24 */
/* 2536 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Return value */
/* 2526 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 2528 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
/* 2530 */ 0x8, /* FC_LONG */
/* 2538 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 2540 */ NdrFcShort( 0x1c ), /* x86 Stack size/offset = 28 */
/* 2542 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Procedure CRegisterWxPidWithCookie */
/* 2544 */ 0x33, /* FC_AUTO_HANDLE */
0x6c, /* Old Flags: object, Oi2 */
/* 2546 */ NdrFcLong( 0x0 ), /* 0 */
/* 2550 */ NdrFcShort( 0x8 ), /* 8 */
/* 2552 */ NdrFcShort( 0x14 ), /* x86 Stack size/offset = 20 */
/* 2554 */ NdrFcShort( 0x10 ), /* 16 */
/* 2556 */ NdrFcShort( 0x24 ), /* 36 */
/* 2558 */ 0x44, /* Oi2 Flags: has return, has ext, */
0x4, /* 4 */
/* 2560 */ 0x8, /* 8 */
0x41, /* Ext Flags: new corr desc, has range on conformance */
/* 2562 */ NdrFcShort( 0x0 ), /* 0 */
/* 2564 */ NdrFcShort( 0x0 ), /* 0 */
/* 2566 */ NdrFcShort( 0x0 ), /* 0 */
/* Parameter pid */
/* 2568 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
/* 2570 */ NdrFcShort( 0x4 ), /* x86 Stack size/offset = 4 */
/* 2572 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Parameter cookie */
/* 2574 */ NdrFcShort( 0x48 ), /* Flags: in, base type, */
/* 2576 */ NdrFcShort( 0x8 ), /* x86 Stack size/offset = 8 */
/* 2578 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Parameter __result */
/* 2580 */ NdrFcShort( 0x2150 ), /* Flags: out, base type, simple ref, srv alloc size=8 */
/* 2582 */ NdrFcShort( 0xc ), /* x86 Stack size/offset = 12 */
/* 2584 */ 0x8, /* FC_LONG */
0x0, /* 0 */
/* Return value */
/* 2586 */ NdrFcShort( 0x70 ), /* Flags: out, return, base type, */
/* 2588 */ NdrFcShort( 0x10 ), /* x86 Stack size/offset = 16 */
/* 2590 */ 0x8, /* FC_LONG */
0x0, /* 0 */
0x0
......@@ -3327,7 +3383,8 @@ static const unsigned short IWeChatRobot_FormatStringOffsetTable[] =
2232,
2274,
2322,
2382
2382,
2424
};
static const MIDL_STUBLESS_PROXY_INFO IWeChatRobot_ProxyInfo =
......@@ -3351,7 +3408,7 @@ static const MIDL_SERVER_INFO IWeChatRobot_ServerInfo =
0,
0,
0};
CINTERFACE_PROXY_VTABLE(56) _IWeChatRobotProxyVtbl =
CINTERFACE_PROXY_VTABLE(57) _IWeChatRobotProxyVtbl =
{
&IWeChatRobot_ProxyInfo,
&IID_IWeChatRobot,
......@@ -3410,7 +3467,8 @@ CINTERFACE_PROXY_VTABLE(56) _IWeChatRobotProxyVtbl =
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetQrcodeImage */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetA8Key */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CSendXmlMsg */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CLogout */
(void *) (INT_PTR) -1 /* IWeChatRobot::CLogout */ ,
(void *) (INT_PTR) -1 /* IWeChatRobot::CGetTransfer */
};
......@@ -3468,6 +3526,7 @@ static const PRPC_STUB_FUNCTION IWeChatRobot_table[] =
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2,
NdrStubCall2
};
......@@ -3475,7 +3534,7 @@ CInterfaceStubVtbl _IWeChatRobotStubVtbl =
{
&IID_IWeChatRobot,
&IWeChatRobot_ServerInfo,
56,
57,
&IWeChatRobot_table[-3],
CStdStubBuffer_DELEGATING_METHODS
};
......@@ -3491,8 +3550,8 @@ static const unsigned short IRobotEvent_FormatStringOffsetTable[] =
(unsigned short) -1,
(unsigned short) -1,
(unsigned short) -1,
2424,
2484
2484,
2544
};
static const MIDL_STUBLESS_PROXY_INFO IRobotEvent_ProxyInfo =
......
......@@ -34,6 +34,7 @@
#include "GetA8Key.h"
#include "SendXmlMsg.h"
#include "Logout.h"
#include "GetTransfer.h"
#define DLLNAME L"DWeChatRobot.dll"
......@@ -97,3 +98,5 @@
#define GetA8KeyRemote "GetA8KeyRemote"
#define SendXmlMsgRemote "SendXmlMsgRemote"
#define LogoutRemote "Logout"
#define GetTransferRemote "GetTransferRemote"
......@@ -331,6 +331,7 @@ xcopy /y /d "$(OutDir)..\..\Python\http\wxDriver.py" "$(SolutionDir)build\http
<ClInclude Include="GetChatRoomMembers.h" />
<ClInclude Include="GetDbHandles.h" />
<ClInclude Include="GetHistoryPublicMsg.h" />
<ClInclude Include="GetTransfer.h" />
<ClInclude Include="LogMsgInfo.h" />
<ClInclude Include="http_overload.hpp" />
<ClInclude Include="Logout.h" />
......@@ -380,6 +381,7 @@ xcopy /y /d "$(OutDir)..\..\Python\http\wxDriver.py" "$(SolutionDir)build\http
<ClCompile Include="GetChatRoomMemebers.cpp" />
<ClCompile Include="GetDbHandles.cpp" />
<ClCompile Include="GetHistoryPublicMsg.cpp" />
<ClCompile Include="GetTransfer.cpp" />
<ClCompile Include="HookImageMessage.cpp" />
<ClCompile Include="HookVoiceMessage.cpp" />
<ClCompile Include="Logout.cpp" />
......
......@@ -142,6 +142,12 @@
<Filter Include="登录相关\退出登录">
<UniqueIdentifier>{e00caf3d-a0c2-4915-9ca5-47e429b4fcbf}</UniqueIdentifier>
</Filter>
<Filter Include="未分类">
<UniqueIdentifier>{75895983-2efe-413f-a71b-1b1891b109a3}</UniqueIdentifier>
</Filter>
<Filter Include="未分类\收款">
<UniqueIdentifier>{f24eb4af-96d0-41a3-ba1a-799d49f2fb4e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h">
......@@ -276,6 +282,9 @@
<ClInclude Include="Logout.h">
<Filter>登录相关\退出登录</Filter>
</ClInclude>
<ClInclude Include="GetTransfer.h">
<Filter>未分类\收款</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp">
......@@ -413,5 +422,8 @@
<ClCompile Include="Logout.cpp">
<Filter>登录相关\退出登录</Filter>
</ClCompile>
<ClCompile Include="GetTransfer.cpp">
<Filter>未分类\收款</Filter>
</ClCompile>
</ItemGroup>
</Project>
#include "pch.h"
#define GetTransferCallOffset 0x10CD2770 - 0x10000000
#define GetTransferHandleOffset 0x5D02F4F4 - 0x5B1B0000
struct TransferStruct
{
DWORD handle = 0;
DWORD unknown_value1 = 0x1;
WxString amount = {0};
WxString transcationid = {0};
DWORD time1 = 0;
DWORD time2 = 0;
WxString transferid = {0};
DWORD unknown_value2 = 0x1;
char null_buf1[0xE0] = {0};
DWORD unknown_value3 = 0x820000;
char null_buf2[0x64] = {0};
};
#ifndef USE_SOCKET
struct GetTransferStruct
{
wchar_t *wxid = NULL;
wchar_t *transcationid = NULL;
wchar_t *transferid = NULL;
};
BOOL GetTransferRemote(LPVOID lpParameter)
{
GetTransferStruct *gts = (GetTransferStruct *)lpParameter;
return GetTransfer(gts->wxid, gts->transcationid, gts->transferid);
}
#endif
BOOL __stdcall GetTransfer(wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid)
{
DWORD WeChatWinBase = GetWeChatWinBase();
DWORD GetTransferCallAddr = WeChatWinBase + GetTransferCallOffset;
DWORD GetTransferHandleAddr = WeChatWinBase + GetTransferHandleOffset;
TransferStruct tf;
tf.handle = GetTransferHandleAddr;
tf.transcationid.set_value(transcationid);
tf.transferid.set_value(transferid);
WxString p_wxid(wxid);
int isSuccess = 0x0;
__asm {
pushad;
pushfd;
push 0x1;
lea edx,p_wxid;
lea ecx,tf;
sub esp,0x8;
call GetTransferCallAddr;
add esp,0xC;
movzx eax,al;
mov isSuccess,eax;
popfd;
popad;
}
return isSuccess;
}
#pragma once
#include <windows.h>
BOOL __stdcall GetTransfer(wchar_t *wxid, wchar_t *transcationid, wchar_t *transferid);
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) BOOL GetTransferRemote(LPVOID lpParameter);
#endif
......@@ -25,6 +25,10 @@ using namespace std;
// 撤回消息HOOK的CALL偏移
#define UpdateMessageNextCallOffset 0x5D6D3430 - 0x5D1F0000
// 音视频通话
#define VoipAckMessageHookOffset 0x1054A18F - 0x10000000
#define VoipAckMessageNextCallOffset 0x1022BA60 - 0x10000000
#define READ_WSTRING(addr, offset) ((*(DWORD *)(addr + offset + 0x4) == 0) ? wstring(L"") : wstring((wchar_t *)(*(DWORD *)(addr + offset)), *(DWORD *)(addr + offset + 0x4)))
static int SRVPORT = 0;
......@@ -35,6 +39,7 @@ BOOL ReceiveMessageHooked = false;
static char OldReceiveMessageAsmCode[5] = {0};
static char OldSendMessageAsmCode[5] = {0};
static char OldUpdateMessageAsmCode[5] = {0};
static char OldVoipAckMessageAsmCode[5] = {0};
static DWORD WeChatWinBase = GetWeChatWinBase();
// 接收消息HOOK地址
static DWORD ReceiveMessageHookAddress = WeChatWinBase + ReceiveMessageHookOffset;
......@@ -54,6 +59,10 @@ static DWORD UpdateMessageHookAddress = WeChatWinBase + UpdateMessageHookOffset;
static DWORD UpdateMessageNextCall = WeChatWinBase + UpdateMessageNextCallOffset;
// 撤回HOOK的跳转地址
static DWORD UpdateMessageJmpBackAddress = UpdateMessageHookAddress + 0x5;
// 音视频通话
static DWORD VoipAckMessageHookAddress = WeChatWinBase + VoipAckMessageHookOffset;
static DWORD VoipAckMessageNextCall = WeChatWinBase + VoipAckMessageNextCallOffset;
static DWORD VoipAckMessageJmpBackAddress = VoipAckMessageHookAddress + 0x5;
struct SocketMessageStruct
{
......@@ -157,7 +166,7 @@ void SendSocketMessageInThread(SocketMessageStruct *param)
LOG(INFO) << "msgid: " << jMsg["msgid"].get<ULONG64>() << " send end." << endl;
}
static void dealMessage(DWORD messageAddr)
static void dealMessage(DWORD messageAddr, int msg_source)
{
json jMsg;
unsigned long long msgid = *(unsigned long long *)(messageAddr + 0x30);
......@@ -166,7 +175,7 @@ static void dealMessage(DWORD messageAddr)
jMsg["isSendMsg"] = *(BOOL *)(messageAddr + 0x3C);
if (jMsg["isSendMsg"].get<BOOL>())
{
jMsg["isSendByPhone"] = (int)(*(BYTE *)(messageAddr + 0xD8));
jMsg["isSendByPhone"] = (msg_source == MSG_SYNC) ? 1 : 0; // (int)(*(BYTE *)(messageAddr + 0xD8));
}
jMsg["msgid"] = msgid;
// jMsg["localId"] = *(unsigned int *)(messageAddr + 0x20);
......@@ -210,7 +219,7 @@ void OnReceiveMessage(DWORD messagesAddr)
DWORD *messages = (DWORD *)messagesAddr;
for (DWORD messageAddr = messages[0]; messageAddr < messages[1]; messageAddr += 0x298)
{
dealMessage(messageAddr);
dealMessage(messageAddr, MSG_SYNC);
}
}
......@@ -222,7 +231,7 @@ void OnSendMessage(DWORD messageAddr)
BOOL isSendMsg = *(BOOL *)(messageAddr + 0x3C);
if (!isSendMsg)
return;
dealMessage(messageAddr);
dealMessage(messageAddr, MSG_SEND);
}
/*
......@@ -231,7 +240,17 @@ void OnSendMessage(DWORD messageAddr)
void OnUpdateMessage(DWORD messageAddr)
{
// DWORD type = *(DWORD *)(messageAddr + 0x38);
dealMessage(messageAddr);
dealMessage(messageAddr, MSG_UPDATE);
}
/*
* 处理音视频通话
*/
void OnVoipAckMessage(DWORD messageAddr)
{
DWORD type = *(DWORD *)(messageAddr + 0x38);
if (type == 0x32 || type == 0x33 || type == 0x2712)
dealMessage(messageAddr, MSG_SYNC);
}
/*
......@@ -288,6 +307,24 @@ _declspec(naked) void dealRevokeMessage()
}
}
/*
* HOOK的具体实现,接收到撤回消息后调用处理函数
*/
_declspec(naked) void dealVoipAckMessage()
{
__asm {
pushad;
pushfd;
push ecx;
call OnVoipAckMessage;
add esp, 0x4;
popfd;
popad;
call VoipAckMessageNextCall;
jmp VoipAckMessageJmpBackAddress;
}
}
/*
* 开始接收消息HOOK
* return:void
......@@ -307,9 +344,13 @@ VOID HookReceiveMessage(int port)
UpdateMessageHookAddress = WeChatWinBase + UpdateMessageHookOffset;
UpdateMessageNextCall = WeChatWinBase + UpdateMessageNextCallOffset;
UpdateMessageJmpBackAddress = UpdateMessageHookAddress + 0x5;
VoipAckMessageHookAddress = WeChatWinBase + VoipAckMessageHookOffset;
VoipAckMessageNextCall = WeChatWinBase + VoipAckMessageNextCallOffset;
VoipAckMessageJmpBackAddress = VoipAckMessageHookAddress + 0x5;
HookAnyAddress(ReceiveMessageHookAddress, (LPVOID)dealReceiveMessage, OldReceiveMessageAsmCode);
HookAnyAddress(SendMessageHookAddress, (LPVOID)dealSendMessage, OldSendMessageAsmCode);
HookAnyAddress(UpdateMessageHookAddress, (LPVOID)dealRevokeMessage, OldUpdateMessageAsmCode);
HookAnyAddress(VoipAckMessageHookAddress, (LPVOID)dealVoipAckMessage, OldVoipAckMessageAsmCode);
ReceiveMessageHooked = TRUE;
}
......@@ -325,5 +366,6 @@ VOID UnHookReceiveMessage()
UnHookAnyAddress(ReceiveMessageHookAddress, OldReceiveMessageAsmCode);
UnHookAnyAddress(SendMessageHookAddress, OldSendMessageAsmCode);
UnHookAnyAddress(UpdateMessageHookAddress, OldUpdateMessageAsmCode);
UnHookAnyAddress(VoipAckMessageHookAddress, OldVoipAckMessageAsmCode);
ReceiveMessageHooked = FALSE;
}
......@@ -18,3 +18,11 @@ BOOL __stdcall HookImageMsg(wstring save_path);
void __stdcall HookVoiceMsg();
void __stdcall HookImageMsg();
typedef enum MSG_SOURCE_TYPETag
{
MSG_SYNC,
MSG_UPDATE,
MSG_SEND,
} MSG_SOURCE,
*PMSG_SOURCE;
......@@ -121,10 +121,10 @@ BOOL __stdcall SendFile(wchar_t *receiver, wchar_t *FilePath)
mov al,byte ptr [eax + 0x38];
movzx eax,al;
mov isSuccess,eax;
push 200;
call Sleep;
lea ecx, buffer;
call DeleteSendFileCacheCall;
// push 200;
// call Sleep;
// lea ecx, buffer;
// call DeleteSendFileCacheCall;
popfd;
popad;
}
......
......@@ -28,10 +28,10 @@ struct ImageParamStruct
* return:void
*/
#ifndef USE_SOCKET
void SendImageRemote(LPVOID lpParamStruct)
BOOL SendImageRemote(LPVOID lpParamStruct)
{
ImageParamStruct *params = (ImageParamStruct *)lpParamStruct;
SendImage((WCHAR *)params->wxid, (WCHAR *)params->imagepath);
return SendImage((WCHAR *)params->wxid, (WCHAR *)params->imagepath);
}
#endif
......@@ -77,5 +77,5 @@ BOOL __stdcall SendImage(wchar_t *receiver, wchar_t *ImagePath)
call DeleteSendImageCacheCall;
popad;
}
return isSuccess == 1;
return isSuccess;
}
......@@ -3,5 +3,5 @@
BOOL __stdcall SendImage(wchar_t *receiver, wchar_t *ImagePath);
#ifndef USE_SOCKET
extern "C" __declspec(dllexport) void SendImageRemote(LPVOID lpParamStruct);
extern "C" __declspec(dllexport) BOOL SendImageRemote(LPVOID lpParamStruct);
#endif
......@@ -143,4 +143,9 @@ BOOL __stdcall SendXmlMsg(wstring wxid, wstring xml, wstring imgpath)
{
return SendXmlMsg(WS2LW(wxid), WS2LW(xml), WS2LW(imgpath));
}
BOOL __stdcall GetTransfer(wstring wxid, wstring transcationid, wstring transferid)
{
return GetTransfer(WS2LW(wxid), WS2LW(transcationid), WS2LW(transferid));
}
#endif
......@@ -36,6 +36,7 @@
#include "GetQrcodeImage.h"
#include "GetA8Key.h"
#include "Logout.h"
#include "GetTransfer.h"
using namespace std;
#pragma comment(lib, "version.lib")
......
......@@ -47,6 +47,12 @@ struct WxString
length = wcslen(pStr);
maxLength = wcslen(pStr) * 2;
}
void set_value(const wchar_t *pStr)
{
buffer = (wchar_t *)pStr;
length = wcslen(pStr);
maxLength = wcslen(pStr) * 2;
}
};
/*
......
......@@ -620,6 +620,16 @@ void request_event(mg_http_message *hm, string &ret, struct mg_connection *c)
ret = ret_data.dump();
break;
}
case WECHAT_GET_TRANSFER:
{
wstring wxid = get_http_param_str(hm, jData, "wxid", method);
wstring transcationid = get_http_param_str(hm, jData, "transcationid", method);
wstring transferid = get_http_param_str(hm, jData, "transferid", method);
BOOL response = GetTransfer(wxid, transcationid, transferid);
json ret_data = {{"msg", response}, {"result", "OK"}};
ret = ret_data.dump();
break;
}
default:
// char* wxid = mg_json_get_str(hm->body, "$.wxid");
break;
......
......@@ -76,6 +76,7 @@ typedef enum WECHAT_HTTP_APISTag
WECHAT_GET_A8KEY,
WECHAT_MSG_SEND_XML,
WECHAT_LOGOUT,
WECHAT_GET_TRANSFER,
} WECHAT_HTTP_APIS,
*PWECHAT_HTTP_APIS;
#endif
......@@ -1134,6 +1134,27 @@ class WeChatRobot:
"""
return self.robot.CLogout(self.pid)
def GetTransfer(self,wxid:str,transcationid:str,transferid:str) -> int:
"""
收款
Parameters
----------
wxid : str
转账人wxid.
transcationid : str
从转账消息xml中获取.
transferid : str
从转账消息xml中获取.
Returns
-------
int
成功返回0,失败返回非0值.
"""
return self.robot.CGetTransfer(self.pid,wxid,transcationid,transferid)
def get_wechat_pid_list() -> list:
"""
......
......@@ -85,7 +85,10 @@ class WECHAT_HTTP_APIS:
WECHAT_MSG_FORWARD_MESSAGE = 40 # 转发消息
WECHAT_GET_QRCODE_IMAGE = 41 # 获取二维码
WECHAT_GET_A8KEY = 42
WECHAT_GET_A8KEY = 42 # 获取A8Key
WECHAT_MSG_SEND_XML = 43 # 发送xml消息
WECHAT_LOGOUT = 44 # 退出登录
WECHAT_GET_TRANSFER = 45 # 收款
APIS = WECHAT_HTTP_APIS
......@@ -191,7 +194,10 @@ class WECHAT_HTTP_API_PARAM_TEMPLATES:
APIS.WECHAT_MSG_FORWARD_MESSAGE: {"wxid": "filehelper","msgid": 2 ** 64 - 1},
APIS.WECHAT_GET_QRCODE_IMAGE: {},
APIS.WECHAT_GET_A8KEY: {"url":""}
APIS.WECHAT_GET_A8KEY: {"url":""},
APIS.WECHAT_MSG_SEND_XML: {"wxid":"filehelper","xml":"","img_path":""},
APIS.WECHAT_LOGOUT: {},
APIS.WECHAT_GET_TRANSFER: {"wxid":"","transcationid":"","transferid":""}
}
def get_http_template(self, api_number):
......@@ -337,8 +343,8 @@ if __name__ == '__main__':
if len(pids) == 0:
pids.append(new_wechat())
start_listen(pids[0],port)
post_wechat_http_api(APIS.WECHAT_LOG_START_HOOK,8000)
print(post_wechat_http_api(APIS.WECHAT_GET_SELF_INFO, 8000))
post_wechat_http_api(APIS.WECHAT_MSG_START_HOOK,8000,{"port":10808})
post_wechat_http_api(APIS.WECHAT_LOG_START_HOOK,port)
print(post_wechat_http_api(APIS.WECHAT_GET_SELF_INFO, port))
post_wechat_http_api(APIS.WECHAT_MSG_START_HOOK,port,{"port":10808})
start_socket_server()
stop_listen(pids[0])
......@@ -155,6 +155,10 @@ CWeChatRobot.exe /unregserver
2. 新增退出登录接口
3. 尝试修复文件发送失败和格式化时间戳导致崩溃问题
4. 实时消息新增一个字段,用于获取视频消息缩略图保存位置
## 2022.10.16
1. 新增收款接口
2. 实时消息接口优化,支持获取音视频聊天信息,支持获取手机端切换联系人时的提示信息
3. 修复部分已知问题
# 打赏作者
请给作者一个star,感谢感谢
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册